AuthProviderRegistry implements AuthProviderFactory { public static void register(AuthProviderFactory factory) { instance.authProviders.putAll(factory.getAuthProviders()); }  static AuthProviderFactory getAuthProviderFactory(); static void register(AuthProviderFactory factory); static void register(String name, AuthProvider authProvider); static void clearRegistry(); @Override AuthProvider getAuthProviderByName(String name); @Override Map<String, AuthProvider> getAuthProviders();  }
@Test public void testRegister() { AuthProviderRegistry.register("apiKey", apiKeyAllAuthProvider); AuthProviderRegistry.register("dummy", apiKeyDummyAuthProvider); Assert.assertEquals(2, AuthProviderRegistry.getAuthProviderFactory().getAuthProviders().size()); Assert.assertEquals(apiKeyAllAuthProvider, AuthProviderRegistry.getAuthProviderFactory().getAuthProviderByName("apiKey")); AuthProviderRegistry.clearRegistry(); Assert.assertEquals(0, AuthProviderRegistry.getAuthProviderFactory().getAuthProviders().size()); TestAuthProviderFactory anotherFactory = new TestAuthProviderFactory(); anotherFactory.register("apiKey", apiKeyAllAuthProvider); anotherFactory.register("dummy", apiKeyDummyAuthProvider); AuthProviderRegistry.register(anotherFactory); Assert.assertEquals(2, AuthProviderRegistry.getAuthProviderFactory().getAuthProviders().size()); Assert.assertEquals(apiKeyAllAuthProvider, AuthProviderRegistry.getAuthProviderFactory().getAuthProviderByName("apiKey")); }