Skip to content

Commit 6afe552

Browse files
committed
Added: Tests : UsersProfile API
1 parent 1d46a0b commit 6afe552

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

src/main/java/Client/SpotifyRestAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,7 @@ public BaseProfile getCurrUserProfile(SpotifyClient client) throws IOException {
19311931

19321932
userprofileInterface userprofileInterface = retrofit.create(Model.userprofileInterface.class);
19331933

1934-
Call<BaseProfile> call = userprofileInterface.getCurrentUserProfile(getTokenString(client.getToken()));
1934+
Call<BaseProfile> call = userprofileInterface.getCurrentUserProfile(getTokenString(client.getLogin().getAccessToken()));
19351935

19361936
Response<BaseProfile> response = call.execute();
19371937

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
11+
public class UsersProfileTest {
12+
13+
static SpotifyClient client;
14+
15+
static {
16+
try {
17+
client = new SpotifyClient("d56c8c3f79a1459bba2c286cfa7aa15b", "9dcd475a773d467990dd75eede0af55f");
18+
19+
SpotifyLogin login = client.getLogin();
20+
login.setEmailOrUsername("exampleEmail");
21+
login.setPassword("examplePasword");
22+
login.setRedirectUri("exampleRedirectURI");
23+
login.addScope("user-modify-playback-state");
24+
client.requestAuthCodeFlowCode(client);
25+
client.generateAccessTokenAndRefreshToken(client);
26+
27+
28+
} catch (IOException | InterruptedException e) {
29+
e.printStackTrace();
30+
}
31+
}
32+
33+
@Test
34+
void testGetCurrUserProfile() throws IOException{
35+
36+
assertNotNull(client.getCurrUserProfile(client));
37+
38+
}
39+
40+
@Test
41+
void testGetUserProfile() throws IOException{
42+
43+
assertNotNull(client.getUserProfile(client));
44+
45+
}
46+
47+
}

0 commit comments

Comments
 (0)