@Test public void signOut_ok() { GoogleAuth googleAuth = new GoogleAuth(); Task task = Mockito.mock(Task.class); final Task task2 = Mockito.mock(Task.class); Mockito.when(task2.isSuccessful()).thenReturn(true); Mockito.when(googleSignInClient.signOut()).thenReturn(task); Mockito.when(task.addOnCompleteListener(Mockito.any(OnCompleteListener.class))).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { ((OnCompleteListener) invocation.getArgument(0)).onComplete(task2); return null; } }); FuturePromise promise = (FuturePromise) spy(googleAuth.signOut().subscribe()); PowerMockito.verifyStatic(GoogleSignIn.class, VerificationModeFactory.times(1)); GoogleSignIn.getClient((Activity) Mockito.refEq(Gdx.app), Mockito.any(GoogleSignInOptions.class)); Mockito.verify(googleSignInClient, VerificationModeFactory.times(1)).signOut(); }
@Override public Promise<Void> signOut() { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> voidFuturePromise) { GoogleSignInClient client = GoogleSignIn.getClient((AndroidApplication) Gdx.app, GoogleSignInOptionsFactory.factory()); client.signOut().addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { voidFuturePromise.doComplete(null); } else { voidFuturePromise.doFail(task.getException()); } } }); } }); }
GoogleAuth implements GoogleAuthDistribution { @Override public Promise<Void> signOut() { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> voidFuturePromise) { GoogleSignInClient client = GoogleSignIn.getClient((AndroidApplication) Gdx.app, GoogleSignInOptionsFactory.factory()); client.signOut().addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { voidFuturePromise.doComplete(null); } else { voidFuturePromise.doFail(task.getException()); } } }); } }); } }
GoogleAuth implements GoogleAuthDistribution { @Override public Promise<Void> signOut() { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> voidFuturePromise) { GoogleSignInClient client = GoogleSignIn.getClient((AndroidApplication) Gdx.app, GoogleSignInOptionsFactory.factory()); client.signOut().addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { voidFuturePromise.doComplete(null); } else { voidFuturePromise.doFail(task.getException()); } } }); } }); }  }
GoogleAuth implements GoogleAuthDistribution { @Override public Promise<Void> signOut() { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> voidFuturePromise) { GoogleSignInClient client = GoogleSignIn.getClient((AndroidApplication) Gdx.app, GoogleSignInOptionsFactory.factory()); client.signOut().addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { voidFuturePromise.doComplete(null); } else { voidFuturePromise.doFail(task.getException()); } } }); } }); }  @Override Promise<GdxFirebaseUser> signIn(); @Override Promise<Void> signOut(); @Override Promise<Void> revokeAccess(); }
GoogleAuth implements GoogleAuthDistribution { @Override public Promise<Void> signOut() { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> voidFuturePromise) { GoogleSignInClient client = GoogleSignIn.getClient((AndroidApplication) Gdx.app, GoogleSignInOptionsFactory.factory()); client.signOut().addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { voidFuturePromise.doComplete(null); } else { voidFuturePromise.doFail(task.getException()); } } }); } }); }  @Override Promise<GdxFirebaseUser> signIn(); @Override Promise<Void> signOut(); @Override Promise<Void> revokeAccess();  }