From f7a68f63286dba5530dc3bcabf63b200ed183874 Mon Sep 17 00:00:00 2001 From: Nicolas Senave Date: Tue, 10 Dec 2024 16:55:21 +0100 Subject: [PATCH 1/2] build: java 11 to 17 --- .github/workflows/create-release.yml | 5 ++++- .github/workflows/create-snapshot.yml | 9 ++++++--- .github/workflows/tests.yml | 7 +++++-- pom.xml | 4 ++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index d6b083aa..ed6d4059 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -8,6 +8,9 @@ on: - 'src/**' - 'pom.xml' +env: + JAVA_VERSION: '17' + jobs: check-version: runs-on: ubuntu-latest @@ -93,7 +96,7 @@ jobs: - name: Set up Maven Central Repository uses: actions/setup-java@v4 with: - java-version: 11 + java-version: ${{ env.JAVA_VERSION }} distribution: adopt server-id: ossrh server-username: MAVEN_USERNAME diff --git a/.github/workflows/create-snapshot.yml b/.github/workflows/create-snapshot.yml index aeefd745..8412953e 100644 --- a/.github/workflows/create-snapshot.yml +++ b/.github/workflows/create-snapshot.yml @@ -4,6 +4,9 @@ on: pull_request: types: [opened, edited, synchronize, reopened, labeled] +env: + JAVA_VERSION: '17' + jobs: # begin the snapshot verification before deployment check-version: @@ -47,11 +50,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: "11" + java-version: ${{ env.JAVA_VERSION }} - name: Tests run: mvn test --no-transfer-progress @@ -79,7 +82,7 @@ jobs: - name: Set up Maven Central Repository uses: actions/setup-java@v4 with: - java-version: 11 + java-version: ${{ env.JAVA_VERSION }} distribution: adopt server-id: ossrh server-username: MAVEN_USERNAME diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 81846b72..9eb80415 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,6 +4,9 @@ on: pull_request: types: [opened, edited, synchronize, reopened] +env: + JAVA_VERSION: '17' + jobs: test: if: ${{ ! contains(github.event.pull_request.labels.*.name, 'deploy-snapshot') }} @@ -11,11 +14,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: "11" + java-version: ${{ env.JAVA_VERSION }} - name: Tests run: mvn test --no-transfer-progress \ No newline at end of file diff --git a/pom.xml b/pom.xml index dbfff366..d4e1f78d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ fr.insee.lunatic lunatic-model - 2.6.4 + 2.7.0 jar Lunatic Model @@ -20,7 +20,7 @@ UTF-8 UTF-8 - 11 + 17 12.4 From f36a1233f8e480c58b0adf6d1ed78d8ad44648a8 Mon Sep 17 00:00:00 2001 From: Nicolas Senave Date: Tue, 10 Dec 2024 17:17:48 +0100 Subject: [PATCH 2/2] test(data): add test on json to xml data conversion For a weird case in pairwise data. --- pom.xml | 2 +- .../conversion/data/JsonToXmlDataTest.java | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/test/java/fr/insee/lunatic/conversion/data/JsonToXmlDataTest.java 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(); + } + +}