diff --git a/pom.xml b/pom.xml index d4e1f78d..1230ab59 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ org.xmlunit - xmlunit-matchers + xmlunit-assertj3 2.10.0 test diff --git a/src/test/java/fr/insee/lunatic/conversion/data/JsonToXmlDataTest.java b/src/test/java/fr/insee/lunatic/conversion/data/JsonToXmlDataTest.java new file mode 100644 index 00000000..abf01ab6 --- /dev/null +++ b/src/test/java/fr/insee/lunatic/conversion/data/JsonToXmlDataTest.java @@ -0,0 +1,58 @@ +package fr.insee.lunatic.conversion.data; + +import org.junit.jupiter.api.Test; +import org.xmlunit.assertj3.XmlAssert; + +class JsonToXmlDataTest { + + /** + * Lunatic bug: in some cases pairwise data can be inconsistent. + * Yet the data conversion shouldn't fail so as not to break the data extraction of client collection tools + * that uses the json to xml conversion. + */ + @Test + void convertInconsistentPairwiseData() throws Exception { + // Given + String jsonInconsistentData = """ + { + "COLLECTED": { + "LIENS_MISSING": { + "COLLECTED": [ + null, + [null, null] + ] + } + }, + "CALCULATED": {}, + "EXTERNAL": { + "FOO_EXTERNAL": "some value" + } + }"""; + // When + JSONLunaticDataToXML converter = new JSONLunaticDataToXML(); + String result = converter.transform(jsonInconsistentData); + // Then + String expected = """ + + + + + + + + + + + + + + + + some value + + + """; + XmlAssert.assertThat(expected).and(result).ignoreWhitespace().areIdentical(); + } + +}