SmartReceiptsAuthenticationProvider extends AWSAbstractCognitoDeveloperIdentityProvider { @Override public String getIdentityId() { Logger.info(this, "Requesting Identity Id"); final Optional<Cognito> cognitoOptional = cognitoIdentityProvider.getCachedCognitoToken(); return cognitoOptional.isPresent() ? cognitoOptional.get().getIdentityId() : null; } SmartReceiptsAuthenticationProvider(@NonNull CognitoIdentityProvider cognitoIdentityProvider, @NonNull Regions regions); @Override String getProviderName(); @Override String refresh(); @Override String getIdentityId();  }
@Test public void getIdentityId() { assertEquals(IDENTITY_ID, authenticationProvider.getIdentityId()); }
@Test public void getNullIdentityId() { Mockito.when(cognitoIdentityProvider.getCachedCognitoToken()).thenReturn(Optional.absent()); assertEquals(null, authenticationProvider.getIdentityId()); }