@Test
public void refreshCognitoTokenIsValid() {

    Mockito.when(identityManager.getMe()).thenReturn(Observable.just(meResponse));
    Mockito.when(user.getCognitoToken()).thenReturn(TOKEN);
    Mockito.when(user.getIdentityId()).thenReturn(IDENTITY_ID);
    Mockito.when(user.getCognitoTokenExpiresAt()).thenReturn(EXPIRES_AT);
    final TestObserver<Optional<Cognito>> testObserver = cognitoIdentityProvider.refreshCognitoToken().test();
    final Cognito cognito = new Cognito(TOKEN, IDENTITY_ID, EXPIRES_AT);
    Mockito.verify(localCognitoTokenStore).persist(null);
    Mockito.verify(localCognitoTokenStore).persist(cognito);
    testObserver.assertValue(Optional.of(cognito))
            .assertComplete()
            .assertNoErrors();
}