From ad5144d485992216227fb340e2549a0fc8b94997 Mon Sep 17 00:00:00 2001 From: amihaiemil Date: Wed, 13 Nov 2024 13:48:33 +0200 Subject: [PATCH] #633 added unit test --- .../eoyaml/ReflectedYamlMappingTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/test/java/com/amihaiemil/eoyaml/ReflectedYamlMappingTest.java b/src/test/java/com/amihaiemil/eoyaml/ReflectedYamlMappingTest.java index 0a089b14..506efc61 100644 --- a/src/test/java/com/amihaiemil/eoyaml/ReflectedYamlMappingTest.java +++ b/src/test/java/com/amihaiemil/eoyaml/ReflectedYamlMappingTest.java @@ -144,6 +144,34 @@ public void reflectsValues() { ); } + /** + * Unit test for Issue #633. + */ + @Test + public void reflectsEntries() { + final Entries entries = new Entries(); + entries.entries.add("Test1"); + entries.entries.add("Test2"); + entries.entries.add("Test3"); + final YamlMapping mapping = Yaml.createYamlDump(entries).dumpMapping(); + MatcherAssert.assertThat( + mapping.yamlSequence("entries").size(), + Matchers.is(3) + ); + MatcherAssert.assertThat( + mapping.yamlSequence("entries").string(0), + Matchers.equalTo("Test1") + ); + MatcherAssert.assertThat( + mapping.yamlSequence("entries").string(1), + Matchers.equalTo("Test2") + ); + MatcherAssert.assertThat( + mapping.yamlSequence("entries").string(2), + Matchers.equalTo("Test3") + ); + } + /** * Prints the YAML correctly. */ @@ -267,4 +295,25 @@ public void setClasses(List classes) { } } + + /** + * Simple pojo for test. + * @checkstyle JavadocVariable (100 lines) + * @checkstyle JavadocMethod (100 lines) + * @checkstyle HiddenField (100 lines) + * @checkstyle ParameterNumber (100 lines) + * @checkstyle FinalParameters (100 lines) + */ + static final class Entries { + private List entries = new ArrayList<>(); + + public List getEntries() { + return entries; + } + + public void setEntries(List entries) { + this.entries = entries; + } + } + }