From 34b4679af1cb4e554cdc0fb827784e113afad228 Mon Sep 17 00:00:00 2001 From: amihaiemil Date: Thu, 15 Aug 2024 16:12:27 +0300 Subject: [PATCH] test --- .../eoyaml/YamlMappingCommentsPrintTest.java | 22 +++++++++++++++++-- src/test/resources/commentedMapping.yml | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/amihaiemil/eoyaml/YamlMappingCommentsPrintTest.java b/src/test/java/com/amihaiemil/eoyaml/YamlMappingCommentsPrintTest.java index 07bffdfb..a63e047d 100644 --- a/src/test/java/com/amihaiemil/eoyaml/YamlMappingCommentsPrintTest.java +++ b/src/test/java/com/amihaiemil/eoyaml/YamlMappingCommentsPrintTest.java @@ -68,7 +68,7 @@ public void printsBuiltYamlMappingWithComments() throws Exception { "name", Yaml.createYamlScalarBuilder() .addLine("eo-yaml") - .buildPlainScalar("name of the project") + .buildPlainScalar("Name", "Elegant objects YAML") ).build("Comment of the whole document"); System.out.println(commented); MatcherAssert.assertThat( @@ -112,13 +112,31 @@ public void readsComments() throws Exception { read.comment().value(), Matchers.equalTo("Comment of the whole document") ); + MatcherAssert.assertThat( + read.keys().stream() + .filter(k -> k.asScalar().value().equals("developers")) + .findFirst() + .get() + .comment().value(), + Matchers.equalTo("all the contributors here") + ); MatcherAssert.assertThat( read.yamlSequence("developers").comment().value(), Matchers.equalTo("all the contributors here") ); + MatcherAssert.assertThat( + read.keys().stream() + .filter(k -> k.asScalar().value().equals("name")) + .findFirst() + .get() + .comment().value(), + Matchers.equalTo("Name") + ); MatcherAssert.assertThat( read.value("name").comment().value(), - Matchers.equalTo("name of the project") + Matchers.equalTo( + "Name" + System.lineSeparator() + "Elegant objects YAML" + ) ); } diff --git a/src/test/resources/commentedMapping.yml b/src/test/resources/commentedMapping.yml index 5528bc77..9208de02 100644 --- a/src/test/resources/commentedMapping.yml +++ b/src/test/resources/commentedMapping.yml @@ -6,4 +6,5 @@ developers: - rultor - salikjan - sherif -name: eo-yaml # name of the project \ No newline at end of file +# Name +name: eo-yaml # Elegant objects YAML \ No newline at end of file