@Test public void checkActionCode() throws InterruptedException { TestObserver<ActionCodeResult> authTestObserver = RxFirebaseAuth .checkActionCode(firebaseAuth, ANY_CODE) .test(); testOnSuccessListener.getValue().onSuccess(actionCodeResult); testOnCompleteListener.getValue().onComplete(actionCodeResultTask); verify(firebaseAuth).checkActionCode(eq(ANY_CODE)); authTestObserver.assertNoErrors() .assertValueCount(1) .assertValueSet(Collections.singletonList(actionCodeResult)) .assertComplete() .dispose(); }
/** * Checks that the code given is valid. This code will have been generated * by {@link FirebaseAuth#sendPasswordResetEmail(String)} or {@link com.google.firebase.auth.FirebaseUser#sendEmailVerification()} valid for a single use. * * @param firebaseAuth firebaseAuth instance. * @param code generated code by firebase. * @return a {@link Maybe} which emits when the action is completed. */ @NonNull public static Maybe<ActionCodeResult> checkActionCode(@NonNull final FirebaseAuth firebaseAuth, @NonNull final String code) { return Maybe.create(new MaybeOnSubscribe<ActionCodeResult>() { @Override public void subscribe(MaybeEmitter<ActionCodeResult> emitter) throws Exception { RxHandler.assignOnTask(emitter, firebaseAuth.checkActionCode(code)); } }); }
@Override public void subscribe(SingleEmitter<ActionCodeResult> emitter) { if (!emitter.isDisposed()) { instance.checkActionCode(code).addOnCompleteListener(GmsTaskListeners.listener(emitter)); } }
/** * @see FirebaseAuth#checkActionCode(String) */ @CheckResult @NonNull public static Single<ActionCodeResult> checkActionCode( @NonNull FirebaseAuth instance, @NonNull String code) { return Single.create(new CheckActionCodeOnSubscribe(instance, code)); }
@Test public void testCheckActionCode_NotSuccessful() { mockNotSuccessfulResultForTask(mockActionCodeResultTask, new IllegalStateException()); when(mockFirebaseAuth.checkActionCode("code")).thenReturn(mockActionCodeResultTask); TestObserver<ActionCodeResult> obs = TestObserver.create(); RxFirebaseAuth.checkActionCode(mockFirebaseAuth, "code").subscribe(obs); callOnComplete(mockActionCodeResultTask); obs.dispose(); // Ensure no more values are emitted after unsubscribe callOnComplete(mockActionCodeResultTask); obs.assertError(IllegalStateException.class); obs.assertNoValues(); }
@Override public Task<ActionCodeResult> checkActionCode(String code) { return mAuth.checkActionCode(code); }
Task<ActionCodeResult> checkActionCode(String code);