@Test
public void getEncryptionService_whenEncryptionServiceIsAlreadyInitialized() throws Exception {

  final EncryptionProviderFactory subject = new EncryptionProviderFactory(
    mock(EncryptionKeysConfiguration.class),
    mock(TimedRetry.class),
    mock(PasswordKeyProxyFactory.class)
  );
  when(provider.getProviderType()).thenReturn(ProviderType.INTERNAL);
  final InternalEncryptionService internal = (InternalEncryptionService) subject.getEncryptionService(provider);
  final InternalEncryptionService internalAgain = (InternalEncryptionService) subject.getEncryptionService(provider);
  assertThat(internal, sameInstance(internalAgain));
  assertThat(internal, instanceOf(PasswordEncryptionService.class));
}