@Test public void shouldComplainAboutUnregisteredProviders() { final DataManager dataManager = mock(DataManager.class); final CredentialProviderRegistry registry = new CredentialProviderRegistry(dataManager); assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> registry.providerWithId("unregistered")) .withMessage("Unable to find connector with id: unregistered"); }
@Override public CredentialProvider providerWithId(final String providerId) { final Connector connector = dataManager.fetch(Connector.class, providerId); if (connector == null) { throw new IllegalArgumentException("Unable to find connector with id: " + providerId); } final String providerToUse = determineProviderFrom(connector); final CredentialProviderFactory credentialProviderFactory = credentialProviderFactories.get(providerToUse); if (credentialProviderFactory == null) { throw new IllegalArgumentException("Unable to locate credential provider factory with id: " + providerId); } final SocialProperties socialProperties = createSocialProperties(providerToUse, connector); final CredentialProvider providerWithId = credentialProviderFactory.create(socialProperties); if (providerWithId == null) { throw new IllegalArgumentException("Unable to locate credential provider with id: " + providerId); } return providerWithId; }
CredentialProviderRegistry implements CredentialProviderLocator { @Override public CredentialProvider providerWithId(final String providerId) { final Connector connector = dataManager.fetch(Connector.class, providerId); if (connector == null) { throw new IllegalArgumentException("Unable to find connector with id: " + providerId); } final String providerToUse = determineProviderFrom(connector); final CredentialProviderFactory credentialProviderFactory = credentialProviderFactories.get(providerToUse); if (credentialProviderFactory == null) { throw new IllegalArgumentException("Unable to locate credential provider factory with id: " + providerId); } final SocialProperties socialProperties = createSocialProperties(providerToUse, connector); final CredentialProvider providerWithId = credentialProviderFactory.create(socialProperties); if (providerWithId == null) { throw new IllegalArgumentException("Unable to locate credential provider with id: " + providerId); } return providerWithId; } }
CredentialProviderRegistry implements CredentialProviderLocator { @Override public CredentialProvider providerWithId(final String providerId) { final Connector connector = dataManager.fetch(Connector.class, providerId); if (connector == null) { throw new IllegalArgumentException("Unable to find connector with id: " + providerId); } final String providerToUse = determineProviderFrom(connector); final CredentialProviderFactory credentialProviderFactory = credentialProviderFactories.get(providerToUse); if (credentialProviderFactory == null) { throw new IllegalArgumentException("Unable to locate credential provider factory with id: " + providerId); } final SocialProperties socialProperties = createSocialProperties(providerToUse, connector); final CredentialProvider providerWithId = credentialProviderFactory.create(socialProperties); if (providerWithId == null) { throw new IllegalArgumentException("Unable to locate credential provider with id: " + providerId); } return providerWithId; } CredentialProviderRegistry(final DataManager dataManager); }
CredentialProviderRegistry implements CredentialProviderLocator { @Override public CredentialProvider providerWithId(final String providerId) { final Connector connector = dataManager.fetch(Connector.class, providerId); if (connector == null) { throw new IllegalArgumentException("Unable to find connector with id: " + providerId); } final String providerToUse = determineProviderFrom(connector); final CredentialProviderFactory credentialProviderFactory = credentialProviderFactories.get(providerToUse); if (credentialProviderFactory == null) { throw new IllegalArgumentException("Unable to locate credential provider factory with id: " + providerId); } final SocialProperties socialProperties = createSocialProperties(providerToUse, connector); final CredentialProvider providerWithId = credentialProviderFactory.create(socialProperties); if (providerWithId == null) { throw new IllegalArgumentException("Unable to locate credential provider with id: " + providerId); } return providerWithId; } CredentialProviderRegistry(final DataManager dataManager); @Override CredentialProvider providerWithId(final String providerId); }
CredentialProviderRegistry implements CredentialProviderLocator { @Override public CredentialProvider providerWithId(final String providerId) { final Connector connector = dataManager.fetch(Connector.class, providerId); if (connector == null) { throw new IllegalArgumentException("Unable to find connector with id: " + providerId); } final String providerToUse = determineProviderFrom(connector); final CredentialProviderFactory credentialProviderFactory = credentialProviderFactories.get(providerToUse); if (credentialProviderFactory == null) { throw new IllegalArgumentException("Unable to locate credential provider factory with id: " + providerId); } final SocialProperties socialProperties = createSocialProperties(providerToUse, connector); final CredentialProvider providerWithId = credentialProviderFactory.create(socialProperties); if (providerWithId == null) { throw new IllegalArgumentException("Unable to locate credential provider with id: " + providerId); } return providerWithId; } CredentialProviderRegistry(final DataManager dataManager); @Override CredentialProvider providerWithId(final String providerId);  }