LoginActivity extends Activity { void onTokenReceived(@NonNull Uri uri) { try { Intent data = AuthUtils.parseTokenUriToIntent(uri); setResult(RESULT_OK, data); finish(); } catch (LoginAuthenticationException loginException) { onError(loginException.getAuthenticationError()); return; } }  @NonNull static Intent newIntent(
            @NonNull Context context,
            @NonNull SessionConfiguration sessionConfiguration,
            @NonNull ResponseType responseType); @NonNull static Intent newIntent(
            @NonNull Context context,
            @NonNull SessionConfiguration sessionConfiguration,
            @NonNull ResponseType responseType,
            boolean forceWebview); static Intent newResponseIntent(Context context, Uri responseUri);  }
@Test public void onTokenReceived_shouldReturnAccessTokenResult() { String tokenString = "accessToken1234"; String redirectUrl = REDIRECT_URI + "?access_token=accessToken1234&expires_in=" + 2592000 + "&scope=history&refresh_token=refreshToken1234&token_type=bearer"; ShadowActivity shadowActivity = shadowOf(loginActivity); loginActivity.onTokenReceived(Uri.parse(redirectUrl)); assertNotNull(shadowActivity.getResultIntent()); assertEquals(shadowActivity.getResultCode(), Activity.RESULT_OK); AccessToken resultAccessToken = AuthUtils.createAccessToken(shadowActivity.getResultIntent()); assertEquals(resultAccessToken.getExpiresIn(), 2592000); assertEquals(resultAccessToken.getToken(), tokenString); assertEquals(resultAccessToken.getScopes().size(), 1); assertTrue(resultAccessToken.getScopes().contains(Scope.HISTORY)); assertThat(shadowActivity.isFinishing()).isTrue(); }