### Question:
ConfigurationFactoryProvider { public static Configuration newConfiguration(Class<?> container) { ConfigurationFactory configurationFactory = getConfigurationFactory(container); Configuration configuration = configurationFactory.newConfiguration(container, new ConfigurationDefaults()); if (configuration.getConfigurationDefaults() != null && configuration.getConfigurationDefaults() != ConfigurationDefaults.class) { ConfigurationProperties configurationDefaults; try { configurationDefaults = ReflectionUtils.newInstance(configuration.getConfigurationDefaults()); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new ConfigurationException( "Can't initialize ConfigurationDefaults:" + configuration.getConfigurationDefaults(), e); } configuration = configurationFactory.newConfiguration(container, configurationDefaults); } return configuration; } private  ConfigurationFactoryProvider(); static ConfigurationFactory getConfigurationFactory(Class<?> container); static Configuration newConfiguration(Class<?> container);  }### Answer:
@Test public void testDefaultConfiguration() { Configuration configuration = ConfigurationFactoryProvider.newConfiguration(DummyContainer.class); assertThat(configuration).isExactlyInstanceOf(ComposedConfiguration.class); }
@Test public void testCustomConfiguration() { Configuration configuration = ConfigurationFactoryProvider.newConfiguration(CustomContainer.class); assertThat(configuration).isExactlyInstanceOf(ProgrammaticConfiguration.class); }
@Test public void testPrivateCustomConfiguration() { Configuration configuration = ConfigurationFactoryProvider.newConfiguration(PrivateDefaultsContainer.class); assertThat(configuration).isNotNull(); }
@Test(expected = ConfigurationException.class) public void testInvalidClassConfiguration() { ConfigurationFactoryProvider.newConfiguration(FailingContainer.class); }
@Test(expected = ConfigurationException.class) public void testInvalidConfigurationClassConfiguration() { ConfigurationFactoryProvider.newConfiguration(FailingConfigurationContainer.class); }
@Test public void testCustomConfigurationDefaults() { Configuration configuration = ConfigurationFactoryProvider.newConfiguration(CustomDefaultsContainer.class); assertThat(configuration.getBaseUrl()).isEqualTo("custom-base-url"); }