GoogleAuthProvider extends AuthProvider { @Override public boolean authorize(int requestCode, int resultCode, @Nullable Intent intent) { return google.parseSignInResult(requestCode, resultCode, intent); } GoogleAuthProvider(@NonNull String serverClientId, @NonNull AuthenticationAPIClient client);  GoogleAuthProvider(@NonNull String connectionName, @NonNull String serverClientId, @NonNull AuthenticationAPIClient client); void setRequiredPermissions(@NonNull String[] androidPermissions); void rememberLastLogin(boolean rememberLastLogin); void setScopes(@NonNull Scope... scope); @Override boolean authorize(int requestCode, int resultCode, @Nullable Intent intent); @Override boolean authorize(@Nullable Intent intent); @Override String[] getRequiredAndroidPermissions(); @Override void stop(); @Override void clearSession();  }
@Test public void shouldParseAuthorization() throws Exception { Intent intent = mock(Intent.class); provider.start(activity, callback, PERMISSION_REQ_CODE, AUTH_REQ_CODE); provider.authorize(AUTH_REQ_CODE, Activity.RESULT_OK, intent); provider.authorize(AUTH_REQ_CODE, Activity.RESULT_CANCELED, intent); verify(google).parseSignInResult(AUTH_REQ_CODE, Activity.RESULT_OK, intent); verify(google).parseSignInResult(AUTH_REQ_CODE, Activity.RESULT_CANCELED, intent); }
@Test public void shouldReturnDelegatedParseResult() throws Exception { Intent intent = mock(Intent.class); provider.start(activity, callback, PERMISSION_REQ_CODE, AUTH_REQ_CODE); when(google.parseSignInResult(AUTH_REQ_CODE, Activity.RESULT_OK, intent)).thenReturn(true); when(google.parseSignInResult(999, Activity.RESULT_OK, intent)).thenReturn(false); assertThat(provider.authorize(AUTH_REQ_CODE, Activity.RESULT_OK, intent), is(true)); assertThat(provider.authorize(999, Activity.RESULT_OK, intent), is(false)); }
@Test public void shouldDoNothingWhenCalledFromNewIntent() throws Exception { assertThat(provider.authorize(null), is(false)); }