when(managerFactory.createInstance(any(Broker.class), any(Map.class))).thenReturn(mock(PrincipalDatabaseAuthenticationManager.class));
when(loader.atLeastOneInstanceOf(AuthenticationManagerFactory.class)).thenReturn(Collections.singleton(managerFactory));
AuthenticationProviderFactory providerFactory = new AuthenticationProviderFactory(loader);
UUID randomUUID = UUID.randomUUID();
AuthenticationProvider provider = providerFactory.create(randomUUID, broker, new HashMap<String, Object>());
assertNotNull("Provider is not created", provider);
assertEquals("Unexpected ID", randomUUID, provider.getId());
}