@Test public void testWhenInvalidYamlContent() throws Exception { Properties someProperties = new Properties(); String key = ConfigConsts.CONFIG_FILE_CONTENT_KEY; String someInvalidContent = ","; someProperties.setProperty(key, someInvalidContent); someSourceType = ConfigSourceType.LOCAL; when(configRepository.getConfig()).thenReturn(someProperties); when(configRepository.getSourceType()).thenReturn(someSourceType); when(yamlParser.yamlToProperties(someInvalidContent)) .thenThrow(new RuntimeException("some exception")); YamlConfigFile configFile = new YamlConfigFile(someNamespace, configRepository); assertSame(someInvalidContent, configFile.getContent()); Throwable exceptionThrown = null; try { configFile.asProperties(); } catch (Throwable ex) { exceptionThrown = ex; } assertTrue(exceptionThrown instanceof ApolloConfigException); assertNotNull(exceptionThrown.getCause()); }
@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();  }