@Test public void testWhenConfigRepositoryHasErrorAndThenRecovered() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someValue = "someKey: 'someValue'"; someProperties.setProperty(key, someValue); someSourceType = ConfigSourceType.LOCAL; Properties someYamlProperties = new Properties(); someYamlProperties.setProperty("someKey", "someValue"); when(configRepository.getConfig()).thenThrow(new RuntimeException("someError")); when(configRepository.getSourceType()).thenReturn(someSourceType); when(yamlParser.yamlToProperties(someValue)).thenReturn(someYamlProperties); YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository); assertFalse(configFile.hasContent()); assertNull(configFile.getContent()); assertEquals(ConfigSourceType.NONE, configFile.getSourceType()); assertTrue(configFile.asProperties().isEmpty()); configFile.onRepositoryChange(someNamespace, someProperties); assertTrue(configFile.hasContent()); assertEquals(someValue, configFile.getContent()); assertEquals(someSourceType, configFile.getSourceType()); assertSame(someYamlProperties, 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();  }