DefaultConfigFactory implements ConfigFactory { PropertiesCompatibleFileConfigRepository createPropertiesCompatibleFileConfigRepository(String namespace, ConfigFileFormat format) { String actualNamespaceName = trimNamespaceFormat(namespace, format); PropertiesCompatibleConfigFile configFile = (PropertiesCompatibleConfigFile) ConfigService .getConfigFile(actualNamespaceName, format); return new PropertiesCompatibleFileConfigRepository(configFile); } DefaultConfigFactory(); @Override Config create(String namespace); @Override ConfigFile createConfigFile(String namespace, ConfigFileFormat configFileFormat);  }
@Test public void testCreatePropertiesCompatibleFileConfigRepository() throws Exception { ConfigFileFormat somePropertiesCompatibleFormat = ConfigFileFormat.YML; String someNamespace = "someName" + "." + somePropertiesCompatibleFormat; Properties someProperties = new Properties(); String someKey = "someKey"; String someValue = "someValue"; someProperties.setProperty(someKey, someValue); PropertiesCompatibleFileConfigRepository someRepository = mock(PropertiesCompatibleFileConfigRepository.class); when(someRepository.getConfig()).thenReturn(someProperties); doReturn(someRepository).when(defaultConfigFactory) .createPropertiesCompatibleFileConfigRepository(someNamespace, somePropertiesCompatibleFormat); Config result = defaultConfigFactory.create(someNamespace); assertThat("DefaultConfigFactory should create DefaultConfig", result, is(instanceOf(DefaultConfig.class))); assertEquals(someValue, result.getProperty(someKey, null)); }