SmartReceiptsAuthenticationProvider extends AWSAbstractCognitoDeveloperIdentityProvider { @Override public String refresh() { Logger.info(this, "Refreshing Cognito Token"); setToken(null); final Cognito cognito = cognitoIdentityProvider.synchronouslyRefreshCognitoToken(); Logger.debug(this, "Refreshed cognito token is null? {}", cognito == null); final String identityId = cognito != null ? cognito.getIdentityId() : null; final String token = cognito != null ? cognito.getCognitoToken() : null; update(identityId, token); return token; } SmartReceiptsAuthenticationProvider(@NonNull CognitoIdentityProvider cognitoIdentityProvider, @NonNull Regions regions); @Override String getProviderName(); @Override String refresh(); @Override String getIdentityId();  }
@Test public void refresh() { assertEquals(TOKEN, authenticationProvider.refresh()); }
@Test public void refreshReturnsNullToken() { Mockito.when(cognitoIdentityProvider.synchronouslyRefreshCognitoToken()).thenReturn(null); assertEquals(null, authenticationProvider.refresh()); }