diff --git a/src/test/java/fr/insee/lunatic/conversion/XMLLunaticFlatToJSONLunaticFlatTranslatorTest.java b/src/test/java/fr/insee/lunatic/conversion/XMLLunaticFlatToJSONLunaticFlatTranslatorTest.java new file mode 100644 index 00000000..6b322213 --- /dev/null +++ b/src/test/java/fr/insee/lunatic/conversion/XMLLunaticFlatToJSONLunaticFlatTranslatorTest.java @@ -0,0 +1,24 @@ +package fr.insee.lunatic.conversion; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class XMLLunaticFlatToJSONLunaticFlatTranslatorTest { + + @Test + void convertQuestionnaireWithSuggester_nonNullOutput() throws Exception { + // Given (using a xml hierarchical as input and supposing that xml h et xml flat translator works fine) + XMLLunaticToXMLLunaticFlatTranslator xmlToXmlFlatTranslator = new XMLLunaticToXMLLunaticFlatTranslator(); + String xmlFlat = xmlToXmlFlatTranslator.generate(this.getClass().getClassLoader().getResourceAsStream( + "conversion/questionnaire-suggester-xml-h.xml")); + + // When + XMLLunaticFlatToJSONLunaticFlatTranslator xmlFlatToJsonFlatTranslator = new XMLLunaticFlatToJSONLunaticFlatTranslator(); + xmlFlatToJsonFlatTranslator.translate(xmlFlat); + + // Then + assertNotNull(xmlFlat); + } + +} diff --git a/src/test/java/fr/insee/lunatic/conversion/XMLLunaticToJSONLunaticTranslatorTest.java b/src/test/java/fr/insee/lunatic/conversion/XMLLunaticToJSONLunaticTranslatorTest.java new file mode 100644 index 00000000..d3222f59 --- /dev/null +++ b/src/test/java/fr/insee/lunatic/conversion/XMLLunaticToJSONLunaticTranslatorTest.java @@ -0,0 +1,25 @@ +package fr.insee.lunatic.conversion; + +import org.junit.jupiter.api.Test; + +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class XMLLunaticToJSONLunaticTranslatorTest { + + @Test + void convertQuestionnaireWithSuggester_nonNullOutput() throws Exception { + // Given + URL resource = this.getClass().getClassLoader().getResource("conversion/questionnaire-suggester-xml-h.xml"); + assert resource != null; + // When + XMLLunaticToJSONLunaticTranslator xmlToJsonFlatTranslator = new XMLLunaticToJSONLunaticTranslator(); + String result = xmlToJsonFlatTranslator.translate(Files.readString(Path.of(resource.toURI()))); + // Then + assertNotNull(result); + } + +} diff --git a/src/test/java/fr/insee/lunatic/conversion/XMLLunaticToXMLLunaticFlatTranslatorTest.java b/src/test/java/fr/insee/lunatic/conversion/XMLLunaticToXMLLunaticFlatTranslatorTest.java new file mode 100644 index 00000000..a55dab95 --- /dev/null +++ b/src/test/java/fr/insee/lunatic/conversion/XMLLunaticToXMLLunaticFlatTranslatorTest.java @@ -0,0 +1,19 @@ +package fr.insee.lunatic.conversion; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class XMLLunaticToXMLLunaticFlatTranslatorTest { + + @Test + void convertQuestionnaireWithSuggester_nonNullOutput() throws Exception { + // Given + When + XMLLunaticToXMLLunaticFlatTranslator xmlToXmlFlatTranslator = new XMLLunaticToXMLLunaticFlatTranslator(); + String result = xmlToXmlFlatTranslator.generate(this.getClass().getClassLoader().getResourceAsStream( + "conversion/questionnaire-suggester-xml-h.xml")); + // Then + assertNotNull(result); + } + +} diff --git a/src/test/resources/conversion/questionnaire-suggester-xml-h.xml b/src/test/resources/conversion/questionnaire-suggester-xml-h.xml new file mode 100644 index 00000000..5c09201f --- /dev/null +++ b/src/test/resources/conversion/questionnaire-suggester-xml-h.xml @@ -0,0 +1,254 @@ + + + + + + + true + VTL + + + + + + + + + + true + VTL + + + + + + + QCU + + 1 + + + + 0 + + + + + + + + true + VTL + + + + + + + SUGGCOMM + + + + + in-error + + true + VTL + + + + + + + INERROR + + + + + + + true + VTL + + + + + + + + + + true + VTL + + + + + + + COMMENT_QE + + + + + + + id + soft + + + soft + + + + in-error + + id + soft + + + soft + + + + COMMENT_QE + + + + + + + + + + QCU + + + + + + + + + + SUGGCOMM + + + + + + + + + + INERROR + + + + + + + + + + FILTER_RESULT_QCU + + true + VTL + + false + + + FILTER_RESULT_SUGGCOMM + + true + VTL + + false + + + FILTER_RESULT_INERROR + + true + VTL + + false + + + +