-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v2-next' into renovate/v2-main-all-minor-patch
- Loading branch information
Showing
5 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/test/java/fr/insee/lunatic/conversion/data/JsonToXmlDataTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = """ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Data> | ||
<COLLECTED> | ||
<LIENS_MISSING> | ||
<COLLECTED> | ||
<COLLECTED type="null"/> | ||
<COLLECTED> | ||
<COLLECTED type="null"/> | ||
<COLLECTED type="null"/> | ||
</COLLECTED> | ||
</COLLECTED> | ||
</LIENS_MISSING> | ||
</COLLECTED> | ||
<CALCULATED/> | ||
<EXTERNAL> | ||
<FOO_EXTERNAL type="string">some value</FOO_EXTERNAL> | ||
</EXTERNAL> | ||
</Data> | ||
"""; | ||
XmlAssert.assertThat(expected).and(result).ignoreWhitespace().areIdentical(); | ||
} | ||
|
||
} |