FacebookAuthProvider extends AuthProvider { @Override public boolean authorize(int requestCode, int resultCode, @Nullable Intent intent) { return facebook.finishLogin(requestCode, resultCode, intent); } FacebookAuthProvider(String connectionName, AuthenticationAPIClient auth0);   FacebookAuthProvider(String connectionName, AuthenticationAPIClient auth0, FacebookApi facebook);  FacebookAuthProvider(@NonNull AuthenticationAPIClient auth0); void setPermissions(@NonNull Collection<String> permissions); void rememberLastLogin(boolean rememberLastLogin); @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 shouldReturnDelegatedParseResult() throws Exception { provider.start(activity, callback, PERMISSION_REQ_CODE, AUTH_REQ_CODE); when(apiHelper.finishLogin(AUTH_REQ_CODE, Activity.RESULT_OK, intent)).thenReturn(true); when(apiHelper.finishLogin(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)); }
@Test public void shouldParseAuthorization() throws Exception { 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(apiHelper).finishLogin(AUTH_REQ_CODE, Activity.RESULT_OK, intent); verify(apiHelper).finishLogin(AUTH_REQ_CODE, Activity.RESULT_CANCELED, intent); }