@Test public void getResponseShouldReturnEmptyWhenSomethingWentWrong() { Intent intent = mock(Intent.class); AuthenticationResponse response = AuthenticationClient.getResponse(Activity.RESULT_CANCELED, intent); assertEquals(AuthenticationResponse.Type.EMPTY, response.getType()); assertNull(response.getAccessToken()); }
public static AuthenticationResponse getResponse(int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK && LoginActivity.getResponseFromIntent(intent) != null) { return LoginActivity.getResponseFromIntent(intent); } else { return new AuthenticationResponse.Builder() .setType(AuthenticationResponse.Type.EMPTY) .build(); } }
AuthenticationClient { public static AuthenticationResponse getResponse(int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK && LoginActivity.getResponseFromIntent(intent) != null) { return LoginActivity.getResponseFromIntent(intent); } else { return new AuthenticationResponse.Builder() .setType(AuthenticationResponse.Type.EMPTY) .build(); } } }
AuthenticationClient { public static AuthenticationResponse getResponse(int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK && LoginActivity.getResponseFromIntent(intent) != null) { return LoginActivity.getResponseFromIntent(intent); } else { return new AuthenticationResponse.Builder() .setType(AuthenticationResponse.Type.EMPTY) .build(); } } AuthenticationClient(Activity activity); }
AuthenticationClient { public static AuthenticationResponse getResponse(int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK && LoginActivity.getResponseFromIntent(intent) != null) { return LoginActivity.getResponseFromIntent(intent); } else { return new AuthenticationResponse.Builder() .setType(AuthenticationResponse.Type.EMPTY) .build(); } } 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); }
AuthenticationClient { public static AuthenticationResponse getResponse(int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK && LoginActivity.getResponseFromIntent(intent) != null) { return LoginActivity.getResponseFromIntent(intent); } else { return new AuthenticationResponse.Builder() .setType(AuthenticationResponse.Type.EMPTY) .build(); } } 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);  }