@SuppressWarnings("unchecked")
public void testCreateNonPasswordCredentialManagingAuthenticationProviderWhenAnotherOneAlreadyExist()
{
Broker broker = mock(Broker.class);
AuthenticationProvider anotherProvider = mock(AuthenticationProvider.class);
when(broker.getAuthenticationProviders()).thenReturn(Collections.singleton(anotherProvider));
QpidServiceLoader<AuthenticationManagerFactory> loader = mock(QpidServiceLoader.class);
AuthenticationManagerFactory managerFactory = mock(AuthenticationManagerFactory.class);
when(managerFactory.createInstance(any(Map.class))).thenReturn(mock(AuthenticationManager.class));
when(loader.atLeastOneInstanceOf(AuthenticationManagerFactory.class)).thenReturn(Collections.singleton(managerFactory));
AuthenticationProviderFactory providerFactory = new AuthenticationProviderFactory(loader);
UUID id = UUID.randomUUID();
AuthenticationProvider provider = providerFactory.create(id, broker, new HashMap<String, Object>());
assertNotNull("Provider is not created", provider);
assertEquals("Unexpected ID", id, provider.getId());
}