Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.stream.Collectors;

public abstract class AbstractRequest<T> implements IRequest<T> {
Expand Down Expand Up @@ -241,7 +242,8 @@ public BT setPath(final String path) {
for (NameValuePair nameValuePair : pathParameters) {
// Don't remove the "\\" before the "}" to prevent a regex issue on Android.
String key = "\\{" + nameValuePair.getName() + "\\}";
builtPath = builtPath.replaceAll(key, nameValuePair.getValue());
String value = nameValuePair.getValue();
builtPath = builtPath.replaceAll(key, Matcher.quoteReplacement(value));
}

this.path = builtPath;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"href": "https://api.spotify.com/v1/users/%24wizzler%24/playlists",
"items": [
{
"collaborative": false,
"external_urls": {
"spotify": "http://open.spotify.com/user/%24wizzler%24/playlists/53Y8wT46QIMz5H4WQ8O22c"
},
"href": "https://api.spotify.com/v1/users/%24wizzler%24/playlists/53Y8wT46QIMz5H4WQ8O22c",
"id": "53Y8wT46QIMz5H4WQ8O22c",
"images": [],
"name": "Wizzlers Big Playlist",
"owner": {
"external_urls": {
"spotify": "http://open.spotify.com/user/wizzler"
},
"href": "https://api.spotify.com/v1/users/wizzler",
"id": "$wizzler$",
"type": "user",
"uri": "spotify:user:%24wizzler%24"
},
"public": true,
"snapshot_id": "bNLWdmhh+HDsbHzhckXeDC0uyKyg4FjPI/KEsKjAE526usnz2LxwgyBoMShVL+z+",
"tracks": {
"href": "https://api.spotify.com/v1/users/wizzler/playlists/53Y8wT46QIMz5H4WQ8O22c/tracks",
"total": 30
},
"type": "playlist",
"uri": "spotify:user:%24wizzler%24:playlist:53Y8wT46QIMz5H4WQ8O22c"
},
{
"collaborative": false,
"external_urls": {
"spotify": "http://open.spotify.com/user/wizzlersmate/playlists/1AVZz0mBuGbCEoNRQdYQju"
},
"href": "https://api.spotify.com/v1/users/wizzlersmate/playlists/1AVZz0mBuGbCEoNRQdYQju",
"id": "1AVZz0mBuGbCEoNRQdYQju",
"images": [],
"name": "Another Playlist",
"owner": {
"external_urls": {
"spotify": "http://open.spotify.com/user/wizzlersmate"
},
"href": "https://api.spotify.com/v1/users/wizzlersmate",
"id": "wizzlersmate",
"type": "user",
"uri": "spotify:user:wizzlersmate"
},
"public": true,
"snapshot_id": "Y0qg/IT5T02DKpw4uQKc/9RUrqQJ07hbTKyEeDRPOo9LU0g0icBrIXwVkHfQZ/aD",
"tracks": {
"href": "https://api.spotify.com/v1/users/wizzlersmate/playlists/1AVZz0mBuGbCEoNRQdYQju/tracks",
"total": 58
},
"type": "playlist",
"uri": "spotify:user:wizzlersmate:playlist:1AVZz0mBuGbCEoNRQdYQju"
}
],
"limit": 9,
"next": null,
"offset": 0,
"previous": null,
"total": 9
}
1 change: 1 addition & 0 deletions src/test/java/se/michaelthelin/spotify/ITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public interface ITest<T> {
String ID_SHOW = "5AvwZVawapvyhJUIx71pdJ";
String ID_TRACK = "01iyCAUm8EvOFqVWYJ3dVX";
String ID_USER = "abbaspotify";
String ID_USER_WITH_$ = "$wizzler$";
String ID_USER_NON_ASCII = "abbaspötify";
String IMAGE_DATA = readFromFileTry(new File("examples/image_data.txt"));
int INSERT_BEFORE = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ public class GetListOfUsersPlaylistsRequestTest extends AbstractDataTest<Paging<
.offset(ITest.OFFSET)
.build();

private final GetListOfUsersPlaylistsRequest requestWithUserIdWithSymbol$ = ITest.SPOTIFY_API
.getListOfUsersPlaylists(ITest.ID_USER_WITH_$)
.setHttpManager(
TestUtil.MockedHttpManager.returningJson(
"requests/data/playlists/GetListOfUsersPlaylistsRequest_UserWith$.json"))
.limit(ITest.LIMIT)
.offset(ITest.OFFSET)
.build();

public GetListOfUsersPlaylistsRequestTest() throws Exception {
}

Expand All @@ -46,6 +55,30 @@ public void shouldReturnDefault_async() throws ExecutionException, InterruptedEx
shouldReturnDefault(defaultRequest.executeAsync().get());
}

@Test
public void shouldReturnDefaultFor_UserId_With_$_async() throws ExecutionException, InterruptedException {
Paging<PlaylistSimplified> playlistSimplifiedPaging = requestWithUserIdWithSymbol$.executeAsync().get();
assertEquals(
"https://api.spotify.com/v1/users/%24wizzler%24/playlists",
playlistSimplifiedPaging.getHref());
assertEquals(
2,
playlistSimplifiedPaging.getItems().length);
assertEquals(
9,
(int) playlistSimplifiedPaging.getLimit());
assertNull(
playlistSimplifiedPaging.getNext());
assertEquals(
0,
(int) playlistSimplifiedPaging.getOffset());
assertNull(
playlistSimplifiedPaging.getPrevious());
assertEquals(
9,
(int) playlistSimplifiedPaging.getTotal());
}

public void shouldReturnDefault(final Paging<PlaylistSimplified> playlistSimplifiedPaging) {
assertEquals(
"https://api.spotify.com/v1/users/wizzler/playlists",
Expand Down