From 54617510af2e7055c28196a20e281f26500e3a29 Mon Sep 17 00:00:00 2001 From: JonasG Date: Mon, 4 Mar 2024 10:56:44 +0100 Subject: [PATCH] doc: add namespace to example snippet Add test to support this. --- README.md | 34 +++++++++---------- .../GeneralDeserializationTest.java | 27 +++++++++++++++ 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 01146a3..95c7b8e 100644 --- a/README.md +++ b/README.md @@ -60,23 +60,23 @@ public class Location { ```java String document = """ - - - New York - USA - - - - 75 - - - - 60 - % - - Sunny - - """; + + + New York + USA + + + + 75 + + + + 60 + % + + Sunny + + """; var xjx = new XjxSerdes(); diff --git a/xjx-serdes/src/test/java/io/jonasg/xjx/serdes/deserialize/GeneralDeserializationTest.java b/xjx-serdes/src/test/java/io/jonasg/xjx/serdes/deserialize/GeneralDeserializationTest.java index e260233..794cc9b 100644 --- a/xjx-serdes/src/test/java/io/jonasg/xjx/serdes/deserialize/GeneralDeserializationTest.java +++ b/xjx-serdes/src/test/java/io/jonasg/xjx/serdes/deserialize/GeneralDeserializationTest.java @@ -239,4 +239,31 @@ static class AbsoluteRootMappingHolder { @Tag(path = "/DataTypes/Double") Double Double; } + + @Test + void namespaceSupport() { + // given + String data = """ + + + 5.7 + TableB + + """; + + // when + var holder = new XjxSerdes().read(data, NamespaceHolder.class); + + // then + assertThat(holder.tableA).isEqualTo(5.7D); + assertThat(holder.tableB).isEqualTo("TableB"); + } + + static class NamespaceHolder { + @Tag(path = "/Tables/TableA") + Double tableA; + + @Tag(path = "/Tables/TableB") + String tableB; + } }