Skip to content

Commit f8b6b6f

Browse files
committed
Added: Tests : Playlist API
1 parent 066a78f commit f8b6b6f

File tree

2 files changed

+122
-11
lines changed

2 files changed

+122
-11
lines changed

src/main/java/Client/SpotifyRestAPI.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ public Controller.PlaylistController.UserPlaylists.BasePlaylist getListCurrUserP
14971497

14981498
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
14991499

1500-
Call<Controller.PlaylistController.UserPlaylists.BasePlaylist> call = playlistInterface.getListOfCurrUserPlaylists(getTokenString(client.getToken()));
1500+
Call<Controller.PlaylistController.UserPlaylists.BasePlaylist> call = playlistInterface.getListOfCurrUserPlaylists(getTokenString(client.getLogin().getAccessToken()));
15011501

15021502
Response<Controller.PlaylistController.UserPlaylists.BasePlaylist> response = call.execute();
15031503

@@ -1518,7 +1518,7 @@ public Controller.PlaylistController.UserPlaylists.BasePlaylist getListUserPlayl
15181518

15191519
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
15201520

1521-
Call<Controller.PlaylistController.UserPlaylists.BasePlaylist> call = playlistInterface.getListOfSpecifiedUserPlaylists(getTokenString(client.getToken()),userId);
1521+
Call<Controller.PlaylistController.UserPlaylists.BasePlaylist> call = playlistInterface.getListOfSpecifiedUserPlaylists(getTokenString(client.getLogin().getAccessToken()),userId);
15221522

15231523
Response<Controller.PlaylistController.UserPlaylists.BasePlaylist> response = call.execute();
15241524

@@ -1539,7 +1539,7 @@ public Controller.PlaylistController.UserPlaylists.CreatePlaylist.BasePlaylist c
15391539

15401540
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
15411541

1542-
Call<Controller.PlaylistController.UserPlaylists.CreatePlaylist.BasePlaylist> call = playlistInterface.createAPlaylist(getTokenString(client.getToken()),client.getUser().getTheUser().get(0),client.getPlaylist().getName());
1542+
Call<Controller.PlaylistController.UserPlaylists.CreatePlaylist.BasePlaylist> call = playlistInterface.createAPlaylist(getTokenString(client.getLogin().getAccessToken()),client.getUser().getTheUser().get(0),client.getPlaylist().getName());
15431543

15441544
Response<Controller.PlaylistController.UserPlaylists.CreatePlaylist.BasePlaylist> response = call.execute();
15451545

@@ -1558,7 +1558,7 @@ public Playlist getAPlaylist(SpotifyClient client) throws IOException {
15581558

15591559
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
15601560

1561-
Call<Playlist> call = playlistInterface.getPlaylist(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId());
1561+
Call<Playlist> call = playlistInterface.getPlaylist(getTokenString(client.getLogin().getAccessToken()),client.getPlaylist().getPlaylistId());
15621562

15631563
Response<Playlist> response = call.execute();
15641564

@@ -1578,7 +1578,7 @@ public boolean changePlaylistDetails(SpotifyClient client) throws IOException {
15781578

15791579
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
15801580

1581-
Call<Object> call = playlistInterface.changePlaylistDetails(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId());
1581+
Call<Object> call = playlistInterface.changePlaylistDetails(getTokenString(client.getLogin().getAccessToken()),client.getPlaylist().getPlaylistId());
15821582

15831583
Response<Object> response = call.execute();
15841584

@@ -1596,7 +1596,7 @@ public BasePlaylistItems getPlaylistItems(SpotifyClient client) throws IOExcepti
15961596

15971597
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
15981598

1599-
Call<BasePlaylistItems> call = playlistInterface.getPlaylistItems(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId());
1599+
Call<BasePlaylistItems> call = playlistInterface.getPlaylistItems(getTokenString(client.getLogin().getAccessToken()),client.getPlaylist().getPlaylistId());
16001600

16011601
Response<BasePlaylistItems> response = call.execute();
16021602

@@ -1615,7 +1615,7 @@ public SnapshotId addItemsToPlaylist(SpotifyClient client) throws IOException {
16151615

16161616
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
16171617

1618-
Call<SnapshotId> call = playlistInterface.addItemsToPlaylist(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId());
1618+
Call<SnapshotId> call = playlistInterface.addItemsToPlaylist(getTokenString(client.getLogin().getAccessToken()),client.getPlaylist().getPlaylistId());
16191619

16201620
Response<SnapshotId> response = call.execute();
16211621

@@ -1634,7 +1634,7 @@ public SnapshotId reorderOrReplacePlaylistItems(SpotifyClient client) throws IOE
16341634

16351635
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
16361636

1637-
Call<SnapshotId> call = playlistInterface.reorderOrReplacePlaylistsItems(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId());
1637+
Call<SnapshotId> call = playlistInterface.reorderOrReplacePlaylistsItems(getTokenString(client.getLogin().getAccessToken()),client.getPlaylist().getPlaylistId());
16381638

16391639
Response<SnapshotId> response = call.execute();
16401640

@@ -1653,7 +1653,7 @@ public SnapshotId removePlaylistItems(SpotifyClient client) throws IOException {
16531653

16541654
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
16551655

1656-
Call<SnapshotId> call = playlistInterface.removeItemsFromPlaylist(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId(),client.getTrackIds().convertTrackIds());
1656+
Call<SnapshotId> call = playlistInterface.removeItemsFromPlaylist(getTokenString(client.getLogin().getAccessToken()),client.getPlaylist().getPlaylistId(),client.getTrackIds().convertTrackIds());
16571657

16581658
Response<SnapshotId> response = call.execute();
16591659

@@ -1672,7 +1672,7 @@ public CoverImage getPlaylistCoverImage(SpotifyClient client) throws IOException
16721672

16731673
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
16741674

1675-
Call<CoverImage> call = playlistInterface.getPlaylistCoverImage(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId());
1675+
Call<CoverImage> call = playlistInterface.getPlaylistCoverImage(getTokenString(client.getLogin().getAccessToken()),client.getPlaylist().getPlaylistId());
16761676

16771677
Response<CoverImage> response = call.execute();
16781678

@@ -1691,7 +1691,7 @@ public boolean uploadCustomPlaylistImage(SpotifyClient client) throws IOExceptio
16911691

16921692
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
16931693

1694-
Call<Object> call = playlistInterface.uploadPlaylistCoverImage(getTokenString(client.getToken()),client.getContentType(),client.getPlaylist().getPlaylistId());
1694+
Call<Object> call = playlistInterface.uploadPlaylistCoverImage(getTokenString(client.getLogin().getAccessToken()),client.getContentType(),client.getPlaylist().getPlaylistId());
16951695

16961696
Response<Object> response = call.execute();
16971697

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
package getRequests;
2+
3+
import Client.SpotifyClient;
4+
import Client.SpotifyLogin;
5+
import org.junit.jupiter.api.Test;
6+
7+
import java.io.IOException;
8+
9+
import static org.junit.jupiter.api.Assertions.assertNotNull;
10+
import static org.junit.jupiter.api.Assertions.assertTrue;
11+
12+
public class PlaylistTest {
13+
14+
static SpotifyClient client;
15+
16+
static {
17+
try {
18+
client = new SpotifyClient("d56c8c3f79a1459bba2c286cfa7aa15b", "9dcd475a773d467990dd75eede0af55f");
19+
20+
SpotifyLogin login = client.getLogin();
21+
login.setEmailOrUsername("exampleEmail");
22+
login.setPassword("examplePasword");
23+
login.setRedirectUri("exampleRedirectURI");
24+
login.addScope("user-modify-playback-state");
25+
client.requestAuthCodeFlowCode(client);
26+
client.generateAccessTokenAndRefreshToken(client);
27+
28+
29+
} catch (IOException | InterruptedException e) {
30+
e.printStackTrace();
31+
}
32+
}
33+
34+
@Test
35+
void testGetListOfCurrUserPlaylist() throws IOException {
36+
37+
assertNotNull(client.getListCurrUserPlaylists(client));
38+
39+
}
40+
41+
@Test
42+
void testGetListOfUserPlaylist() throws IOException{
43+
44+
assertNotNull(client.getListUserPlaylists(client));
45+
46+
}
47+
48+
@Test
49+
void testCreateAPlaylist() throws IOException{
50+
51+
assertNotNull(client.createAPlaylist(client));
52+
53+
}
54+
55+
@Test
56+
void testGetAPlaylist() throws IOException{
57+
58+
assertNotNull(client.getAPlaylist(client));
59+
60+
}
61+
62+
@Test
63+
void testChangePlaylistDetails() throws IOException{
64+
65+
assertTrue(client.changePlaylistDetails(client));
66+
67+
}
68+
69+
@Test
70+
void testGetPlaylistItems() throws IOException{
71+
72+
assertNotNull(client.getPlaylistItems(client));
73+
74+
}
75+
76+
@Test
77+
void testAddItemsToPlaylist() throws IOException{
78+
79+
assertNotNull(client.addItemsToPlaylist(client));
80+
81+
}
82+
83+
@Test
84+
void testReorderOrReplacePlaylistItems() throws IOException{
85+
86+
assertNotNull(client.reorderOrReplacePlaylistItems(client));
87+
88+
}
89+
90+
@Test
91+
void testRemoveItemsFromPlaylist() throws IOException{
92+
93+
assertNotNull(client.removePlaylistItems(client));
94+
95+
}
96+
97+
@Test
98+
void testGetPlaylistCoverImage() throws IOException{
99+
100+
assertNotNull(client.getPlaylistCoverImage(client));
101+
102+
}
103+
104+
@Test
105+
void testUploadCustomPlaylistImage() throws IOException{
106+
107+
assertTrue(client.uploadCustomPlaylistImage(client));
108+
109+
}
110+
111+
}

0 commit comments

Comments
 (0)