Skip to content

Commit

Permalink
Add unit-test demonstrating the problem from issue #18
Browse files Browse the repository at this point in the history
  • Loading branch information
tokee committed Mar 22, 2021
1 parent 1e4e35f commit 449acd7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/java/dk/kb/util/yaml/YAMLTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ public void testMultiConfig() throws IOException {
"The merged YAML should have the expected value for alias-using 'theServer'");
}

@Test
public void testMerge() throws IOException {
final String FIRST_ONLY = "upperA.subYAML.sub2Element";
assertTrue(YAML.resolveMultiConfig("yaml/overwrite-1.yaml").containsKey(FIRST_ONLY),
"Non-merged first file should contain element '" + FIRST_ONLY + "'");

YAML yaml = YAML.resolveMultiConfig("yaml/overwrite-1.yaml", "yaml/overwrite-2.yaml");
assertEquals("baz", yaml.getString("upperA.subElement"),
"Merged YAML should contain overwritten element 'upperA.subElement'");
assertEquals("bar", yaml.getString(FIRST_ONLY),
"Merged YAML should contain element '" + FIRST_ONLY + "' from file #1");
assertEquals(12, yaml.getInteger("upperC.subCElement"),
"Merged YAML should contain element 'upperC.subClement' from file #2");
}

@Test
public void testFailingMultiConfig() throws IOException {
Assertions.assertThrows(FileNotFoundException.class,
Expand Down

0 comments on commit 449acd7

Please sign in to comment.