@Test public void testOnRepositoryChange() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someKey: 'someValue'"; String anotherValue = "anotherKey: 'anotherValue'"; someProperties.setProperty(key, someValue); someSourceType = ConfigSourceType.LOCAL; Properties someYamlProperties = new Properties(); someYamlProperties.setProperty("someKey", "someValue"); Properties anotherYamlProperties = new Properties(); anotherYamlProperties.setProperty("anotherKey", "anotherValue"); when(configRepository.getConfig()).thenReturn(someProperties); when(configRepository.getSourceType()).thenReturn(someSourceType); when(yamlParser.yamlToProperties(someValue)).thenReturn(someYamlProperties); when(yamlParser.yamlToProperties(anotherValue)).thenReturn(anotherYamlProperties); YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository); assertEquals(someValue, configFile.getContent()); assertEquals(someSourceType, configFile.getSourceType()); assertSame(someYamlProperties, configFile.asProperties()); Properties anotherProperties = new Properties(); anotherProperties.setProperty(key, anotherValue); ConfigSourceType anotherSourceType = ConfigSourceType.REMOTE; when(configRepository.getSourceType()).thenReturn(anotherSourceType); configFile.onRepositoryChange(someNamespace, anotherProperties); assertEquals(anotherValue, configFile.getContent()); assertEquals(anotherSourceType, configFile.getSourceType()); assertSame(anotherYamlProperties, configFile.asProperties()); }
@Override public Properties asProperties() { if (cachedProperties == null) { transformToProperties(); } return cachedProperties; }
YamlConfigFile extends PlainTextConfigFile implements PropertiesCompatibleConfigFile { @Override public Properties asProperties() { if (cachedProperties == null) { transformToProperties(); } return cachedProperties; } }
YamlConfigFile extends PlainTextConfigFile implements PropertiesCompatibleConfigFile { @Override public Properties asProperties() { if (cachedProperties == null) { transformToProperties(); } return cachedProperties; } YamlConfigFile(String namespace, ConfigRepository configRepository); }
YamlConfigFile extends PlainTextConfigFile implements PropertiesCompatibleConfigFile { @Override public Properties asProperties() { if (cachedProperties == null) { transformToProperties(); } return cachedProperties; } YamlConfigFile(String namespace, ConfigRepository configRepository); @Override ConfigFileFormat getConfigFileFormat(); @Override Properties asProperties(); }
YamlConfigFile extends PlainTextConfigFile implements PropertiesCompatibleConfigFile { @Override public Properties asProperties() { if (cachedProperties == null) { transformToProperties(); } return cachedProperties; } YamlConfigFile(String namespace, ConfigRepository configRepository); @Override ConfigFileFormat getConfigFileFormat(); @Override Properties asProperties();  }