@Test public void synchronouslyRefreshCognitoTokenReturnsNullUserResponse() { Mockito.when(meResponse.getUser()).thenReturn(null); Mockito.when(identityManager.getMe()).thenReturn(Observable.just(meResponse)); assertEquals(null, cognitoIdentityProvider.synchronouslyRefreshCognitoToken()); }
@Nullable public Cognito synchronouslyRefreshCognitoToken() { try { return refreshCognitoToken() .onErrorReturn(throwable -> Optional.absent()) .blockingGet().get(); } catch (Exception e) { return null; } }
CognitoIdentityProvider { @Nullable public Cognito synchronouslyRefreshCognitoToken() { try { return refreshCognitoToken() .onErrorReturn(throwable -> Optional.absent()) .blockingGet().get(); } catch (Exception e) { return null; } } }
CognitoIdentityProvider { @Nullable public Cognito synchronouslyRefreshCognitoToken() { try { return refreshCognitoToken() .onErrorReturn(throwable -> Optional.absent()) .blockingGet().get(); } catch (Exception e) { return null; } } @Inject  CognitoIdentityProvider(@NonNull IdentityManager identityManager,
                                   @NonNull LocalCognitoTokenStore localCognitoTokenStore); }
CognitoIdentityProvider { @Nullable public Cognito synchronouslyRefreshCognitoToken() { try { return refreshCognitoToken() .onErrorReturn(throwable -> Optional.absent()) .blockingGet().get(); } catch (Exception e) { return null; } } @Inject  CognitoIdentityProvider(@NonNull IdentityManager identityManager,
                                   @NonNull LocalCognitoTokenStore localCognitoTokenStore); @NonNull Single<Optional<Cognito>> prefetchCognitoTokenIfNeeded(); @NonNull Single<Optional<Cognito>> refreshCognitoToken(); @Nullable Cognito synchronouslyRefreshCognitoToken(); @NonNull Optional<Cognito> getCachedCognitoToken(); }
CognitoIdentityProvider { @Nullable public Cognito synchronouslyRefreshCognitoToken() { try { return refreshCognitoToken() .onErrorReturn(throwable -> Optional.absent()) .blockingGet().get(); } catch (Exception e) { return null; } } @Inject  CognitoIdentityProvider(@NonNull IdentityManager identityManager,
                                   @NonNull LocalCognitoTokenStore localCognitoTokenStore); @NonNull Single<Optional<Cognito>> prefetchCognitoTokenIfNeeded(); @NonNull Single<Optional<Cognito>> refreshCognitoToken(); @Nullable Cognito synchronouslyRefreshCognitoToken(); @NonNull Optional<Cognito> getCachedCognitoToken();  }