From 717d3179f7ca30ea5df4ec6b30f00632533affc4 Mon Sep 17 00:00:00 2001 From: bot Date: Thu, 11 Jul 2024 11:00:50 +0000 Subject: [PATCH 1/5] updated version to 2.15.0-SNAPSHOT --- CHANGELOG.md | 5 +++++ aql/pom.xml | 2 +- bom/pom.xml | 2 +- client/pom.xml | 2 +- example-generator/pom.xml | 2 +- generator-commons/pom.xml | 2 +- generator-maven-plugin/pom.xml | 2 +- generator/pom.xml | 2 +- opt-1.4/pom.xml | 2 +- pom.xml | 4 ++-- response-dto/pom.xml | 2 +- serialisation/pom.xml | 2 +- serialisation_conformance_test/pom.xml | 2 +- terminology/pom.xml | 2 +- test-coverage/pom.xml | 2 +- test-data/pom.xml | 2 +- util/pom.xml | 2 +- validation/pom.xml | 2 +- web-template/pom.xml | 2 +- 19 files changed, 24 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7756bd696..6733bf99e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Note: version releases in the 0.x.y range may introduce breaking changes. +## [unreleased] + ### Added + ### Fixed + ## [2.14.0] ### Changed - Bumped libraries @@ -422,3 +426,4 @@ Note: version releases in the 0.x.y range may introduce breaking changes. [2.12.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.11.0...v2.12.0 [2.13.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.12.0...v2.13.0 [2.14.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.13.0...v2.14.0 +[unreleased]: https://github.com/ehrbase/openEHR_SDK/compare/v2.14.0...HEAD diff --git a/aql/pom.xml b/aql/pom.xml index 8c764d70e..829621273 100644 --- a/aql/pom.xml +++ b/aql/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT aql diff --git a/bom/pom.xml b/bom/pom.xml index e38dd6c3c..98c9f5ce4 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -8,7 +8,7 @@ bom org.ehrbase.openehr.sdk - 2.14.0 + 2.15.0-SNAPSHOT pom openEHR SDK diff --git a/client/pom.xml b/client/pom.xml index 837ae600f..6050b9f91 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT client diff --git a/example-generator/pom.xml b/example-generator/pom.xml index da3b891e3..eba869ccc 100644 --- a/example-generator/pom.xml +++ b/example-generator/pom.xml @@ -5,7 +5,7 @@ sdk-parent org.ehrbase.openehr.sdk - 2.14.0 + 2.15.0-SNAPSHOT 4.0.0 diff --git a/generator-commons/pom.xml b/generator-commons/pom.xml index 0f831edb7..9764074aa 100644 --- a/generator-commons/pom.xml +++ b/generator-commons/pom.xml @@ -6,7 +6,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT generator-commons diff --git a/generator-maven-plugin/pom.xml b/generator-maven-plugin/pom.xml index c0fc8fffe..dc9239272 100644 --- a/generator-maven-plugin/pom.xml +++ b/generator-maven-plugin/pom.xml @@ -5,7 +5,7 @@ sdk-parent org.ehrbase.openehr.sdk - 2.14.0 + 2.15.0-SNAPSHOT 4.0.0 diff --git a/generator/pom.xml b/generator/pom.xml index ea4e1c0d3..89d0b064a 100644 --- a/generator/pom.xml +++ b/generator/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT generator diff --git a/opt-1.4/pom.xml b/opt-1.4/pom.xml index 80cf28e53..10282fd95 100644 --- a/opt-1.4/pom.xml +++ b/opt-1.4/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT opt-1.4 diff --git a/pom.xml b/pom.xml index bb122cfac..bea29c310 100644 --- a/pom.xml +++ b/pom.xml @@ -25,13 +25,13 @@ org.ehrbase.openehr.sdk bom - 2.14.0 + 2.15.0-SNAPSHOT ./bom/pom.xml org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT pom openEHR SDK diff --git a/response-dto/pom.xml b/response-dto/pom.xml index 1ee585663..24cb4058f 100644 --- a/response-dto/pom.xml +++ b/response-dto/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT response-dto diff --git a/serialisation/pom.xml b/serialisation/pom.xml index 883b9249c..3fd6df13f 100644 --- a/serialisation/pom.xml +++ b/serialisation/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT serialisation diff --git a/serialisation_conformance_test/pom.xml b/serialisation_conformance_test/pom.xml index d305091f2..f2e957549 100644 --- a/serialisation_conformance_test/pom.xml +++ b/serialisation_conformance_test/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT serialisation_conformance_test diff --git a/terminology/pom.xml b/terminology/pom.xml index 20ebb7fbb..820b83147 100644 --- a/terminology/pom.xml +++ b/terminology/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT terminology diff --git a/test-coverage/pom.xml b/test-coverage/pom.xml index 2d9cc4ca2..da82cf062 100644 --- a/test-coverage/pom.xml +++ b/test-coverage/pom.xml @@ -8,7 +8,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT test-coverage diff --git a/test-data/pom.xml b/test-data/pom.xml index c77f166aa..9c1128aca 100644 --- a/test-data/pom.xml +++ b/test-data/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT test-data diff --git a/util/pom.xml b/util/pom.xml index 4ff4d5e16..c1c6b1dd7 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT util diff --git a/validation/pom.xml b/validation/pom.xml index c2d293714..ba60f7e0b 100644 --- a/validation/pom.xml +++ b/validation/pom.xml @@ -24,7 +24,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT validation diff --git a/web-template/pom.xml b/web-template/pom.xml index d09de54c3..7140305a6 100644 --- a/web-template/pom.xml +++ b/web-template/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.14.0 + 2.15.0-SNAPSHOT web-template From 83e6b5f3a8729fe230962374900114e74525d3a2 Mon Sep 17 00:00:00 2001 From: alexlehn Date: Mon, 22 Jul 2024 12:00:49 +0200 Subject: [PATCH 2/5] [CDR-1512] Fix flat parsing of ObjectVersionId (#622) * CDR-1512 Migrate tests to JUnit5 * CDR-1512 Reduce cognitive load of flat locatable unmarshaller --- CHANGELOG.md | 1 + .../LocatableUnmarshalPostprocessor.java | 128 +++-- .../serialisation/FolderSerializerTest.java | 14 +- .../flatencoding/FlatJsonTest.java | 45 +- .../flatencoding/FlatTestHelper.java | 51 ++ .../std/marshal/FlatJsonMarshallerTest.java | 172 +++---- .../umarshal/FlatJsonUnmarshallerTest.java | 447 +++++++++--------- .../structured/StructuredHelperTest.java | 17 +- .../CanonicalJsonMarshallingTest.java | 30 +- .../sdk/serialisation/walker/WalkerTest.java | 6 +- .../defaultvalues/DefaultValuesTest.java | 8 +- .../xmlencoding/CanonicalXMLTest.java | 14 +- 12 files changed, 485 insertions(+), 448 deletions(-) create mode 100644 serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/FlatTestHelper.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 6733bf99e..c551b7c0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Note: version releases in the 0.x.y range may introduce breaking changes. ## [unreleased] ### Added ### Fixed +- Fix flat format parsing of `ObjectVersionId` ([622](https://github.com/ehrbase/openEHR_SDK/pull/622)) ## [2.14.0] ### Changed diff --git a/serialisation/src/main/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/umarshal/postprocessor/LocatableUnmarshalPostprocessor.java b/serialisation/src/main/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/umarshal/postprocessor/LocatableUnmarshalPostprocessor.java index 3c8f8b1e2..5b3ead4a4 100644 --- a/serialisation/src/main/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/umarshal/postprocessor/LocatableUnmarshalPostprocessor.java +++ b/serialisation/src/main/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/umarshal/postprocessor/LocatableUnmarshalPostprocessor.java @@ -27,14 +27,17 @@ import com.nedap.archie.rm.datavalues.DvCodedText; import com.nedap.archie.rm.datavalues.DvText; import com.nedap.archie.rm.support.identification.HierObjectId; +import com.nedap.archie.rm.support.identification.ObjectVersionId; import java.util.ArrayList; import java.util.Map; +import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; import org.ehrbase.openehr.sdk.serialisation.walker.Context; import org.ehrbase.openehr.sdk.serialisation.walker.FlatHelper; import org.ehrbase.openehr.sdk.serialisation.walker.defaultvalues.DefaultValues; import org.ehrbase.openehr.sdk.util.rmconstants.RmConstants; +import org.ehrbase.openehr.sdk.webtemplate.model.WebTemplateNode; import org.ehrbase.openehr.sdk.webtemplate.path.flat.FlatPathDto; public class LocatableUnmarshalPostprocessor extends AbstractUnmarshalPostprocessor { @@ -48,54 +51,16 @@ public void process( Set consumedPaths, Context> context) { - if (RmConstants.ELEMENT.equals(context.getNodeDeque().peek().getRmType()) - || !context.getFlatHelper().skip(context)) { - - setValue( - term + PATH_DIVIDER + "_uid", - null, - values, - s -> rmObject.setUid(new HierObjectId(s)), - String.class, - consumedPaths); - - Map> links = extractMultiValued(term, "_link", values); - - if (rmObject.getLinks() == null) { - rmObject.setLinks(new ArrayList<>()); - } - - rmObject.getLinks() - .addAll(links.entrySet().stream() - .map(e -> DefaultValues.createLink(e.getValue(), term + "/_link:" + e.getKey())) - .collect(Collectors.toList())); - - consumeAllMatching(term + PATH_DIVIDER + "_link", values, consumedPaths, false); - - Map feederAuditValues = FlatHelper.filter(values, term + "/_feeder_audit", false); - - if (!feederAuditValues.isEmpty()) { - - rmObject.setFeederAudit(new FeederAudit()); - handleRmAttribute( - term, rmObject.getFeederAudit(), feederAuditValues, consumedPaths, context, "feeder_audit"); - } - - Map nameValues = FlatHelper.filter(values, term + "/_name", false); - if (!nameValues.isEmpty()) { - final DvText name; - boolean isDvCodedText = nameValues.keySet().stream() - .anyMatch(e -> "code".equals(e.getLast().getAttributeName()) - && "_name".equals(e.getLast().getName())); - - if (isDvCodedText) { - name = new DvCodedText(); - } else { - name = new DvText(); - } - rmObject.setName(name); - handleRmAttribute(term, rmObject.getName(), nameValues, consumedPaths, context, "name"); - } + String rmType = Optional.ofNullable(context.getNodeDeque().peek()) + .map(WebTemplateNode::getRmType) + .orElse(null); + + if (RmConstants.ELEMENT.equals(rmType) || !context.getFlatHelper().skip(context)) { + + setUID(term, rmObject, values, consumedPaths); + setName(term, rmObject, values, consumedPaths, context); + setLinks(term, rmObject, values, consumedPaths); + setFeederAudit(term, rmObject, values, consumedPaths, context); } } @@ -104,4 +69,69 @@ public void process( public Class getAssociatedClass() { return Locatable.class; } + + private void setUID(String term, Locatable rmObject, Map values, Set consumedPaths) { + setValue( + term + PATH_DIVIDER + "_uid", + null, + values, + value -> rmObject.setUid( + StringUtils.countMatches(value, "::") == 2 + ? new ObjectVersionId(value) + : new HierObjectId(value)), + String.class, + consumedPaths); + } + + private void setName( + String term, + Locatable rmObject, + Map values, + Set consumedPaths, + Context> context) { + + Map nameValues = FlatHelper.filter(values, term + "/_name", false); + if (!nameValues.isEmpty()) { + boolean isDvCodedText = nameValues.keySet().stream().anyMatch(e -> { + FlatPathDto last = e.getLast(); + return "code".equals(last.getAttributeName()) && "_name".equals(last.getName()); + }); + + rmObject.setName(isDvCodedText ? new DvCodedText() : new DvText()); + handleRmAttribute(term, rmObject.getName(), nameValues, consumedPaths, context, "name"); + } + } + + private void setLinks(String term, Locatable rmObject, Map values, Set consumedPaths) { + + Map> links = extractMultiValued(term, "_link", values); + + if (rmObject.getLinks() == null) { + rmObject.setLinks(new ArrayList<>()); + } + + rmObject.getLinks() + .addAll(links.entrySet().stream() + .map(e -> DefaultValues.createLink(e.getValue(), term + "/_link:" + e.getKey())) + .toList()); + + consumeAllMatching(term + PATH_DIVIDER + "_link", values, consumedPaths, false); + } + + private void setFeederAudit( + String term, + Locatable rmObject, + Map values, + Set consumedPaths, + Context> context) { + + Map feederAuditValues = FlatHelper.filter(values, term + "/_feeder_audit", false); + + if (!feederAuditValues.isEmpty()) { + + rmObject.setFeederAudit(new FeederAudit()); + handleRmAttribute( + term, rmObject.getFeederAudit(), feederAuditValues, consumedPaths, context, "feeder_audit"); + } + } } diff --git a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/FolderSerializerTest.java b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/FolderSerializerTest.java index e7268ac48..0f386865f 100644 --- a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/FolderSerializerTest.java +++ b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/FolderSerializerTest.java @@ -27,13 +27,13 @@ import org.ehrbase.openehr.sdk.serialisation.xmlencoding.CanonicalXML; import org.ehrbase.openehr.sdk.test_data.folder.FolderTestDataCanonicalJson; import org.ehrbase.openehr.sdk.test_data.folder.FolderTestDataCanonicalXML; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -public class FolderSerializerTest { +class FolderSerializerTest { @Test - public void marshalBasicJsonFolder() throws IOException { + void marshalBasicJsonFolder() throws IOException { String value = IOUtils.toString(FolderTestDataCanonicalJson.SIMPLE_EMPTY_FOLDER.getStream(), UTF_8); CanonicalJson canonicalJson = new CanonicalJson(); @@ -49,7 +49,7 @@ public void marshalBasicJsonFolder() throws IOException { } @Test - public void unmarshalBasicJsonFolder() throws IOException { + void unmarshalBasicJsonFolder() throws IOException { String value = IOUtils.toString(FolderTestDataCanonicalJson.SIMPLE_EMPTY_FOLDER.getStream(), UTF_8); @@ -60,8 +60,8 @@ public void unmarshalBasicJsonFolder() throws IOException { } @Test - @Ignore("Possible bug at Archie with missing XMLRootElement annotation for folders.") - public void marshalBasicXmlFolder() throws IOException { + @Disabled("Possible bug at Archie with missing XMLRootElement annotation for folders.") + void marshalBasicXmlFolder() throws IOException { String value = IOUtils.toString(FolderTestDataCanonicalXML.SIMPLE_EMPTY_FOLDER.getStrean(), UTF_8); diff --git a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/FlatJsonTest.java b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/FlatJsonTest.java index add176833..ac835058c 100644 --- a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/FlatJsonTest.java +++ b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/FlatJsonTest.java @@ -26,18 +26,17 @@ import org.apache.commons.io.IOUtils; import org.assertj.core.api.SoftAssertions; import org.ehrbase.openehr.sdk.serialisation.RMDataFormat; -import org.ehrbase.openehr.sdk.serialisation.flatencoding.std.marshal.FlatJsonMarshallerTest; import org.ehrbase.openehr.sdk.serialisation.templateprovider.TestDataTemplateProvider; import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataSimSDTJson; import org.ehrbase.openehr.sdk.test_data.operationaltemplate.OperationalTemplateTestData; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class FlatJsonTest { +class FlatJsonTest { - public static final TestDataTemplateProvider templateProvider = new TestDataTemplateProvider(); + private static final TestDataTemplateProvider templateProvider = new TestDataTemplateProvider(); @Test - public void roundTrip() throws IOException { + void roundTrip() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.CORONA_WITH_OTHER_PARTICIPATION; String templateId = "Corona_Anamnese"; @@ -46,7 +45,7 @@ public void roundTrip() throws IOException { } @Test - public void roundTripSSIAD_PRIeSM() throws IOException { + void roundTripSSIAD_PRIeSM() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.SSIAD_PRIESM; String templateId = testData.getTemplate().getTemplateId(); @@ -55,7 +54,7 @@ public void roundTripSSIAD_PRIeSM() throws IOException { } @Test - public void roundTripFeederAudit() throws IOException { + void roundTripFeederAudit() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.CORONA_WITH_FEEDER_AUDIT; String templateId = "Corona_Anamnese"; @@ -64,7 +63,7 @@ public void roundTripFeederAudit() throws IOException { } @Test - public void roundTripFeederAuditRaw() throws IOException { + void roundTripFeederAuditRaw() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.CORONA_WITH_FEEDER_AUDIT_RAW; String templateId = "Corona_Anamnese"; @@ -90,7 +89,7 @@ public void roundTripFeederAuditRaw() throws IOException { String expected = IOUtils.toString( CompositionTestDataSimSDTJson.CORONA_WITH_FEEDER_AUDIT.getStream(), StandardCharsets.UTF_8); - List errors = FlatJsonMarshallerTest.compere(actual, expected); + List errors = FlatTestHelper.compere(actual, expected); softAssertions .assertThat(errors) @@ -103,7 +102,7 @@ public void roundTripFeederAuditRaw() throws IOException { } @Test - public void roundTripRaw() throws IOException { + void roundTripRaw() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.CORONA_WITH_RAW; String templateId = "Corona_Anamnese"; @@ -128,7 +127,7 @@ public void roundTripRaw() throws IOException { String expected = IOUtils.toString(CompositionTestDataSimSDTJson.CORONA.getStream(), StandardCharsets.UTF_8); - List errors = FlatJsonMarshallerTest.compere(actual, expected); + List errors = FlatTestHelper.compere(actual, expected); softAssertions .assertThat(errors) @@ -141,7 +140,7 @@ public void roundTripRaw() throws IOException { } @Test - public void roundTripAction() throws IOException { + void roundTripAction() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.EREACT_COVID_MANAGEMENT; String templateId = OperationalTemplateTestData.EREACT_COVID_MANAGEMENT.getTemplateId(); @@ -150,7 +149,7 @@ public void roundTripAction() throws IOException { } @Test - public void roundTripNCD() throws IOException { + void roundTripNCD() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.NCD; String templateId = OperationalTemplateTestData.NCD.getTemplateId(); @@ -202,7 +201,7 @@ public void roundTripNCD() throws IOException { } @Test - public void roundTripVitalSigns() throws IOException { + void roundTripVitalSigns() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.VITALSIGNS; String templateId = "EHRN Vital signs.v2"; @@ -210,7 +209,7 @@ public void roundTripVitalSigns() throws IOException { } @Test - public void roundTripIcd() throws IOException { + void roundTripIcd() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.ADVERSE_REACTION_LIST; String templateId = "Adverse Reaction List.v1"; @@ -219,7 +218,7 @@ public void roundTripIcd() throws IOException { } @Test - public void roundMultiList() throws IOException { + void roundMultiList() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.MULTI_LIST; String templateId = OperationalTemplateTestData.MULTI_LIST.getTemplateId(); @@ -228,7 +227,7 @@ public void roundMultiList() throws IOException { } @Test - public void roundNameWithAnd() throws IOException { + void roundNameWithAnd() throws IOException { CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.WORD_WITH_AND; String templateId = OperationalTemplateTestData.WORD_WITH_AND.getTemplateId(); @@ -237,7 +236,7 @@ public void roundNameWithAnd() throws IOException { } @Test - public void roundTripDeterioriationAssessment() throws IOException { + void roundTripDeterioriationAssessment() throws IOException { String templateId = "EREACT - Deterioriation assessment.v0"; CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.DETERIORIATION_ASSESSMENT; @@ -264,7 +263,7 @@ public void roundTripDeterioriationAssessment() throws IOException { } @Test - public void roundTripAll() throws IOException { + void roundTripAll() throws IOException { String templateId = "test_all_types.en.v1"; CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.ALL_TYPES; @@ -282,7 +281,7 @@ public void roundTripAll() throws IOException { } @Test - public void roundTripAlt() throws IOException { + void roundTripAlt() throws IOException { String templateId = "AlternativeEvents"; CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.ALTERNATIVE_EVENTS; @@ -307,7 +306,7 @@ public void roundTripAlt() throws IOException { } @Test - public void roundTripMulti() throws IOException { + void roundTripMulti() throws IOException { String templateId = "ehrbase_multi_occurrence.de.v1"; CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.MULTI_OCCURRENCE; @@ -330,7 +329,7 @@ public void roundTripMulti() throws IOException { } @Test - public void roundTripMissingCount() throws IOException { + void roundTripMissingCount() throws IOException { String templateId = "ehrbase_multi_occurrence.de.v1"; CompositionTestDataSimSDTJson testData = CompositionTestDataSimSDTJson.MISSING_COUNT; @@ -385,7 +384,7 @@ private void check( String expected = IOUtils.toString(testData.getStream(), StandardCharsets.UTF_8); - List errors = FlatJsonMarshallerTest.compere(actual, expected); + List errors = FlatTestHelper.compere(actual, expected); softAssertions .assertThat(errors) diff --git a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/FlatTestHelper.java b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/FlatTestHelper.java new file mode 100644 index 000000000..7be7fedcc --- /dev/null +++ b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/FlatTestHelper.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 vitasystems GmbH and Hannover Medical School. + * + * This file is part of project openEHR_SDK + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.ehrbase.openehr.sdk.serialisation.flatencoding; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.ehrbase.openehr.sdk.serialisation.jsonencoding.ArchieObjectMapperProvider; + +public class FlatTestHelper { + + @SuppressWarnings("unchecked") + public static List compere(String actualJson, String expectedJson) throws JsonProcessingException { + List errors = new ArrayList<>(); + ObjectMapper objectMapper = ArchieObjectMapperProvider.getObjectMapper(); + + Map actual = objectMapper.readValue(actualJson, Map.class); + Map expected = objectMapper.readValue(expectedJson, Map.class); + + actual.forEach((key, value) -> { + if (!expected.containsKey(key) || !expected.get(key).equals(value)) { + errors.add(String.format("Missing path: %s, value: %s", key, value)); + } + }); + + expected.forEach((key, value) -> { + if (!actual.containsKey(key) || !actual.get(key).equals(value)) { + errors.add(String.format("Extra path: %s, value: %s", key, value)); + } + }); + + return errors; + } +} diff --git a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/marshal/FlatJsonMarshallerTest.java b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/marshal/FlatJsonMarshallerTest.java index f87ddc54e..e06d31d91 100644 --- a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/marshal/FlatJsonMarshallerTest.java +++ b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/marshal/FlatJsonMarshallerTest.java @@ -18,74 +18,50 @@ package org.ehrbase.openehr.sdk.serialisation.flatencoding.std.marshal; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import com.nedap.archie.rm.composition.Composition; -import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import org.apache.commons.io.IOUtils; -import org.apache.xmlbeans.XmlException; import org.assertj.core.api.SoftAssertions; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.ArchieObjectMapperProvider; +import org.ehrbase.openehr.sdk.serialisation.flatencoding.FlatTestHelper; import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataSimSDTJson; import org.ehrbase.openehr.sdk.test_data.operationaltemplate.OperationalTemplateTestData; +import org.ehrbase.openehr.sdk.webtemplate.model.WebTemplate; import org.ehrbase.openehr.sdk.webtemplate.parser.OPTParser; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openehr.schemas.v1.OPERATIONALTEMPLATE; import org.openehr.schemas.v1.TemplateDocument; -public class FlatJsonMarshallerTest { +class FlatJsonMarshallerTest { @Test - public void toFlatJson() throws IOException, XmlException { + void toFlatJson() throws Exception { - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( - OperationalTemplateTestData.CORONA_ANAMNESE.getStream()) - .getTemplate(); - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString(CompositionTestDataCanonicalJson.CORONA.getStream(), StandardCharsets.UTF_8), - Composition.class); - FlatJsonMarshaller cut = new FlatJsonMarshaller(); - String actual = cut.toFlatJson(composition, new OPTParser(template).parse()); - assertThat(actual).isNotNull(); + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.CORONA_ANAMNESE); + Composition composition = composition(CompositionTestDataCanonicalJson.CORONA); - String expected = IOUtils.toString(CompositionTestDataSimSDTJson.CORONA.getStream(), StandardCharsets.UTF_8); - - List errors = compere(actual, expected); + String actual = new FlatJsonMarshaller().toFlatJson(composition, webTemplate); + String expected = compositionJson(CompositionTestDataSimSDTJson.CORONA); + List errors = FlatTestHelper.compere(actual, expected); assertThat(errors).filteredOn(s -> s.startsWith("Missing")).containsExactlyInAnyOrder(); - assertThat(errors).filteredOn(s -> s.startsWith("Extra")).containsExactlyInAnyOrder(); } @Test - public void toFlatJsonAltEvents() throws IOException, XmlException { - - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( - OperationalTemplateTestData.ALT_EVENTS.getStream()) - .getTemplate(); - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.ALTERNATIVE_EVENTS.getStream(), - StandardCharsets.UTF_8), - Composition.class); - FlatJsonMarshaller cut = new FlatJsonMarshaller(); - String actual = cut.toFlatJson(composition, new OPTParser(template).parse()); - assertThat(actual).isNotNull(); - - String expected = IOUtils.toString( - CompositionTestDataSimSDTJson.ALTERNATIVE_EVENTS_2.getStream(), StandardCharsets.UTF_8); - - List errors = compere(actual, expected); + void toFlatJsonAltEventsErrors() throws Exception { + + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.ALT_EVENTS); + Composition composition = composition(CompositionTestDataCanonicalJson.ALTERNATIVE_EVENTS); + String actual = new FlatJsonMarshaller().toFlatJson(composition, webTemplate); + String expected = compositionJson(CompositionTestDataSimSDTJson.ALTERNATIVE_EVENTS_2); + + List errors = FlatTestHelper.compere(actual, expected); checkErrors( errors, new String[] { @@ -101,25 +77,15 @@ public void toFlatJsonAltEvents() throws IOException, XmlException { } @Test - public void toFlatJsonMultiOccurrence() throws IOException, XmlException { - - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( - OperationalTemplateTestData.MULTI_OCCURRENCE.getStream()) - .getTemplate(); - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.MULTI_OCCURRENCE.getStream(), StandardCharsets.UTF_8), - Composition.class); - FlatJsonMarshaller cut = new FlatJsonMarshaller(); - String actual = cut.toFlatJson(composition, new OPTParser(template).parse()); - assertThat(actual).isNotNull(); + void toFlatJsonMultiOccurrenceErrors() throws Exception { - String expected = - IOUtils.toString(CompositionTestDataSimSDTJson.MULTI_OCCURRENCE.getStream(), StandardCharsets.UTF_8); + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.MULTI_OCCURRENCE); + Composition composition = composition(CompositionTestDataCanonicalJson.MULTI_OCCURRENCE); - List errors = compere(actual, expected); + String actual = new FlatJsonMarshaller().toFlatJson(composition, webTemplate); + String expected = compositionJson(CompositionTestDataSimSDTJson.MULTI_OCCURRENCE); + List errors = FlatTestHelper.compere(actual, expected); checkErrors( errors, new String[] { @@ -137,24 +103,15 @@ public void toFlatJsonMultiOccurrence() throws IOException, XmlException { } @Test - public void toFlatJsonAllTypes() throws IOException, XmlException { - - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.ALL_TYPES.getStream()) - .getTemplate(); + void toFlatJsonAllTypesErrors() throws Exception { - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.ALL_TYPES.getStream(), StandardCharsets.UTF_8), - Composition.class); - FlatJsonMarshaller cut = new FlatJsonMarshaller(); - String actual = cut.toFlatJson(composition, new OPTParser(template).parse()); - assertThat(actual).isNotNull(); + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.ALL_TYPES); + Composition composition = composition(CompositionTestDataCanonicalJson.ALL_TYPES); - String expected = IOUtils.toString(CompositionTestDataSimSDTJson.ALL_TYPES.getStream(), StandardCharsets.UTF_8); - - List errors = compere(actual, expected); + String actual = new FlatJsonMarshaller().toFlatJson(composition, webTemplate); + String expected = compositionJson(CompositionTestDataSimSDTJson.ALL_TYPES); + List errors = FlatTestHelper.compere(actual, expected); checkErrors( errors, new String[] { @@ -172,24 +129,15 @@ public void toFlatJsonAllTypes() throws IOException, XmlException { } @Test - public void toFlatJsonIps() throws Exception { - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.IPS.getStream()) - .getTemplate(); - - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString(CompositionTestDataCanonicalJson.IPS.getStream(), StandardCharsets.UTF_8), - Composition.class); - - FlatJsonMarshaller marshaller = new FlatJsonMarshaller(); + void toFlatJsonIpsErrors() throws Exception { - String actual = marshaller.toFlatJson(composition, new OPTParser(template).parse()); - assertThat(actual).isNotNull(); + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.IPS); + Composition composition = composition(CompositionTestDataCanonicalJson.IPS); - String expected = IOUtils.toString(CompositionTestDataSimSDTJson.IPS.getStream(), StandardCharsets.UTF_8); - - List errors = compere(actual, expected); + String actual = new FlatJsonMarshaller().toFlatJson(composition, webTemplate); + String expected = compositionJson(CompositionTestDataSimSDTJson.IPS); + List errors = FlatTestHelper.compere(actual, expected); checkErrors( errors, new String[] { @@ -232,7 +180,29 @@ public void toFlatJsonIps() throws Exception { }); } - public void checkErrors(List errors, String[] missing, String[] extra) { + // -- Helper -- + + private static WebTemplate webTemplateFromOTP(OperationalTemplateTestData data) { + WebTemplate webTemplate = null; + try (var in = data.getStream()) { + OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(in).getTemplate(); + webTemplate = new OPTParser(template).parse(); + assertThat(webTemplate).isNotNull(); + } catch (Exception e) { + fail(e); + } + return webTemplate; + } + + private static Composition composition(CompositionTestDataCanonicalJson data) throws Exception { + return new CanonicalJson().unmarshal(IOUtils.toString(data.getStream(), StandardCharsets.UTF_8)); + } + + private static String compositionJson(CompositionTestDataSimSDTJson data) throws Exception { + return IOUtils.toString(data.getStream(), StandardCharsets.UTF_8); + } + + void checkErrors(List errors, String[] missing, String[] extra) { SoftAssertions softAssertions = new SoftAssertions(); @@ -245,26 +215,4 @@ public void checkErrors(List errors, String[] missing, String[] extra) { softAssertions.assertAll(); } - - public static List compere(String actualJson, String expectedJson) throws JsonProcessingException { - List errors = new ArrayList<>(); - ObjectMapper objectMapper = ArchieObjectMapperProvider.getObjectMapper(); - - Map actual = objectMapper.readValue(actualJson, Map.class); - Map expected = objectMapper.readValue(expectedJson, Map.class); - - actual.forEach((key, value) -> { - if (!expected.containsKey(key) || !expected.get(key).equals(value)) { - errors.add(String.format("Missing path: %s, value: %s", key, value)); - } - }); - - expected.forEach((key, value) -> { - if (!actual.containsKey(key) || !actual.get(key).equals(value)) { - errors.add(String.format("Extra path: %s, value: %s", key, value)); - } - }); - - return errors; - } } diff --git a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/umarshal/FlatJsonUnmarshallerTest.java b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/umarshal/FlatJsonUnmarshallerTest.java index c136e7189..f50eba6e2 100644 --- a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/umarshal/FlatJsonUnmarshallerTest.java +++ b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/std/umarshal/FlatJsonUnmarshallerTest.java @@ -18,8 +18,11 @@ package org.ehrbase.openehr.sdk.serialisation.flatencoding.std.umarshal; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.fail; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.nedap.archie.rm.composition.Composition; import com.nedap.archie.rm.composition.Observation; import com.nedap.archie.rm.datastructures.Element; @@ -28,311 +31,317 @@ import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime; import com.nedap.archie.rm.datavalues.quantity.datetime.DvTime; import com.nedap.archie.rm.generic.PartySelf; -import java.io.IOException; -import java.io.InputStream; +import com.nedap.archie.rm.support.identification.HierObjectId; +import com.nedap.archie.rm.support.identification.ObjectVersionId; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.commons.io.IOUtils; -import org.apache.xmlbeans.XmlException; -import org.assertj.core.api.Assertions; import org.ehrbase.openehr.sdk.serialisation.exception.UnmarshalException; import org.ehrbase.openehr.sdk.serialisation.jsonencoding.ArchieObjectMapperProvider; import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataConformanceSDTJson; import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataSimSDTJson; +import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataSimSDTJsonInterface; import org.ehrbase.openehr.sdk.test_data.operationaltemplate.OperationalTemplateTestData; import org.ehrbase.openehr.sdk.webtemplate.model.WebTemplate; import org.ehrbase.openehr.sdk.webtemplate.parser.OPTParser; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.ValueSource; import org.openehr.schemas.v1.OPERATIONALTEMPLATE; import org.openehr.schemas.v1.TemplateDocument; -public class FlatJsonUnmarshallerTest { +class FlatJsonUnmarshallerTest { - private Object thing; + private final ObjectMapper mapper = ArchieObjectMapperProvider.getObjectMapper(); @Test - public void unmarshal() throws IOException, XmlException { - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( - OperationalTemplateTestData.CORONA_ANAMNESE.getStream()) - .getTemplate(); - WebTemplate webTemplate = new OPTParser(template).parse(); + void unmarshal() { - FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller(); - - String flat = IOUtils.toString(CompositionTestDataSimSDTJson.CORONA.getStream(), StandardCharsets.UTF_8); - - Composition actual = cut.unmarshal(flat, webTemplate); - - assertThat(actual).isNotNull(); - - Observation observation = (Observation) actual.itemAtPath("/content[openEHR-EHR-OBSERVATION.story.v1]"); + Composition composition = unmarshallComposition( + CompositionTestDataSimSDTJson.CORONA, OperationalTemplateTestData.CORONA_ANAMNESE); + Observation observation = (Observation) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.story.v1]"); assertThat(observation.getData().getOrigin().getValue()).hasToString("2020-05-11T22:53:12.039139+02:00"); assertThat(observation.getSubject()).isNotNull(); assertThat(observation.getSubject().getClass()).isEqualTo(PartySelf.class); } @Test - public void unmarshalUuid() throws IOException, XmlException { - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( - OperationalTemplateTestData.CONFORMANCE.getStream()) - .getTemplate(); - WebTemplate webTemplate = new OPTParser(template).parse(); - - FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller(); - - String flat = IOUtils.toString( - CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_OBSERVATION.getStream(), - StandardCharsets.UTF_8); - - Composition actual = cut.unmarshal(flat, webTemplate); - - assertThat(actual).isNotNull(); + void unmarshalUid() { + Composition composition = unmarshallComposition( + CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_OBSERVATION, + OperationalTemplateTestData.CONFORMANCE); Observation observation = (Observation) - actual.itemAtPath( + composition.itemAtPath( "/content[openEHR-EHR-SECTION.conformance_section.v0]/items[openEHR-EHR-OBSERVATION.conformance_observation.v0]"); - assertThat(observation.getUid().getValue()).hasToString("9fcc1c70-9349-444d-b9cb-8fa817697f5e"); + assertThat(observation.getUid()).hasToString("9fcc1c70-9349-444d-b9cb-8fa817697f5e"); assertThat(observation.getData().getUid()).isNull(); } @Test - public void unmarshalMulti() throws IOException, XmlException { - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( - OperationalTemplateTestData.MULTI_OCCURRENCE.getStream()) - .getTemplate(); - WebTemplate webTemplate = new OPTParser(template).parse(); + void unmarshalHierObjectId() throws Exception { - FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller(); + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.CONFORMANCE); + Map data = + flatCompostionMap(CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_DATA_TYPES_DV_DATE_TIME); - String flat = - IOUtils.toString(CompositionTestDataSimSDTJson.MULTI_OCCURRENCE.getStream(), StandardCharsets.UTF_8); + data.put("conformance-ehrbase.de.v0/_uid", "0e8c2c01-b92d-453e-828e-d33eb721b5a7"); + String flatJson = mapper.writeValueAsString(data); - Composition actual = cut.unmarshal(flat, webTemplate); - - assertThat(actual).isNotNull(); + Composition composition = unmarshallComposition(flatJson, webTemplate); + assertThat(composition.getUid()) + .isNotNull() + .isInstanceOf(HierObjectId.class) + .hasToString("0e8c2c01-b92d-453e-828e-d33eb721b5a7"); } @Test - public void unmarshalAlt() throws IOException, XmlException { - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( - OperationalTemplateTestData.ALT_EVENTS.getStream()) - .getTemplate(); - WebTemplate webTemplate = new OPTParser(template).parse(); - - FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller(); + void unmarshalObjectVersionId() throws Exception { - String flat = - IOUtils.toString(CompositionTestDataSimSDTJson.ALTERNATIVE_EVENTS.getStream(), StandardCharsets.UTF_8); + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.CONFORMANCE); + Map data = + flatCompostionMap(CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_DATA_TYPES_DV_DATE_TIME); - Composition actual = cut.unmarshal(flat, webTemplate); + data.put("conformance-ehrbase.de.v0/_uid", "0e8c2c01-b92d-453e-828e-d33eb721b5a7::test.ehrbase::42"); + String flatJson = mapper.writeValueAsString(data); - assertThat(actual).isNotNull(); + Composition composition = unmarshallComposition(flatJson, webTemplate); + assertThat(composition.getUid()) + .isNotNull() + .isInstanceOf(ObjectVersionId.class) + .hasToString("0e8c2c01-b92d-453e-828e-d33eb721b5a7::test.ehrbase::42"); } @Test - public void unmarshalAllTypes() throws IOException, XmlException { - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.ALL_TYPES.getStream()) - .getTemplate(); - WebTemplate webTemplate = new OPTParser(template).parse(); + void unmarshalMulti() { - FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller(); + Composition composition = unmarshallComposition( + CompositionTestDataSimSDTJson.MULTI_OCCURRENCE, OperationalTemplateTestData.MULTI_OCCURRENCE); + assertThat(composition).isNotNull(); + } - String flat = IOUtils.toString(CompositionTestDataSimSDTJson.ALL_TYPES.getStream(), StandardCharsets.UTF_8); + @Test + void unmarshalAlt() { + + Composition composition = unmarshallComposition( + CompositionTestDataSimSDTJson.ALTERNATIVE_EVENTS, OperationalTemplateTestData.ALT_EVENTS); + assertThat(composition).isNotNull(); + } - Composition actual = cut.unmarshal(flat, webTemplate); + @Test + void unmarshalAllTypes() { - assertThat(actual).isNotNull(); + Composition composition = + unmarshallComposition(CompositionTestDataSimSDTJson.ALL_TYPES, OperationalTemplateTestData.ALL_TYPES); // Choice Node was correctly parsed - Object choice = actual.itemAtPath( + DvQuantity choice = (DvQuantity) composition.itemAtPath( "/content[openEHR-EHR-EVALUATION.test_all_types.v1]/data[at0001]/items[at0009]/value"); - assertThat(choice).isNotNull(); - assertThat(choice.getClass()).isEqualTo(DvQuantity.class); - assertThat(((DvQuantity) choice).getMagnitude()).isEqualTo(148.01210165023804d); - assertThat(((DvQuantity) choice).getUnits()).isEqualTo("mm[H20]"); + assertThat(choice.getMagnitude()).isEqualTo(148.01210165023804d); + assertThat(choice.getUnits()).isEqualTo("mm[H20]"); } @Test - public void unmarshalDeterioriationAssessment() throws IOException, XmlException { - OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( - OperationalTemplateTestData.DETERIORIATION_ASSESSMENT.getStream()) - .getTemplate(); - WebTemplate webTemplate = new OPTParser(template).parse(); - - FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller(); - - String flat = IOUtils.toString( - CompositionTestDataSimSDTJson.DETERIORIATION_ASSESSMENT.getStream(), StandardCharsets.UTF_8); + void unmarshalDeterioriationAssessment() { - Composition actual = cut.unmarshal(flat, webTemplate); - - assertThat(actual).isNotNull(); + Composition composition = unmarshallComposition( + CompositionTestDataSimSDTJson.DETERIORIATION_ASSESSMENT, + OperationalTemplateTestData.DETERIORIATION_ASSESSMENT); + assertThat(composition).isNotNull(); } @Test - public void unmarshallNestedComposition() throws Exception { - var optTemplate = TemplateDocument.Factory.parse(OperationalTemplateTestData.NESTED.getStream()) - .getTemplate(); - var webTemplate = new OPTParser(optTemplate).parse(); + void unmarshallNestedComposition() { - var json = IOUtils.toString(CompositionTestDataSimSDTJson.NESTED.getStream(), StandardCharsets.UTF_8); + Composition composition = + unmarshallComposition(CompositionTestDataSimSDTJson.NESTED, OperationalTemplateTestData.NESTED); + assertThat(composition).isNotNull(); + } - var composition = new FlatJsonUnmarshaller().unmarshal(json, webTemplate); + @Test + void unmarshallIpsComposition() { + Composition composition = + unmarshallComposition(CompositionTestDataSimSDTJson.IPS, OperationalTemplateTestData.IPS); assertThat(composition).isNotNull(); } - @Test - public void unmarshallIpsComposition() throws Exception { - var optTemplate = TemplateDocument.Factory.parse(OperationalTemplateTestData.IPS.getStream()) - .getTemplate(); - var webTemplate = new OPTParser(optTemplate).parse(); + @ParameterizedTest + @CsvSource( + textBlock = + """ + 2022-11-01|2022-11-01 + 2022-11|2022-11 + 2022|2022 + 2022-11-01T13|2022-11-01T13:00 + 2022-11-01T13+02:00|2022-11-01T13:00+02:00 + """, + delimiterString = "|") + void validDvDateTime(String input, String expected) throws Exception { + + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.CONFORMANCE); + Map flat = + flatCompostionMap(CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_DATA_TYPES_DV_DATE_TIME); - var json = IOUtils.toString(CompositionTestDataSimSDTJson.IPS.getStream(), StandardCharsets.UTF_8); + String key = "conformance-ehrbase.de.v0/conformance_section/conformance_observation/any_event:0/dv_date_time"; - var composition = new FlatJsonUnmarshaller().unmarshal(json, webTemplate); + flat.put(key, input); + String json = mapper.writeValueAsString(flat); - assertThat(composition).isNotNull(); + Composition composition = new FlatJsonUnmarshaller().unmarshal(json, webTemplate); + Element element = (Element) + composition.itemAtPath( + "/content[openEHR-EHR-SECTION.conformance_section.v0]/items[openEHR-EHR-OBSERVATION.conformance_observation.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0011]"); + assertThat(element).isNotNull(); + DvDateTime dateTime = (DvDateTime) element.getValue(); + assertThat(dateTime.getValue()).hasToString(expected); } - @Test - public void DvDateTimeTest() throws Exception { - var optTemplate = TemplateDocument.Factory.parse(OperationalTemplateTestData.CONFORMANCE.getStream()) - .getTemplate(); - var webTemplate = new OPTParser(optTemplate).parse(); - Map flat = getKeyValueFromFlatJson( - CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_DATA_TYPES_DV_DATE_TIME.getStream()); + @ParameterizedTest + @ValueSource(strings = {"2022-11", "2022-11-01", "2022-11-01T13"}) + void invalidDvTimeTest(String input) throws Exception { - String key = "conformance-ehrbase.de.v0/conformance_section/conformance_observation/any_event:0/dv_date_time"; - FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller(); - - for (TestCase testCase : Arrays.asList( - new TestCase("2022-11-01", "2022-11-01"), - new TestCase("2022-11", "2022-11"), - new TestCase("2022", "2022"), - new TestCase("2022-11-01T13", "2022-11-01T13:00"), - new TestCase("2022-11-01T13+02:00", "2022-11-01T13:00+02:00"))) { - flat.put(key, testCase.input); - String json = ArchieObjectMapperProvider.getObjectMapper().writeValueAsString(flat); - Composition actual = cut.unmarshal(json, webTemplate); - assertThat(actual).isNotNull(); - Element element = (Element) - actual.itemAtPath( - "/content[openEHR-EHR-SECTION.conformance_section.v0]/items[openEHR-EHR-OBSERVATION.conformance_observation.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0011]"); - assertThat(element).isNotNull(); - DvDateTime dateTime = (DvDateTime) element.getValue(); - assertThat(dateTime.getValue().toString()).isEqualTo(testCase.expected); - } + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.CONFORMANCE); + Map flat = + flatCompostionMap(CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_DATA_TYPES_DV_DATE_TIME); + + String key = "conformance-ehrbase.de.v0/conformance_section/conformance_observation/any_event:0/dv_time"; + + flat.put(key, input); + String json = mapper.writeValueAsString(flat); + + FlatJsonUnmarshaller unmarshaller = new FlatJsonUnmarshaller(); + assertThatThrownBy(() -> unmarshaller.unmarshal(json, webTemplate)) + .isInstanceOf(UnmarshalException.class) + .hasMessageContaining("Text '%s' could not be parsed, unparsed text found".formatted(input)); } - @Test - public void DvTimeTest() throws Exception { - var optTemplate = TemplateDocument.Factory.parse(OperationalTemplateTestData.CONFORMANCE.getStream()) - .getTemplate(); - var webTemplate = new OPTParser(optTemplate).parse(); - Map flat = getKeyValueFromFlatJson( - CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_DATA_TYPES_DV_DATE_TIME.getStream()); + @ParameterizedTest + @CsvSource( + textBlock = + """ + 13:12:11|13:12:11 + 13:12|13:12 + 13|13:00 + 13+02:00|13:00+02:00 + """, + delimiterString = "|") + void validDvTimeTest(String input, String expected) throws Exception { + + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.CONFORMANCE); + Map flat = + flatCompostionMap(CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_DATA_TYPES_DV_DATE_TIME); String key = "conformance-ehrbase.de.v0/conformance_section/conformance_observation/any_event:0/dv_time"; - FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller(); - - for (TestCase testCase : Arrays.asList( - new TestCase("13:12:11", "13:12:11"), - new TestCase("13:12", "13:12"), - new TestCase("13", "13:00"), - new TestCase("13+02:00", "13:00+02:00"), - new TestCase("2022-11", null), - new TestCase("2022-11-01", null), - new TestCase("2022-11-01T13", null))) { - flat.put(key, testCase.input); - String json = ArchieObjectMapperProvider.getObjectMapper().writeValueAsString(flat); - Composition actual; - try { - actual = cut.unmarshal(json, webTemplate); - } catch (UnmarshalException ex) { - if (testCase.expected != null) { - Assertions.fail("should not have failed", ex); - } - return; - } - if (testCase.expected == null) { - Assertions.fail(testCase.input + " should have failed"); - return; - } - assertThat(actual).isNotNull(); - Element element = (Element) - actual.itemAtPath( - "/content[openEHR-EHR-SECTION.conformance_section.v0]/items[openEHR-EHR-OBSERVATION.conformance_observation.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0012]"); - assertThat(element).isNotNull(); - DvTime time = (DvTime) element.getValue(); - assertThat(time.getValue().toString()).isEqualTo(testCase.expected); - } + + flat.put(key, input); + String json = mapper.writeValueAsString(flat); + + Composition composition = new FlatJsonUnmarshaller().unmarshal(json, webTemplate); + DvTime time = (DvTime) + composition.itemAtPath( + "/content[openEHR-EHR-SECTION.conformance_section.v0]/items[openEHR-EHR-OBSERVATION.conformance_observation.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0012]/value"); + assertThat(time.getValue()).hasToString(expected); } - @Test - public void DvDateTest() throws Exception { - var optTemplate = TemplateDocument.Factory.parse(OperationalTemplateTestData.CONFORMANCE.getStream()) - .getTemplate(); - var webTemplate = new OPTParser(optTemplate).parse(); - Map flat = getKeyValueFromFlatJson( - CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_DATA_TYPES_DV_DATE_TIME.getStream()); + @ParameterizedTest + @ValueSource(strings = {"2022-11-01T13", "13:00:00", "T13"}) + void invalidDvDateTest(String input) throws Exception { + + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.CONFORMANCE); + Map flat = + flatCompostionMap(CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_DATA_TYPES_DV_DATE_TIME); String key = "conformance-ehrbase.de.v0/conformance_section/conformance_observation/any_event:0/dv_date"; - FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller(); - - for (TestCase testCase : Arrays.asList( - new TestCase("2022-11-01", "2022-11-01"), - new TestCase("2022-11", "2022-11"), - new TestCase("2022", "2022"), - new TestCase("2022-11-01T13", null), - new TestCase("13:00:00", null), - new TestCase("T13", null))) { - flat.put(key, testCase.input); - String json = ArchieObjectMapperProvider.getObjectMapper().writeValueAsString(flat); - Composition actual; - try { - actual = cut.unmarshal(json, webTemplate); - } catch (UnmarshalException ex) { - if (testCase.expected != null) { - Assertions.fail("should not have failed", ex); - } - return; - } - if (testCase.expected == null) { - Assertions.fail(testCase.input + " should have failed"); - return; - } - assertThat(actual).isNotNull(); - Element element = (Element) - actual.itemAtPath( - "/content[openEHR-EHR-SECTION.conformance_section.v0]/items[openEHR-EHR-OBSERVATION.conformance_observation.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0013]"); - assertThat(element).isNotNull(); - DvDate date = (DvDate) element.getValue(); - assertThat(date.getValue().toString()).isEqualTo(testCase.expected); + + flat.put(key, input); + String json = mapper.writeValueAsString(flat); + + FlatJsonUnmarshaller unmarshaller = new FlatJsonUnmarshaller(); + assertThatThrownBy(() -> unmarshaller.unmarshal(json, webTemplate)) + .isInstanceOf(UnmarshalException.class) + .hasMessageContaining("Text '%s' could not be parsed".formatted(input)); + } + + @ParameterizedTest + @CsvSource( + textBlock = + """ + 2022-11-01|2022-11-01 + 2022-11|2022-11 + 2022|2022 + """, + delimiterString = "|") + void validDvDateTest(String input, String expected) throws Exception { + + WebTemplate webTemplate = webTemplateFromOTP(OperationalTemplateTestData.CONFORMANCE); + Map flat = + flatCompostionMap(CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_DATA_TYPES_DV_DATE_TIME); + + String key = "conformance-ehrbase.de.v0/conformance_section/conformance_observation/any_event:0/dv_date"; + + flat.put(key, input); + String json = mapper.writeValueAsString(flat); + + Composition composition = new FlatJsonUnmarshaller().unmarshal(json, webTemplate); + DvDate date = (DvDate) + composition.itemAtPath( + "/content[openEHR-EHR-SECTION.conformance_section.v0]/items[openEHR-EHR-OBSERVATION.conformance_observation.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0013]/value"); + assertThat(date.getValue()).hasToString(expected); + } + + // -- Helper -- + + private static WebTemplate webTemplateFromOTP(OperationalTemplateTestData data) { + WebTemplate webTemplate = null; + try (var in = data.getStream()) { + OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(in).getTemplate(); + webTemplate = new OPTParser(template).parse(); + assertThat(webTemplate).isNotNull(); + } catch (Exception e) { + fail(e); } + return webTemplate; } - private static class TestCase { - public final String input; - public final String expected; + private static Composition unmarshallComposition( + CompositionTestDataSimSDTJsonInterface data, OperationalTemplateTestData templateData) { + WebTemplate webTemplate = webTemplateFromOTP(templateData); + return unmarshallComposition(data, webTemplate); + } - public TestCase(String input, String expected) { - this.input = input; - this.expected = expected; + private static Composition unmarshallComposition( + CompositionTestDataSimSDTJsonInterface data, WebTemplate webTemplate) { + Composition composition = null; + try (var in = data.getStream()) { + String content = IOUtils.toString(in, StandardCharsets.UTF_8); + composition = unmarshallComposition(content, webTemplate); + } catch (Exception e) { + fail(e); } + return composition; } - private Map getKeyValueFromFlatJson(InputStream in) throws IOException { + private static Composition unmarshallComposition(String flatJson, WebTemplate webTemplate) { + + return new FlatJsonUnmarshaller().unmarshal(flatJson, webTemplate); + } + + private Map flatCompostionMap(CompositionTestDataSimSDTJsonInterface data) { Map currentValues = new HashMap<>(); - for (Iterator> it = ArchieObjectMapperProvider.getObjectMapper() - .readTree(IOUtils.toString(in, StandardCharsets.UTF_8)) - .fields(); - it.hasNext(); ) { - Map.Entry e = it.next(); - currentValues.put(e.getKey(), e.getValue().textValue()); + try (var in = data.getStream()) { + for (Iterator> it = ArchieObjectMapperProvider.getObjectMapper() + .readTree(IOUtils.toString(in, StandardCharsets.UTF_8)) + .fields(); + it.hasNext(); ) { + Map.Entry e = it.next(); + currentValues.put(e.getKey(), e.getValue().textValue()); + } + } catch (Throwable e) { + fail(e); } return currentValues; } diff --git a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/structured/StructuredHelperTest.java b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/structured/StructuredHelperTest.java index e3ece8180..410a55a8d 100644 --- a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/structured/StructuredHelperTest.java +++ b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/flatencoding/structured/StructuredHelperTest.java @@ -17,8 +17,6 @@ */ package org.ehrbase.openehr.sdk.serialisation.flatencoding.structured; -import static org.ehrbase.openehr.sdk.serialisation.flatencoding.std.marshal.FlatJsonMarshallerTest.compere; - import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.List; @@ -27,18 +25,19 @@ import org.ehrbase.openehr.sdk.serialisation.RMDataFormat; import org.ehrbase.openehr.sdk.serialisation.flatencoding.FlatFormat; import org.ehrbase.openehr.sdk.serialisation.flatencoding.FlatJasonProvider; +import org.ehrbase.openehr.sdk.serialisation.flatencoding.FlatTestHelper; import org.ehrbase.openehr.sdk.serialisation.templateprovider.TestDataTemplateProvider; import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataSimSDTJson; import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataStructuredJson; import org.ehrbase.openehr.sdk.test_data.operationaltemplate.OperationalTemplateTestData; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; -public class StructuredHelperTest { +class StructuredHelperTest { @Test - public void convert() throws IOException { + void convert() throws IOException { CompositionTestDataStructuredJson structuredJson = CompositionTestDataStructuredJson.CORONA; CompositionTestDataSimSDTJson simSDTJson = CompositionTestDataSimSDTJson.CORONA; @@ -48,7 +47,7 @@ public void convert() throws IOException { } @Test - public void convertRevert() throws IOException { + void convertRevert() throws IOException { CompositionTestDataStructuredJson structuredJson = CompositionTestDataStructuredJson.CORONA; CompositionTestDataSimSDTJson simSDTJson = CompositionTestDataSimSDTJson.CORONA; @@ -68,7 +67,7 @@ private void testFlatToStructured( } @Test - public void convertMultiList() throws IOException { + void convertMultiList() throws IOException { CompositionTestDataStructuredJson structuredJson = CompositionTestDataStructuredJson.MULTI_LIST; CompositionTestDataSimSDTJson simSDTJson = CompositionTestDataSimSDTJson.MULTI_LIST; @@ -78,7 +77,7 @@ public void convertMultiList() throws IOException { } @Test - public void convertRevertMultiList() throws IOException { + void convertRevertMultiList() throws IOException { CompositionTestDataStructuredJson structuredJson = CompositionTestDataStructuredJson.MULTI_LIST; CompositionTestDataSimSDTJson simSDTJson = CompositionTestDataSimSDTJson.MULTI_LIST; @@ -100,7 +99,7 @@ private void testStructuredToFlat( RMDataFormat flatJson = new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT, templateId); - List errors = compere(flatJson.marshal(flatJson.unmarshal(actual)), expected); + List errors = FlatTestHelper.compere(flatJson.marshal(flatJson.unmarshal(actual)), expected); SoftAssertions softAssertions = new SoftAssertions(); diff --git a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/jsonencoding/CanonicalJsonMarshallingTest.java b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/jsonencoding/CanonicalJsonMarshallingTest.java index db8299ebd..dab384e70 100644 --- a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/jsonencoding/CanonicalJsonMarshallingTest.java +++ b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/jsonencoding/CanonicalJsonMarshallingTest.java @@ -41,12 +41,12 @@ import java.util.ArrayList; import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class CanonicalJsonMarshallingTest { +class CanonicalJsonMarshallingTest { @Test - public void UnmarshalMultimedia() throws IOException { + void UnmarshalMultimedia() throws IOException { String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/multimedia.json"))); @@ -57,7 +57,7 @@ public void UnmarshalMultimedia() throws IOException { } @Test - public void UnmarshalMultimediaElement() throws IOException { + void UnmarshalMultimediaElement() throws IOException { String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/element_multimedia.json"))); @@ -69,7 +69,7 @@ public void UnmarshalMultimediaElement() throws IOException { } @Test - public void UnmarshalItemTree() throws IOException { + void UnmarshalItemTree() throws IOException { String value = new String( Files.readAllBytes(Paths.get("src/test/resources/sample_data/item_tree_with_multimedia.json"))); @@ -81,7 +81,7 @@ public void UnmarshalItemTree() throws IOException { } @Test - public void UnmarshalPartialDate() throws IOException { + void UnmarshalPartialDate() throws IOException { String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/partialdvdate.json"))); @@ -94,7 +94,7 @@ public void UnmarshalPartialDate() throws IOException { } @Test - public void MarshalDuration() { + void MarshalDuration() { DvDuration duration = new DvDuration(Duration.ofDays(30L)); CanonicalJson cut = new CanonicalJson(); String actual = cut.marshal(duration); @@ -103,7 +103,7 @@ public void MarshalDuration() { } @Test - public void MarshalEmptyDvText() { + void MarshalEmptyDvText() { DvText dvText = new DvText(""); CanonicalJson cut = new CanonicalJson(); String actual = cut.marshal(dvText); @@ -112,7 +112,7 @@ public void MarshalEmptyDvText() { } @Test - public void MarshalDvDateTimeWithZero() { + void MarshalDvDateTimeWithZero() { DvDateTime dvDateTime = new DvDateTime("2022-02-25T10:55:41.400Z"); CanonicalJson cut = new CanonicalJson(); String actual = cut.marshal(dvDateTime); @@ -124,7 +124,7 @@ public void MarshalDvDateTimeWithZero() { } @Test - public void MarshalDvTimeWithZero() { + void MarshalDvTimeWithZero() { DvTime dvTime = new DvTime("10:55:41.400Z"); CanonicalJson cut = new CanonicalJson(); String actual = cut.marshal(dvTime); @@ -134,7 +134,7 @@ public void MarshalDvTimeWithZero() { } @Test - public void MarshalEmptyContent() { + void MarshalEmptyContent() { ItemTree itemTree = new ItemTree(); itemTree.setNameAsString("test"); CanonicalJson cut = new CanonicalJson(); @@ -150,7 +150,7 @@ public void MarshalEmptyContent() { } @Test - public void UnmarshalPartialDateTime() throws IOException { + void UnmarshalPartialDateTime() throws IOException { String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/partialdvdatetime.json"))); @@ -165,7 +165,7 @@ public void UnmarshalPartialDateTime() throws IOException { } @Test - public void marshallContribution() { + void marshallContribution() { List> versions = new ArrayList<>(); versions.add(new ObjectRef<>( new HierObjectId("COMPOSITION"), @@ -184,7 +184,7 @@ public void marshallContribution() { } @Test - public void marshallEhr() { + void marshallEhr() { List> compositions = new ArrayList<>(); compositions.add(new ObjectRef<>( new HierObjectId("COMPOSITION"), @@ -215,7 +215,7 @@ public void marshallEhr() { // check that dot is not converted into a comma! @Test - public void MarshalDvDateTime() { + void MarshalDvDateTime() { DvDateTime dvDateTime = new DvDateTime("2021-10-01T10:32:51.543+07:00"); CanonicalJson cut = new CanonicalJson(); String actual = cut.marshal(dvDateTime); diff --git a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/walker/WalkerTest.java b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/walker/WalkerTest.java index 48072b893..4c0847ef8 100644 --- a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/walker/WalkerTest.java +++ b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/walker/WalkerTest.java @@ -31,14 +31,14 @@ import org.ehrbase.openehr.sdk.webtemplate.model.FilteredWebTemplate; import org.ehrbase.openehr.sdk.webtemplate.model.WebTemplate; import org.ehrbase.openehr.sdk.webtemplate.parser.OPTParser; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openehr.schemas.v1.OPERATIONALTEMPLATE; import org.openehr.schemas.v1.TemplateDocument; -public class WalkerTest { +class WalkerTest { @Test - public void testClone() throws IOException, XmlException { + void testClone() throws IOException, XmlException { OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( OperationalTemplateTestData.CORONA_ANAMNESE.getStream()) diff --git a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/walker/defaultvalues/DefaultValuesTest.java b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/walker/defaultvalues/DefaultValuesTest.java index cd322464b..c4d5580ff 100644 --- a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/walker/defaultvalues/DefaultValuesTest.java +++ b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/walker/defaultvalues/DefaultValuesTest.java @@ -42,14 +42,14 @@ import org.ehrbase.openehr.sdk.test_data.operationaltemplate.OperationalTemplateTestData; import org.ehrbase.openehr.sdk.webtemplate.model.WebTemplate; import org.ehrbase.openehr.sdk.webtemplate.parser.OPTParser; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openehr.schemas.v1.OPERATIONALTEMPLATE; import org.openehr.schemas.v1.TemplateDocument; -public class DefaultValuesTest { +class DefaultValuesTest { @Test - public void test() throws IOException { + void test() throws IOException { Map currentValues = new HashMap<>(); for (Iterator> it = ArchieObjectMapperProvider.getObjectMapper() .readTree(IOUtils.toString( @@ -99,7 +99,7 @@ public void test() throws IOException { } @Test - public void unmarshal() throws IOException, XmlException { + void unmarshal() throws IOException, XmlException { OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( OperationalTemplateTestData.CORONA_ANAMNESE.getStream()) diff --git a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/xmlencoding/CanonicalXMLTest.java b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/xmlencoding/CanonicalXMLTest.java index a5da9d9f0..0199834b0 100644 --- a/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/xmlencoding/CanonicalXMLTest.java +++ b/serialisation/src/test/java/org/ehrbase/openehr/sdk/serialisation/xmlencoding/CanonicalXMLTest.java @@ -28,12 +28,12 @@ import javax.xml.namespace.QName; import org.apache.commons.io.IOUtils; import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalXML; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class CanonicalXMLTest { +class CanonicalXMLTest { @Test - public void marshal() throws IOException { + void marshal() throws IOException { String value = IOUtils.toString(CompositionTestDataCanonicalXML.ALL_TYPES.getStream(), UTF_8); CanonicalXML cut = new CanonicalXML(); @@ -46,7 +46,7 @@ public void marshal() throws IOException { } @Test - public void unmarshal() throws IOException { + void unmarshal() throws IOException { String value = IOUtils.toString(CompositionTestDataCanonicalXML.ALL_TYPES.getStream(), UTF_8); CanonicalXML cut = new CanonicalXML(); @@ -57,7 +57,7 @@ public void unmarshal() throws IOException { } @Test - public void unmarshalWithDefaultSchema() throws IOException { + void unmarshalWithDefaultSchema() throws IOException { String value = IOUtils.toString(CompositionTestDataCanonicalXML.DIADEM_DEFAULT_SCHEMA.getStream(), UTF_8); CanonicalXML cut = new CanonicalXML(); @@ -69,7 +69,7 @@ public void unmarshalWithDefaultSchema() throws IOException { } @Test - public void unmarshalWithDuplicatedSections() throws IOException { + void unmarshalWithDuplicatedSections() throws IOException { String value = IOUtils.toString(CompositionTestDataCanonicalXML.REGISTRO_DE_ATENDIMENTO.getStream(), UTF_8); CanonicalXML cut = new CanonicalXML(); @@ -81,7 +81,7 @@ public void unmarshalWithDuplicatedSections() throws IOException { } @Test - public void marshalInline() { + void marshalInline() { Folder folder = new Folder(); folder.setName(new DvText("folder name")); folder.addItem(new PartyRef()); From e5963df513cd554b19d8a736446b1ee5527dd433 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 08:45:20 +0200 Subject: [PATCH 3/5] Bump org.testcontainers:testcontainers from 1.19.7 to 1.20.0 (#623) Bumps [org.testcontainers:testcontainers](https://github.com/testcontainers/testcontainers-java) from 1.19.7 to 1.20.0. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.7...1.20.0) --- updated-dependencies: - dependency-name: org.testcontainers:testcontainers dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom/pom.xml b/bom/pom.xml index 98c9f5ce4..fc69bbcfd 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -356,7 +356,7 @@ org.testcontainers testcontainers - 1.19.7 + 1.20.0 test From 5921b4762e2f5a72eb8d8087e395bb2a3edabe26 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 08:53:13 +0200 Subject: [PATCH 4/5] Bump org.apache.maven:maven-core from 3.9.6 to 3.9.8 (#619) Bumps [org.apache.maven:maven-core](https://github.com/apache/maven) from 3.9.6 to 3.9.8. - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.9.6...maven-3.9.8) --- updated-dependencies: - dependency-name: org.apache.maven:maven-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- generator-maven-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator-maven-plugin/pom.xml b/generator-maven-plugin/pom.xml index dc9239272..eb34a45c6 100644 --- a/generator-maven-plugin/pom.xml +++ b/generator-maven-plugin/pom.xml @@ -38,7 +38,7 @@ org.apache.maven maven-core - 3.9.6 + 3.9.8 provided From c69259da35ced9ad7c607ea560c68770993bfd88 Mon Sep 17 00:00:00 2001 From: bot Date: Wed, 24 Jul 2024 14:23:50 +0000 Subject: [PATCH 5/5] release 2.15.0: updated version to 2.15.0 --- CHANGELOG.md | 4 ++-- aql/pom.xml | 2 +- bom/pom.xml | 2 +- client/pom.xml | 2 +- example-generator/pom.xml | 2 +- generator-commons/pom.xml | 2 +- generator-maven-plugin/pom.xml | 2 +- generator/pom.xml | 2 +- opt-1.4/pom.xml | 2 +- pom.xml | 4 ++-- response-dto/pom.xml | 2 +- serialisation/pom.xml | 2 +- serialisation_conformance_test/pom.xml | 2 +- terminology/pom.xml | 2 +- test-coverage/pom.xml | 2 +- test-data/pom.xml | 2 +- util/pom.xml | 2 +- validation/pom.xml | 2 +- web-template/pom.xml | 2 +- 19 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c551b7c0c..6dc4cba17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Note: version releases in the 0.x.y range may introduce breaking changes. -## [unreleased] +## [2.15.0] ### Added ### Fixed - Fix flat format parsing of `ObjectVersionId` ([622](https://github.com/ehrbase/openEHR_SDK/pull/622)) @@ -427,4 +427,4 @@ Note: version releases in the 0.x.y range may introduce breaking changes. [2.12.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.11.0...v2.12.0 [2.13.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.12.0...v2.13.0 [2.14.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.13.0...v2.14.0 -[unreleased]: https://github.com/ehrbase/openEHR_SDK/compare/v2.14.0...HEAD +[2.15.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.14.0...v2.15.0 diff --git a/aql/pom.xml b/aql/pom.xml index 829621273..49758e409 100644 --- a/aql/pom.xml +++ b/aql/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 aql diff --git a/bom/pom.xml b/bom/pom.xml index fc69bbcfd..0322ec4e7 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -8,7 +8,7 @@ bom org.ehrbase.openehr.sdk - 2.15.0-SNAPSHOT + 2.15.0 pom openEHR SDK diff --git a/client/pom.xml b/client/pom.xml index 6050b9f91..98a753736 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 client diff --git a/example-generator/pom.xml b/example-generator/pom.xml index eba869ccc..fac8a7fb4 100644 --- a/example-generator/pom.xml +++ b/example-generator/pom.xml @@ -5,7 +5,7 @@ sdk-parent org.ehrbase.openehr.sdk - 2.15.0-SNAPSHOT + 2.15.0 4.0.0 diff --git a/generator-commons/pom.xml b/generator-commons/pom.xml index 9764074aa..e8835360e 100644 --- a/generator-commons/pom.xml +++ b/generator-commons/pom.xml @@ -6,7 +6,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 generator-commons diff --git a/generator-maven-plugin/pom.xml b/generator-maven-plugin/pom.xml index eb34a45c6..a028644b1 100644 --- a/generator-maven-plugin/pom.xml +++ b/generator-maven-plugin/pom.xml @@ -5,7 +5,7 @@ sdk-parent org.ehrbase.openehr.sdk - 2.15.0-SNAPSHOT + 2.15.0 4.0.0 diff --git a/generator/pom.xml b/generator/pom.xml index 89d0b064a..4572dbe41 100644 --- a/generator/pom.xml +++ b/generator/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 generator diff --git a/opt-1.4/pom.xml b/opt-1.4/pom.xml index 10282fd95..ae8405467 100644 --- a/opt-1.4/pom.xml +++ b/opt-1.4/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 opt-1.4 diff --git a/pom.xml b/pom.xml index bea29c310..b810b2b4b 100644 --- a/pom.xml +++ b/pom.xml @@ -25,13 +25,13 @@ org.ehrbase.openehr.sdk bom - 2.15.0-SNAPSHOT + 2.15.0 ./bom/pom.xml org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 pom openEHR SDK diff --git a/response-dto/pom.xml b/response-dto/pom.xml index 24cb4058f..0d1e29ee6 100644 --- a/response-dto/pom.xml +++ b/response-dto/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 response-dto diff --git a/serialisation/pom.xml b/serialisation/pom.xml index 3fd6df13f..01e3f79a9 100644 --- a/serialisation/pom.xml +++ b/serialisation/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 serialisation diff --git a/serialisation_conformance_test/pom.xml b/serialisation_conformance_test/pom.xml index f2e957549..4a151b20b 100644 --- a/serialisation_conformance_test/pom.xml +++ b/serialisation_conformance_test/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 serialisation_conformance_test diff --git a/terminology/pom.xml b/terminology/pom.xml index 820b83147..432537ed7 100644 --- a/terminology/pom.xml +++ b/terminology/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 terminology diff --git a/test-coverage/pom.xml b/test-coverage/pom.xml index da82cf062..03f3536eb 100644 --- a/test-coverage/pom.xml +++ b/test-coverage/pom.xml @@ -8,7 +8,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 test-coverage diff --git a/test-data/pom.xml b/test-data/pom.xml index 9c1128aca..6e439ff78 100644 --- a/test-data/pom.xml +++ b/test-data/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 test-data diff --git a/util/pom.xml b/util/pom.xml index c1c6b1dd7..4d697dcad 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 util diff --git a/validation/pom.xml b/validation/pom.xml index ba60f7e0b..caf7108d4 100644 --- a/validation/pom.xml +++ b/validation/pom.xml @@ -24,7 +24,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 validation diff --git a/web-template/pom.xml b/web-template/pom.xml index 7140305a6..5f01e8d8d 100644 --- a/web-template/pom.xml +++ b/web-template/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.15.0-SNAPSHOT + 2.15.0 web-template