@Test public void testCreateRefreshToken() { doReturn(this.spotifyApi).when(this.spotifyAPICalls).getSpotifyApi(); assertThat(this.spotifyAPICalls.createRefreshToken("a"), equalTo(false)); }
public boolean createRefreshToken(String authCode) { AuthorizationCodeRequest authorizationCodeRequest = getSpotifyApi().authorizationCode(authCode).build(); AuthorizationCodeCredentials authCodeCredentials = exceptionHandlingWithResults( authorizationCodeRequest::execute); if (authCodeCredentials != null) { this.userData = new User(); this.storage.put(SPOTIFY_REFRSHTOKEN_KEY, authCodeCredentials.getRefreshToken()); this.userData.setRefreshToken(authCodeCredentials.getRefreshToken()); if (getDevices().length > 0) { this.userData.setCurrentDeviceId(getDevices()[0].getId()); } return true; } return false; }
SpotifyAPICalls { public boolean createRefreshToken(String authCode) { AuthorizationCodeRequest authorizationCodeRequest = getSpotifyApi().authorizationCode(authCode).build(); AuthorizationCodeCredentials authCodeCredentials = exceptionHandlingWithResults( authorizationCodeRequest::execute); if (authCodeCredentials != null) { this.userData = new User(); this.storage.put(SPOTIFY_REFRSHTOKEN_KEY, authCodeCredentials.getRefreshToken()); this.userData.setRefreshToken(authCodeCredentials.getRefreshToken()); if (getDevices().length > 0) { this.userData.setCurrentDeviceId(getDevices()[0].getId()); } return true; } return false; } }
SpotifyAPICalls { public boolean createRefreshToken(String authCode) { AuthorizationCodeRequest authorizationCodeRequest = getSpotifyApi().authorizationCode(authCode).build(); AuthorizationCodeCredentials authCodeCredentials = exceptionHandlingWithResults( authorizationCodeRequest::execute); if (authCodeCredentials != null) { this.userData = new User(); this.storage.put(SPOTIFY_REFRSHTOKEN_KEY, authCodeCredentials.getRefreshToken()); this.userData.setRefreshToken(authCodeCredentials.getRefreshToken()); if (getDevices().length > 0) { this.userData.setCurrentDeviceId(getDevices()[0].getId()); } return true; } return false; }  }
SpotifyAPICalls { public boolean createRefreshToken(String authCode) { AuthorizationCodeRequest authorizationCodeRequest = getSpotifyApi().authorizationCode(authCode).build(); AuthorizationCodeCredentials authCodeCredentials = exceptionHandlingWithResults( authorizationCodeRequest::execute); if (authCodeCredentials != null) { this.userData = new User(); this.storage.put(SPOTIFY_REFRSHTOKEN_KEY, authCodeCredentials.getRefreshToken()); this.userData.setRefreshToken(authCodeCredentials.getRefreshToken()); if (getDevices().length > 0) { this.userData.setCurrentDeviceId(getDevices()[0].getId()); } return true; } return false; }  SpotifyApi getSpotifyApi(); URI authorizationCodeUri(); boolean createRefreshToken(String authCode); void setClientID(String clientID); void setClientSecret(String clientSecret); boolean setCurrentDevice(String deviceID); boolean checkPlayerState(); Device[] getDevices(); Device getActiveDevice(); boolean checkDeviceIsLoggedIn(String deviceId); boolean playSongFromUri(String uri); boolean playListFromUri(String uri); boolean resume(); boolean pause(); boolean skip(); boolean back(); boolean setVolume(int volume); int getVolume(); CurrentlyPlayingContext getCurrentPlayingContext(); boolean getIsPlaying(); SearchResult searchInSpotify(String searchItem, String type, int limit); FeaturedPlaylists getFeaturedPlaylists(int limit); Paging<PlaylistSimplified> getOwnPlaylists(int limit); }
SpotifyAPICalls { public boolean createRefreshToken(String authCode) { AuthorizationCodeRequest authorizationCodeRequest = getSpotifyApi().authorizationCode(authCode).build(); AuthorizationCodeCredentials authCodeCredentials = exceptionHandlingWithResults( authorizationCodeRequest::execute); if (authCodeCredentials != null) { this.userData = new User(); this.storage.put(SPOTIFY_REFRSHTOKEN_KEY, authCodeCredentials.getRefreshToken()); this.userData.setRefreshToken(authCodeCredentials.getRefreshToken()); if (getDevices().length > 0) { this.userData.setCurrentDeviceId(getDevices()[0].getId()); } return true; } return false; }  SpotifyApi getSpotifyApi(); URI authorizationCodeUri(); boolean createRefreshToken(String authCode); void setClientID(String clientID); void setClientSecret(String clientSecret); boolean setCurrentDevice(String deviceID); boolean checkPlayerState(); Device[] getDevices(); Device getActiveDevice(); boolean checkDeviceIsLoggedIn(String deviceId); boolean playSongFromUri(String uri); boolean playListFromUri(String uri); boolean resume(); boolean pause(); boolean skip(); boolean back(); boolean setVolume(int volume); int getVolume(); CurrentlyPlayingContext getCurrentPlayingContext(); boolean getIsPlaying(); SearchResult searchInSpotify(String searchItem, String type, int limit); FeaturedPlaylists getFeaturedPlaylists(int limit); Paging<PlaylistSimplified> getOwnPlaylists(int limit); static final String SPOTIFY_CLIENTSECRET_KEY; static final String SPOTIFY_CLIENTID_KEY; static final String SPOTIFY_REFRSHTOKEN_KEY; static final int TOKEN_EXPIRE_TIME_OFFSET; static final String SPOTIFY_ERROR_TAG; }