/** * Construct configuration from raw yaml string. * * @param yaml string * @throws Exception */ public YamlConfiguration(String yaml) throws IOException { this(new YamlString(yaml)); }
/** * New instance. * * @throws Exception */ public YamlConfiguration() throws IOException { this(new YamlString("")); }
/** * New instance. * * @throws Exception */ public YamlConfiguration() throws IOException { this(new YamlString("")); }
/** * Construct configuration from raw yaml string. * * @param yaml string * @throws Exception */ public YamlConfiguration(String yaml) throws IOException { this(new YamlString(yaml)); }
/** * Construct configuration from raw yaml string. * * @param clazz * @param resourcePath * @throws Exception */ public YamlConfiguration(InputStream inputStream) throws IOException { this(new YamlString(IOUtils.toString(inputStream, Charset.defaultCharset()))); }
/** * Construct configuration from raw yaml string. * * @param clazz * @param resourcePath * @throws Exception */ public YamlConfiguration(InputStream inputStream) throws IOException { this(new YamlString(IOUtils.toString(inputStream, Charset.defaultCharset()))); }
return new YamlString(""); } else if (yamls.size() == 1) { return yamls.get(0);
String source = null; if (!Strings.isNullOrEmpty(config)) { yaml = new YamlString(config); source = "string"; } else if (!Strings.isNullOrEmpty(file)) {
String source = null; if (!Strings.isNullOrEmpty(config)) { yaml = new YamlString(config); source = "string"; } else if (!Strings.isNullOrEmpty(file)) {
@Test public void testNoMergeRequired() throws IOException { String yaml1 = "test1: value1"; String yaml2 = "test2: value2"; MergedYaml mergedYaml = new MergedYaml(ImmutableList.of(new YamlString(yaml1), new YamlString(yaml2))); Object dataTree = mergedYaml.dataTree(); assertTrue(dataTree instanceof Map); Map<String, Object> map = (Map) dataTree; assertTrue(map.containsKey("test1")); assertTrue(map.containsKey("test2")); assertEquals("value1", map.get("test1")); assertEquals("value2", map.get("test2")); }
@Test public void testSimpleMergeRequired() throws IOException { String yaml1 = "test: value1"; String yaml2 = "test: \n- value2\n- value3"; MergedYaml mergedYaml = new MergedYaml(ImmutableList.of(new YamlString(yaml1), new YamlString(yaml2))); Object dataTree = mergedYaml.dataTree(); assertTrue(dataTree instanceof Map); Map<String, Object> map = (Map) dataTree; assertTrue(map.containsKey("test")); ; assertTrue(map.get("test") instanceof List); List<Object> value = (List<Object>) map.get("test"); assertTrue(value.contains("value1")); assertTrue(value.contains("value2")); assertTrue(value.contains("value3")); }