@Test public void accept_fail() { Mockito.when(task.isSuccessful()).thenReturn(false); FuturePromise promise = Mockito.spy(FuturePromise.empty()); promise.then(Mockito.mock(Consumer.class)).silentFail(); AuthPromiseConsumer authPromiseConsumer = new AuthPromiseConsumer(task); authPromiseConsumer.accept(promise); Mockito.verify(promise, VerificationModeFactory.times(1)).doFail(Mockito.nullable(String.class), Mockito.nullable(Exception.class)); }
@Override public void accept(final FuturePromise<GdxFirebaseUser> promise) { if (task != null) { task.addOnCompleteListener(new OnCompleteListener<T>() { @Override public void onComplete(@NonNull Task<T> task) { if (task.isSuccessful()) { promise.doComplete(GdxFIRAuth.instance().getCurrentUser()); } else { promise.doFail(task.getException() != null ? task.getException().getLocalizedMessage() : "Authorization fail", task.getException()); } } }); } }
AuthPromiseConsumer implements Consumer<FuturePromise<GdxFirebaseUser>> { @Override public void accept(final FuturePromise<GdxFirebaseUser> promise) { if (task != null) { task.addOnCompleteListener(new OnCompleteListener<T>() { @Override public void onComplete(@NonNull Task<T> task) { if (task.isSuccessful()) { promise.doComplete(GdxFIRAuth.instance().getCurrentUser()); } else { promise.doFail(task.getException() != null ? task.getException().getLocalizedMessage() : "Authorization fail", task.getException()); } } }); } } }
AuthPromiseConsumer implements Consumer<FuturePromise<GdxFirebaseUser>> { @Override public void accept(final FuturePromise<GdxFirebaseUser> promise) { if (task != null) { task.addOnCompleteListener(new OnCompleteListener<T>() { @Override public void onComplete(@NonNull Task<T> task) { if (task.isSuccessful()) { promise.doComplete(GdxFIRAuth.instance().getCurrentUser()); } else { promise.doFail(task.getException() != null ? task.getException().getLocalizedMessage() : "Authorization fail", task.getException()); } } }); } } AuthPromiseConsumer(Task<T> task); }
AuthPromiseConsumer implements Consumer<FuturePromise<GdxFirebaseUser>> { @Override public void accept(final FuturePromise<GdxFirebaseUser> promise) { if (task != null) { task.addOnCompleteListener(new OnCompleteListener<T>() { @Override public void onComplete(@NonNull Task<T> task) { if (task.isSuccessful()) { promise.doComplete(GdxFIRAuth.instance().getCurrentUser()); } else { promise.doFail(task.getException() != null ? task.getException().getLocalizedMessage() : "Authorization fail", task.getException()); } } }); } } AuthPromiseConsumer(Task<T> task); @Override void accept(final FuturePromise<GdxFirebaseUser> promise); }
AuthPromiseConsumer implements Consumer<FuturePromise<GdxFirebaseUser>> { @Override public void accept(final FuturePromise<GdxFirebaseUser> promise) { if (task != null) { task.addOnCompleteListener(new OnCompleteListener<T>() { @Override public void onComplete(@NonNull Task<T> task) { if (task.isSuccessful()) { promise.doComplete(GdxFIRAuth.instance().getCurrentUser()); } else { promise.doFail(task.getException() != null ? task.getException().getLocalizedMessage() : "Authorization fail", task.getException()); } } }); } } AuthPromiseConsumer(Task<T> task); @Override void accept(final FuturePromise<GdxFirebaseUser> promise);  }