### Question:
ConnectionFactoryRegistry implements ConnectionFactoryLocator { public ConnectionFactory<?> getConnectionFactory(String providerId) { ConnectionFactory<?> connectionFactory = connectionFactories.get(providerId); if (connectionFactory == null) { throw new IllegalArgumentException("No connection factory for service provider '" + providerId + "' is registered"); } return connectionFactory; }  void addConnectionFactory(ConnectionFactory<?> connectionFactory); void setConnectionFactories(List<ConnectionFactory<?>> connectionFactories); ConnectionFactory<?> getConnectionFactory(String providerId); @SuppressWarnings("unchecked") ConnectionFactory<A> getConnectionFactory(Class<A> apiType); Set<String> registeredProviderIds();  }### Answer:
@Test public void getConnectionFactoryByProviderId() { ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory("twitter"); assertSame(twitterConnectionFactory, connectionFactory); assertEquals("twitter", connectionFactory.getProviderId()); }
@Test public void getConnectionFactoryByApi() { ConnectionFactory<TestTwitterApi> connectionFactory = connectionFactoryLocator.getConnectionFactory(TestTwitterApi.class); assertSame(twitterConnectionFactory, connectionFactory); assertEquals("twitter", connectionFactory.getProviderId()); }