### Question:
RestrictedComponentContainer extends AbstractComponentContainer { @Override public <T> Provider<T> getProvider(Class<T> anInterface) { if (!allowedProviderInterfaces.contains(anInterface)) { throw new IllegalArgumentException( String.format( "Attempting to request an undeclared dependency Provider<%s>.", anInterface)); } return delegateContainer.getProvider(anInterface); } RestrictedComponentContainer(Component<?> component, ComponentContainer container); @Override T get(Class<T> anInterface); @Override Provider<T> getProvider(Class<T> anInterface); @Override Provider<Set<T>> setOfProvider(Class<T> anInterface); @Override Set<T> setOf(Class<T> anInterface);  }### Answer:
@Test public void getProvider_withNotAllowedClass_shouldThrow() { try { container.getProvider(List.class); fail("Expected exception not thrown."); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()).contains("java.util.List"); } }
@Test public void getProvider_withDirectClass_shouldThrow() { try { container.getProvider(Float.class); fail("Expected exception not thrown."); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()).contains("java.lang.Float"); } }