AuthenticationClient { public static Intent createLoginActivityIntent(Activity contextActivity, AuthenticationRequest request) { return LoginActivity.getAuthIntent(contextActivity, request); } AuthenticationClient(Activity activity); static void openLoginInBrowser(Activity contextActivity, AuthenticationRequest request); static Intent createLoginActivityIntent(Activity contextActivity, AuthenticationRequest request); static void openLoginActivity(Activity contextActivity, int requestCode, AuthenticationRequest request); static void stopLoginActivity(Activity contextActivity, int requestCode); static AuthenticationResponse getResponse(int resultCode, Intent intent); static void openDownloadSpotifyActivity(Activity contextActivity); static void openDownloadSpotifyActivity(Activity contextActivity, String campaign); static boolean isAvailable(Context ctx, Intent intent);  }
@Test public void createLoginActivityIntentShouldReturnAnIntentWithExtrasInIt() { AuthenticationRequest authenticationRequest = new AuthenticationRequest .Builder("test", AuthenticationResponse.Type.TOKEN, "to: .setScopes(new String[]{"testa", "toppen"}) .build(); Activity activity = mock(Activity.class); Intent intent = AuthenticationClient.createLoginActivityIntent(activity, authenticationRequest); AuthenticationRequest extra = intent .getBundleExtra(LoginActivity.EXTRA_AUTH_REQUEST).getParcelable(LoginActivity.REQUEST_KEY); assertNotNull(extra); assertEquals("test", extra.getClientId()); assertEquals("token", extra.getResponseType()); assertEquals("to: assertEquals(2, extra.getScopes().length); }
@Test(expected = IllegalArgumentException.class) public void createLoginActivityIntentShouldThrowExceptionWhenBothPassedIsNull() { AuthenticationClient.createLoginActivityIntent(null, null); }
@Test(expected = IllegalArgumentException.class) public void createLoginActivityIntentShouldThrowExceptionWhenFirstPassedIsNull() { AuthenticationRequest authenticationRequest = mock(AuthenticationRequest.class); AuthenticationClient.createLoginActivityIntent(null, authenticationRequest); }
@Test(expected = IllegalArgumentException.class) public void createLoginActivityIntentShouldThrowExceptionWhenSecondPassedIsNull() { Activity activity = mock(Activity.class); AuthenticationClient.createLoginActivityIntent(activity, null); }