diff --git a/test/src/test/atriasoft/exml/ExmlTestIntrospectionRecord.java b/test/src/test/atriasoft/exml/ExmlTestIntrospectionRecord.java new file mode 100644 index 0000000..0b4a174 --- /dev/null +++ b/test/src/test/atriasoft/exml/ExmlTestIntrospectionRecord.java @@ -0,0 +1,45 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2021, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ +package test.atriasoft.exml; + +import org.atriasoft.exml.Exml; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class ExmlTestIntrospectionRecord { + static final String NODE_NAME = "elem"; + @BeforeAll + public static void beforeClass() { + Log.warning("================================================================"); + } + public record TestRecord( + Integer valueA, + double valueB) { + public TestRecord(final Integer valueA, final double valueB) { + this.valueA = valueA; + this.valueB = valueB; + } + } + @Test + public void testModelRecord() { + TestRecord elem = new TestRecord(66, 18523.0); + StringBuilder builder = new StringBuilder(); + Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder)); + String dataTest = builder.toString(); + Log.warning("data generated: " + builder.toString()); + Assertions.assertEquals("\n" + + " 18523.0\n" + + "", dataTest); + + final TestRecord root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestRecord.class, ExmlTestIntrospectionObject.NODE_NAME)); + Assertions.assertEquals(66, root.valueA); + Assertions.assertEquals(18523.0f, root.valueB); + } + +} +