### Question:
ConnectionFactoryRegistry implements ConnectionFactoryLocator { public void addConnectionFactory(ConnectionFactory<?> connectionFactory) { if (connectionFactories.containsKey(connectionFactory.getProviderId())) { throw new IllegalArgumentException("A ConnectionFactory for provider '" + connectionFactory.getProviderId() + "' has already been registered"); } Class<?> apiType = GenericTypeResolver.resolveTypeArgument(connectionFactory.getClass(), ConnectionFactory.class); if (apiTypeIndex.containsKey(apiType)) { throw new IllegalArgumentException("A ConnectionFactory for API [" + apiType.getName() + "] has already been registered"); } connectionFactories.put(connectionFactory.getProviderId(), connectionFactory); apiTypeIndex.put(apiType, connectionFactory.getProviderId()); }  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(expected=IllegalArgumentException.class) public void addDuplicateProviderId() { connectionFactoryLocator.addConnectionFactory(new TestTwitterConnectionFactory()); }
@Test(expected=IllegalArgumentException.class) public void addDuplicateApiType() { connectionFactoryLocator.addConnectionFactory(new TestTwitter2ConnectionFactory()); }