From 68752a3c3b1837d3d2ac05b2ba90a8627b4d360e Mon Sep 17 00:00:00 2001 From: bot Date: Thu, 29 Feb 2024 08:57:02 +0000 Subject: [PATCH 1/5] updated version to 2.9.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 6159323a9..9f556b9a3 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.8.0] ### Added ### Fixed @@ -381,3 +385,4 @@ Note: version releases in the 0.x.y range may introduce breaking changes. [2.6.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.5.0...v2.6.0 [2.7.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.6.0...v2.7.0 [2.8.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.7.0...v2.8.0 +[unreleased]: https://github.com/ehrbase/openEHR_SDK/compare/v2.8.0...HEAD diff --git a/aql/pom.xml b/aql/pom.xml index c96ba4c7c..661f72357 100644 --- a/aql/pom.xml +++ b/aql/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT aql diff --git a/bom/pom.xml b/bom/pom.xml index 4d0175a3d..745456e47 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -8,7 +8,7 @@ bom org.ehrbase.openehr.sdk - 2.8.0 + 2.9.0-SNAPSHOT pom openEHR SDK diff --git a/client/pom.xml b/client/pom.xml index a53d55b56..593fb5d70 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT client diff --git a/example-generator/pom.xml b/example-generator/pom.xml index 56f0804d1..13cf3d519 100644 --- a/example-generator/pom.xml +++ b/example-generator/pom.xml @@ -5,7 +5,7 @@ sdk-parent org.ehrbase.openehr.sdk - 2.8.0 + 2.9.0-SNAPSHOT 4.0.0 diff --git a/generator-commons/pom.xml b/generator-commons/pom.xml index e079ad0f0..f5ca2cb47 100644 --- a/generator-commons/pom.xml +++ b/generator-commons/pom.xml @@ -6,7 +6,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT generator-commons diff --git a/generator-maven-plugin/pom.xml b/generator-maven-plugin/pom.xml index 2e4f8a107..450b124c0 100644 --- a/generator-maven-plugin/pom.xml +++ b/generator-maven-plugin/pom.xml @@ -5,7 +5,7 @@ sdk-parent org.ehrbase.openehr.sdk - 2.8.0 + 2.9.0-SNAPSHOT 4.0.0 diff --git a/generator/pom.xml b/generator/pom.xml index 86d80afd0..22ef50c27 100644 --- a/generator/pom.xml +++ b/generator/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT generator diff --git a/opt-1.4/pom.xml b/opt-1.4/pom.xml index 6a1029e42..ce6b33b8d 100644 --- a/opt-1.4/pom.xml +++ b/opt-1.4/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT opt-1.4 diff --git a/pom.xml b/pom.xml index c37c7b899..7569bfc27 100644 --- a/pom.xml +++ b/pom.xml @@ -25,13 +25,13 @@ org.ehrbase.openehr.sdk bom - 2.8.0 + 2.9.0-SNAPSHOT ./bom/pom.xml org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT pom openEHR SDK diff --git a/response-dto/pom.xml b/response-dto/pom.xml index 0ac0900b5..84ee610c6 100644 --- a/response-dto/pom.xml +++ b/response-dto/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT response-dto diff --git a/serialisation/pom.xml b/serialisation/pom.xml index 1af8a1a45..cf519be01 100644 --- a/serialisation/pom.xml +++ b/serialisation/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT serialisation diff --git a/serialisation_conformance_test/pom.xml b/serialisation_conformance_test/pom.xml index 844375a15..cad915d8f 100644 --- a/serialisation_conformance_test/pom.xml +++ b/serialisation_conformance_test/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT serialisation_conformance_test diff --git a/terminology/pom.xml b/terminology/pom.xml index 35fafbe2c..bc16493f0 100644 --- a/terminology/pom.xml +++ b/terminology/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT terminology diff --git a/test-coverage/pom.xml b/test-coverage/pom.xml index d11902532..51bb8227d 100644 --- a/test-coverage/pom.xml +++ b/test-coverage/pom.xml @@ -8,7 +8,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT test-coverage diff --git a/test-data/pom.xml b/test-data/pom.xml index bf28415aa..779adceca 100644 --- a/test-data/pom.xml +++ b/test-data/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT test-data diff --git a/util/pom.xml b/util/pom.xml index 333d92073..19aba13ec 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT util diff --git a/validation/pom.xml b/validation/pom.xml index 552202043..8eb605ff7 100644 --- a/validation/pom.xml +++ b/validation/pom.xml @@ -24,7 +24,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT validation diff --git a/web-template/pom.xml b/web-template/pom.xml index 84e510fec..554661e75 100644 --- a/web-template/pom.xml +++ b/web-template/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.8.0 + 2.9.0-SNAPSHOT web-template From 84940bf50c3a130ecf3bb5f0618ca2f087c5ebe9 Mon Sep 17 00:00:00 2001 From: Alex Vidrean Date: Thu, 29 Feb 2024 11:24:15 +0200 Subject: [PATCH 2/5] Fix nexus url to use s01 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7569bfc27..e3a2334ae 100644 --- a/pom.xml +++ b/pom.xml @@ -256,7 +256,7 @@ true ossrh - https://oss.sonatype.org/ + https://s01.oss.sonatype.org/ true 30 From 157ff1c7040166d4b9210797402084c1b9232d74 Mon Sep 17 00:00:00 2001 From: Holger Reise Date: Thu, 21 Mar 2024 14:32:00 +0100 Subject: [PATCH 3/5] Clean up license header --- .../sdk/aql/parser/AqlQueryVisitorTest.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/aql/src/test/java/org/ehrbase/openehr/sdk/aql/parser/AqlQueryVisitorTest.java b/aql/src/test/java/org/ehrbase/openehr/sdk/aql/parser/AqlQueryVisitorTest.java index a46e71f18..fb1459de5 100644 --- a/aql/src/test/java/org/ehrbase/openehr/sdk/aql/parser/AqlQueryVisitorTest.java +++ b/aql/src/test/java/org/ehrbase/openehr/sdk/aql/parser/AqlQueryVisitorTest.java @@ -21,22 +21,6 @@ import org.junit.jupiter.api.Test; -/* - * Copyright (c) 2022. vitasystems GmbH and Hannover Medical School. - * - * 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. - */ - class AqlQueryVisitorTest { @Test From b9c14122687eb1034c2b6b9ea9700b3e3c874f7e Mon Sep 17 00:00:00 2001 From: stefanspiska Date: Tue, 2 Apr 2024 09:51:13 +0200 Subject: [PATCH 4/5] move to testcontainer (#575) --- .circleci/config.yml | 1778 ----------------- .github/workflows/build.yml | 36 +- .github/workflows/publish.yml | 56 + bom/pom.xml | 12 + client/pom.xml | 10 + .../defaultrestclient/AqlTestIT.java | 744 ------- .../defaultrestclient/CoronaTestIT.java | 510 ----- .../DefaultDirectoryCrudEndpointTestIT.java | 33 +- .../DefaultRestAdminEhrEndpointIT.java | 28 +- .../DefaultRestAqlEndpointTestIT.java | 45 +- .../DefaultRestCompositionEndpointIT.java | 58 +- .../DefaultRestContributionEndpointIT.java | 30 +- .../DefaultRestDirectoryEndpointIT.java | 38 +- .../DefaultRestEhrFieldsEndpointIT.java | 32 +- .../DefaultRestTemplateEndpointIT.java | 33 +- ...ultRestVersionedCompositionEndpointIT.java | 204 +- .../defaultrestclient/EHRbaseContainer.java | 81 + .../EHRbasePostgresContainer.java | 72 + .../OtherParticipationsQueryTestIT.java | 91 - .../ParticipationTestIT.java | 182 -- ...ntTestHelper.java => SdkClientTestIT.java} | 59 +- .../systematic/CanonicalUtil.java | 216 -- .../systematic/CanonicalUtilTest.java | 59 - .../systematic/SpecialCase.java | 53 - .../CompareCanonicalHierObjects.java | 41 - .../systematic/comparator/EhrComparator.java | 65 - .../comparator/EhrStatusComparator.java | 55 - .../datetime/CompareCanonicalDvDate.java | 46 - .../datetime/CompareCanonicalDvDateTime.java | 75 - .../CompareCanonicalDvDateTimeTest.java | 69 - .../datetime/CompareCanonicalDvTime.java | 59 - .../datetime/DatePartComparator.java | 29 - .../datetime/TimePartComparator.java | 29 - .../datetime/ZoneOffsetPartComparator.java | 29 - .../ArbitraryQueryDateTimeIT.java | 48 - .../ArbitraryQueryFeederAuditIT.java | 73 - .../compositionquery/ArbitraryQueryIT.java | 56 - .../ArbitraryQueryOtherContextIT.java | 84 - .../compositionquery/AutoWhereIT.java | 141 -- .../CanonicalCompoAllTypeQueryIT.java | 85 - ...anonicalMinimalInstructionTypeQueryIT.java | 167 -- .../CartesianProductQueryIT.java | 121 -- .../FeederAuditQueryWithWhereIT.java | 56 - .../compositionquery/NumericTestsIT.java | 82 - .../compositionquery/SelectFeederAuditIT.java | 77 - .../compositionquery/SelectRMIT.java | 191 -- .../queries/AqlExpressionBuilder.java | 72 - .../queries/ParserSettings.java | 42 - .../queries/TestQueryEngine.java | 327 --- .../arbitrary/ArbitraryExpression.java | 53 - .../ArbitraryExpressionSettings.java | 38 - .../queries/arbitrary/ArbitraryQuery.java | 39 - .../queries/arbitrary/NumericExpression.java | 60 - .../arbitrary/NumericExpressionSettings.java | 38 - .../queries/arbitrary/NumericQuery.java | 35 - .../queries/auto/AutoEhrStatusWhereQuery.java | 36 - .../queries/auto/AutoWhereCondition.java | 49 - .../queries/auto/AutoWhereQuery.java | 37 - .../queries/simple/PathExpression.java | 37 - .../simple/SimplePathExpressionSettings.java | 37 - .../queries/simple/SimpleSelectQuery.java | 37 - .../ehrquery/CanonicalEhrQuery1IT.java | 179 -- .../ehrquery/CanonicalEhrQuery2IT.java | 123 -- .../ehrquery/CanonicalEhrQuery3IT.java | 163 -- generator-maven-plugin/pom.xml | 3 +- pom.xml | 49 - 66 files changed, 444 insertions(+), 7148 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/AqlTestIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/CoronaTestIT.java create mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/EHRbaseContainer.java create mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/EHRbasePostgresContainer.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/OtherParticipationsQueryTestIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/ParticipationTestIT.java rename client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/{DefaultRestClientTestHelper.java => SdkClientTestIT.java} (52%) delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/CanonicalUtil.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/CanonicalUtilTest.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/SpecialCase.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/CompareCanonicalHierObjects.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/EhrComparator.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/EhrStatusComparator.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDate.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDateTime.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDateTimeTest.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvTime.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/DatePartComparator.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/TimePartComparator.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/ZoneOffsetPartComparator.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryDateTimeIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryFeederAuditIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryOtherContextIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/AutoWhereIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CanonicalCompoAllTypeQueryIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CanonicalMinimalInstructionTypeQueryIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CartesianProductQueryIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/FeederAuditQueryWithWhereIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/NumericTestsIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/SelectFeederAuditIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/SelectRMIT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/AqlExpressionBuilder.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/ParserSettings.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/TestQueryEngine.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryExpression.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryExpressionSettings.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryQuery.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericExpression.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericExpressionSettings.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericQuery.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoEhrStatusWhereQuery.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoWhereCondition.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoWhereQuery.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/PathExpression.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/SimplePathExpressionSettings.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/SimpleSelectQuery.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery1IT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery2IT.java delete mode 100644 client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery3IT.java diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 0f815b26e..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,1778 +0,0 @@ -version: 2.1 - -# OVERVIEW - What this CI pipeline does: -# 1. build & test the SDK -# 2. build & test EHRbase w/ SDK (as local dependency) -# 3. conduct (static) code analysis w/ Sonar scanner and send results to sonarcloud.io -# - this includes code coverage from unit & integration tests (written in Java) -# 4. run Robot integation tests (from EHRbase's repo) -# 5. publish git tag based snapshot & release versions on jitpack.io -# - requires manually creating a release (via Github UI) from a given git tag -# - jitpack will build related artifacts on demand - -# QUALITY GATE I for fast feedback -# - builds and tests SDK as fast as possible for fast feedback -# - ehrbase build w/o any tests (mvn even doesn't compile any test code) -# - no Jacoco code instrumentation -# - no code coverage metrics and related storage/upload of artifacts -# - no Java Doc generation -# - needs less than 50% of time before Robot integration test can start than would be the case in Quality Gate 2 - -# QUALITY GATE II for indepth test and analysis -# - Jacoco code instrumentation enabled to get coverage metrics -# - ehrbase builds with tests enabled -# - Java docs generation enabled -# - Sonar code analysis enabled and results uploaded to sonarcloud.io -# - TODO: enable scheduled execution(?) -# - TODO: add security test suite(?) - - - -workflows: - - # WORKFLOW 1/6) Build & Test the SDK - QUALITY-GATE-I: - jobs: - - check-codestyle: - context: org-global - filters: - branches: - ignore: - - /release\/.*/ - - master - - /sync\/.*/ - - /feature/sync\/.*/ - - build-and-test-openEHR_SDK: - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - COMPOSITION-tests-1: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - COMPOSITION-tests-2: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - COMPOSITION-tests-3: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - COMPOSITION-tests-4: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - COMPOSITION-tests-5: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - CONTRIBUTION-tests: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - DIRECTORY-tests: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - EHRSERVICE-tests: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - EHRSTATUS-tests: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - KNOWLEDGE-tests: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - QUERYSERVICE-tests-1: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - QUERYSERVICE-tests-2: - context: org-global - requires: - - build-and-test-openEHR_SDK - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - ROBOT-TEST-REPORT: - context: org-global - requires: - - COMPOSITION-tests-1 - - COMPOSITION-tests-2 - - COMPOSITION-tests-3 - - COMPOSITION-tests-4 - - COMPOSITION-tests-5 - - CONTRIBUTION-tests - - DIRECTORY-tests - - EHRSERVICE-tests - - EHRSTATUS-tests - - KNOWLEDGE-tests - - QUERYSERVICE-tests-1 - - QUERYSERVICE-tests-2 - filters: - branches: - ignore: - - master - - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - - # WORKFLOW 2/6) Publish Git tags for SNAPSHOT releases -# deploy-snapshot-release: -# when: -# and: -# - equal: [ develop, << pipeline.git.branch >> ] -# # - equal: [ SNAPSHOT, << pipeline.git.tag >> ] -# jobs: -# - publish-snapshot: -# filters: -# tags: -# ignore: -# # - /^v.*/ -# - /SNAPSHOT.*/ - - - - # WORKFLOW 3/6) Publish Git tag for (stable) releases -# deploy-stable-release: -# when: -# and: -# - equal: [ release, << pipeline.git.branch >> ] -# jobs: -# - publish-release - - - - # # WORKFLOW 4/5) Update SDK version in EHRbase's POM /w lastest stable release - # update-ehrbase-sdk-dependency: - # when: - # and: - # - equal: [ master, << pipeline.git.branch >> ] - # jobs: - # - approve-sdk-version-update: - # type: approval - # - update-ehrbase-sdk-dependency: - # requires: - # - approve-sdk-version-update - - - - # WORKFLOW 5/6) Code analysis w/ SonarCloud.io - QUALITY-GATE-II: - jobs: - - build-test-and-analyse-openEHR_SDK: - context: org-global - filters: - branches: - ignore: - - master - # - develop - - release - - /sync\/.*/ - - /feature/sync\/.*/ - - - # WORKFLOW 6/6) - synced-feature-check: - description: | - WHAT THIS WORKFLOW DOES - ======================= - - Build and run all openEHR_SDK Java tests (unit and integration tests) - with EHRbase being checked out from a branch named sync/* or sync/feature/* - - Consider the following scenarios - -------------------------------- - - code change in repo | - EHRBASE SDK | BRANCH | CI ACTION | COMMENT - --------------------|-------------------|-------------------|--------------------------------------------------------------------- - - YES NO feature/* default build ehrbase uses SDK referenced in it's parent pom.xml (commit hash) - NO YES feature/* default build sdk uses EHRBASE (built) from develop branch - - YES YES feature/* SHOULD FAIL default builds triggered on both CIs do not take into account - respective changes in the featue branch of the other repository - NOTE: if the build does NOT fail on ehrbase's and/or sdk's CI - then proper Java unit/integration tests are missing! - - YES NO sync/feature/* SHOULD FAIL ehrbase's CI fails to checkout sync/feature/* branch from sdk repo - NO YES sync/feature/* SHOULD FAIL sdk's CI fails to checkout sync/feature/* branch from ehrbase repo - - YES YES sync/feature/* synced build - ehrbase's CI uses SDK from sync/feature/* branch - - sdk's CI uses EHRBASE from sync/feature/* branch - - explanations - -------------------- - default build (ehrbase) EHRbase is build using SDK version given in it's parent pom.xml - default build (sdk) SDK is build and tested using EHRbase build from develop branch - - synced build both CIs take into account respective changes in sync/feature/* - branch of each repository - - Find detailed steps description for this workflow in - "build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK" job. - - - HOW TO USE THIS WORKFLOW? - ========================= - - 1. create TWO branches "sync/[issue-id]_name branches" respectively in - - - ehrbase repo --> i.e. sync/123_example-issue - - openehr_sdk repo --> i.e. sync/123_example-issue - - 2. apply and commit your code changes (!!! in both repositories) - 3. push to openehr_sdk repo (CI will trigger this workflow) - 4. push to ehrbase repo (ehrbase's CI will trigger a similar workflow) - - NOTE: at this point 'synced build' will be trigger on both CIs - - 5. create TWO PRs (one in ehrbase, one in openehr_sdk) - 6. merge bot PRs (WARNING): - - /////////////////////////////////////////////////////////////////////// - /// /// - /// - make sure that both PRs are reviewed and ready to be merged /// - /// at the same time! /// - /// - make sure to sync both PRs w/ develop before merging! /// - /// - open each PR in it's own browser window /// - /// - MERGE BOTH PRs AT THE SAME TIME! /// - /// /// - ////////////////////////////////////////////////////////////////////// - - jobs: - - check-codestyle: - filters: - branches: - only: - - /^sync\/.*/ - - /^feature\/sync\/.*/ - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK: - context: org-global - filters: - branches: - only: - - /^sync\/.*/ - - /^feature\/sync\/.*/ - - COMPOSITION-tests-1: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - COMPOSITION-tests-2: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - COMPOSITION-tests-3: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - COMPOSITION-tests-4: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - COMPOSITION-tests-5: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - CONTRIBUTION-tests: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - DIRECTORY-tests: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - EHRSERVICE-tests: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - EHRSTATUS-tests: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - KNOWLEDGE-tests: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - QUERYSERVICE-tests-1: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - QUERYSERVICE-tests-2: - context: org-global - requires: - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - # - SECURITY-test: - # context: org-global - # requires: - # - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - # - ADMIN-test: - # context: org-global - # requires: - # - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK - - ROBOT-TEST-REPORT: - context: org-global - requires: - - COMPOSITION-tests-1 - - COMPOSITION-tests-2 - - COMPOSITION-tests-3 - - COMPOSITION-tests-4 - - COMPOSITION-tests-5 - - CONTRIBUTION-tests - - DIRECTORY-tests - - EHRSERVICE-tests - - EHRSTATUS-tests - - KNOWLEDGE-tests - - QUERYSERVICE-tests-1 - - QUERYSERVICE-tests-2 - # - SECURITY-test - # - ADMIN-test - - - - - -jobs: - # 88 ,ad8888ba, 88888888ba ad88888ba - # 88 d8"' `"8b 88 "8b d8" "8b - # 88 d8' `8b 88 ,8P Y8, - # 88 88 88 88aaaaaa8P' `Y8aaaaa, - # 88 88 88 88""""""8b, `"""""8b, - # 88 Y8, ,8P 88 `8b `8b - # 88, ,d88 Y8a. .a8P 88 a8P Y8a a8P - # "Y8888P" `"Y8888Y"' 88888888P" "Y88888P" - - - check-codestyle: - executor: docker-python3 - steps: - - checkout - - install-java-maven - - maven-check-codestyle - - - build-and-test-openEHR_SDK: - description: Build and run all openEHR_SDK Java tests (unit and integration tests w/ EHRbase + DB running). - executor: docker-py3-postgres - steps: - - checkout - - cache-out-sdk-m2-dependencies - - build-sdk - - git-clone-ehrbase-repo - - git-clone-robot-integration-tests-repo - - cache-out-ehrbase-m2-dependencies - - force-ehrbase-build-to-use-local-sdk-version - - build-and-run-ehrbase-then-run-all-sdk-java-tests - - cache-in-ehrbase-m2-dependencies - - cache-in-sdk-m2-dependencies - - collect-sdk-unittest-results - - collect-sdk-integrationtest-results - - save-skd-test-results - - save-sdk-workspace - - - build-and-test-synced-branches-of-EHRbase-and-openEHR_SDK: - description: | - Build and run all openEHR_SDK Java tests (unit and integration tests) - w/ EHRbase being checked out from a sync/*-branch or feature/sync/*-branch - executor: docker-py3-postgres - steps: - - checkout - - cache-out-sdk-m2-dependencies - - build-sdk - - git-clone-ehrbase-repo: - branch: ${CIRCLE_BRANCH} - - git-clone-robot-integration-tests-repo - - cache-out-ehrbase-m2-dependencies - - force-ehrbase-build-to-use-local-sdk-version - - build-and-run-ehrbase-then-run-all-sdk-java-tests - - cache-in-ehrbase-m2-dependencies - - cache-in-sdk-m2-dependencies - - collect-sdk-unittest-results - - collect-sdk-integrationtest-results - - save-skd-test-results - - save-sdk-workspace - - - COMPOSITION-tests-1: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - # - start-ehrbase-server - - run-robot-tests: - include-tags: "compositionANDcomposition_create" - test-suite-path: "COMPOSITION_TESTS" - test-suite-name: "COMPOSITION_1" - - COMPOSITION-tests-2: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - - run-robot-tests: - include-tags: "compositionANDcomposition_get" - test-suite-path: "COMPOSITION_TESTS" - test-suite-name: "COMPOSITION_2" - - COMPOSITION-tests-3: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - - run-robot-tests: - include-tags: "compositionANDcomposition_get_versioned" - test-suite-path: "COMPOSITION_TESTS" - test-suite-name: "COMPOSITION_3" - - COMPOSITION-tests-4: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - - run-robot-tests: - include-tags: "compositionANDcomposition_update" - test-suite-path: "COMPOSITION_TESTS" - test-suite-name: "COMPOSITION_4" - - COMPOSITION-tests-5: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - - run-robot-tests: - include-tags: "compositionANDcomposition_delete" - test-suite-path: "COMPOSITION_TESTS" - test-suite-name: "COMPOSITION_5" - - CONTRIBUTION-tests: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - - run-robot-tests: - include-tags: "CONTRIBUTION" - test-suite-path: "CONTRIBUTION_TESTS" - test-suite-name: "CONTRIBUTION" - - DIRECTORY-tests: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - - run-robot-tests: - include-tags: "directory" - test-suite-path: "DIRECTORY_TESTS" - test-suite-name: "DIRECTORY" - - EHRSERVICE-tests: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - - run-robot-tests: - include-tags: "EHR_SERVICE" - test-suite-path: "EHR_SERVICE_TESTS" - test-suite-name: "EHR_SERVICE" - - EHRSTATUS-tests: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - - run-robot-tests: - include-tags: "EHR_STATUS" - test-suite-path: "EHR_STATUS_TESTS" - test-suite-name: "EHR_STATUS" - - KNOWLEDGE-tests: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - - run-robot-tests: - include-tags: "OPT" - test-suite-path: "KNOWLEDGE_TESTS" - test-suite-name: "KNOWLEDGE" - allow-template-overwrite: false - cache-enabled: false - - QUERYSERVICE-tests-1: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - - restore-ehrbase-workspace - - run-robot-tests: - include-tags: "aql_adhoc-queryANDaql_empty_db" - test-suite-path: "QUERY_SERVICE_TESTS" - test-suite-name: "ADHOC-QUERY-1" - - QUERYSERVICE-tests-2: - executor: machine-ubuntu-2004 - environment: - SUT: TEST - steps: - - restore-ehrbase-workspace - - restore_cache: - keys: - - expected-results-loaded-db-v8 - - run: - name: list files after restore of cache - command: | - cd ehrbase - ls -la tests/robot/_resources/test_data_sets/query/aql_queries_valid/A/ - ls -la tests/robot/_resources/test_data_sets/query/aql_queries_valid/B/ - ls -la tests/robot/_resources/test_data_sets/query/aql_queries_valid/C/ - ls -la tests/robot/_resources/test_data_sets/query/aql_queries_valid/D/ - - restore_cache: - keys: - - ehrbasedb-dump-v8 - # COMMENT: USE THE NEXT LINE ONLY TO FORCE TEST-DATA REGENERATION! Otherwise comment it out! - - run: echo "FORCE GENERATION OF TEST-DATA AND EXPECTED RESULTS!" > /tmp/DATA_CHANGED_NOTICE - - run: - name: CHECK IF EXPECTED-RESULT TEMPLATES HAVE CHANGED AND REGENERATE TEST-DATA IF NEEDED - command: | - cd ehrbase - FILE=/tmp/DATA_CHANGED_NOTICE - if [ -f "$FILE" ]; then - echo "REGENERATION OF TEST-DATA AND EXPECTED RESULT SETS IS EITHER REQUIRED OR WAS FORCED." - else - find tests/robot/_resources/test_data_sets/query/expected_results/loaded_db/ -type f ! -name *.tmp.json | sort | xargs cat > /tmp/expected-results-loaded_db-seed - sha256sum /tmp/expected-results-loaded_db-seed - ACTUAL_HASH="$(sha256sum /tmp/expected-results-loaded_db-seed | cat)" - EXPECTED_HASH="f5ee5a9a55c50687dafc3c3acff66089759f1577d7a5dd71aff6e60793ce91c2 /tmp/expected-results-loaded_db-seed" - [ "$ACTUAL_HASH" = "$EXPECTED_HASH" ] && echo "Expected results unchanged! Don't regenerate test-data!" || echo "Expected result data-sets changed. Regenerate!" > /tmp/DATA_CHANGED_NOTICE - fi - - run-robot-tests: - sut: "TEST" - include-tags: "aql_adhoc-queryANDaql_loaded_db" - test-suite-path: "QUERY_SERVICE_TESTS" - test-suite-name: "ADHOC-QUERY-2" - - save_cache: - key: expected-results-loaded-db-v8-{{ checksum "/tmp/expected-results-loaded_db-seed" }} - paths: - - ehrbase/tests/robot/_resources/test_data_sets/query/expected_results/loaded_db/ - - ehrbase/tests/robot/_resources/test_data_sets/query/aql_queries_valid/ - - run: - name: list files after save of cache - command: | - cd ehrbase - ls -la tests/robot/_resources/test_data_sets/query/aql_queries_valid/A/ - ls -la tests/robot/_resources/test_data_sets/query/aql_queries_valid/B/ - ls -la tests/robot/_resources/test_data_sets/query/aql_queries_valid/C/ - ls -la tests/robot/_resources/test_data_sets/query/aql_queries_valid/D/ - - save_cache: - key: ehrbasedb-dump-v8-{{ checksum "/tmp/ehrbasedb_dump.sql" }} - paths: - - /tmp/ehrbasedb_dump.sql - - - - ROBOT-TEST-REPORT: - executor: docker-py3-postgres - # executor: machine-ubuntu-2004 # (use for pipeline debugging only) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - # - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - # - cache-out-python-requirements # TODO: @wlad find a solution: python cache not working yet - - restore-test-results-folder - - merge-robot-outputs - - - publish-snapshot: - executor: docker-python3 - # executor: machine-ubuntu-2004 # (use for pipeline debugging only!) - description: | - Publishes a SNAPSHOT release version via jitpack.io - whenever one of these keywords: [major], [minor] or [patch] - is used in a PR's merge commit title when merging a feature branch into develop. - steps: - - checkout - - configure-git-for-ci-bot - - cache-out-versionupdater-dependencies - - update-and-publish-snapshot-release-version - - cache-in-versionupdater-dependencies - - - publish-release: - executor: docker-python3 - # executor: machine-ubuntu-2004 # (use for pipeline debugging only!) - description: | - Publishes a (stable) release version via jitpack.io - whenever a 'release' branch is pushed to remote. - steps: - - checkout - - configure-git-for-ci-bot - - cache-out-versionupdater-dependencies - - publish-release-version - - - update-ehrbase-sdk-dependency: - executor: docker-python3 - # executor: machine-ubuntu-2004 # (use for pipeline debugging only!) - steps: - #-----------------------------------#---------------(use for pipeline debugging only) - - run: echo MOCKED JOB # - # - cache-out-ehrbase-workspace # - #-----------------------------------# - # - checkout - # - configure-git-for-ci-bot - # - cache-out-versionupdater-dependencies - - - build-test-and-analyse-openEHR_SDK: - description: | - Runs code analysis w/ SonarCloud via CircleCI Orb provided by sonarsource team. - Orb documentation: https://circleci.com/orbs/registry/orb/sonarsource/sonarcloud - Scanner configuration happens in file sonar-project.properties in project's root folder. - executor: docker-py3-postgres - steps: - - checkout - - cache-out-sdk-m2-dependencies - - build-sdk - - git-clone-ehrbase-repo - - cache-out-ehrbase-m2-dependencies - - force-ehrbase-build-to-use-local-sdk-version - - build-and-run-ehrbase-then-run-all-sdk-java-tests: - skip-jacoco: false - skip-tests: false - skip-javadoc: false - - cache-in-ehrbase-m2-dependencies - - cache-in-sdk-m2-dependencies - - collect-sdk-unittest-results - - collect-sdk-integrationtest-results - - save-skd-test-results - - save-jacoco-coverage-report - - sonarcloud/scan: - cache_version: 1 # NOTE: increment this value to force cache rebuild - - - - - - - -commands: - # ,ad8888ba, ,ad8888ba, 88b d88 88b d88 db 888b 88 88888888ba, ad88888ba - # d8"' `"8b d8"' `"8b 888b d888 888b d888 d88b 8888b 88 88 `"8b d8" "8b - # d8' d8' `8b 88`8b d8'88 88`8b d8'88 d8'`8b 88 `8b 88 88 `8b Y8, - # 88 88 88 88 `8b d8' 88 88 `8b d8' 88 d8' `8b 88 `8b 88 88 88 `Y8aaaaa, - # 88 88 88 88 `8b d8' 88 88 `8b d8' 88 d8YaaaaY8b 88 `8b 88 88 88 `"""""8b, - # Y8, Y8, ,8P 88 `8b d8' 88 88 `8b d8' 88 d8""""""""8b 88 `8b 88 88 8P `8b - # Y8a. .a8P Y8a. .a8P 88 `888' 88 88 `888' 88 d8' `8b 88 `8888 88 .a8P Y8a a8P - # `"Y8888Y"' `"Y8888Y"' 88 `8' 88 88 `8' 88 d8' `8b 88 `888 88888888Y"' "Y88888P" - - - update-and-publish-snapshot-release-version: - steps: - - install-java-maven - - install-xml-cli-tool - - run: - name: Update Snapshot Release Version - command: | - echo test - last_commit="$(git log -1 --pretty=%B | cat)" - echo $last_commit - case $last_commit in - *"[major]"*) - - echo "bump major release version" - mvn17 build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.nextMajorVersion}.0.0 versions:commit - SDK_VERSION=$(xmlstarlet sel -t -m "/_:project/_:version" -v . pom.xml ) - - git commit -am "updated major version to v${SDK_VERSION}-SNAPSHOT [skip ci]" - git checkout -b major-snapshot-update - git merge --strategy=ours develop - git checkout develop - git merge major-snapshot-update - git tag -a v${SDK_VERSION}-SNAPSHOT -m "v${SDK_VERSION}-SNAPSHOT release" - git push --set-upstream origin develop v${SDK_VERSION}-SNAPSHOT - - exit 0 - ;; - *"[minor]"*) - - echo "bump minor release version" - mvn17 build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 versions:commit - SDK_VERSION=$(xmlstarlet sel -t -m "/_:project/_:version" -v . pom.xml ) - - git commit -am "updated minor version to v${SDK_VERSION}-SNAPSHOT [skip ci]" - git checkout -b minor-snapshot-update - git merge --strategy=ours develop - git checkout develop - git merge minor-snapshot-update - git tag -a v${SDK_VERSION}-SNAPSHOT -m "v${SDK_VERSION}-SNAPSHOT release" - git push --set-upstream origin develop v${SDK_VERSION}-SNAPSHOT - - exit 0 - ;; - *"[patch]"*) - - echo "bump patch release version" - mvn17 build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} versions:commit - SDK_VERSION=$(mvn17 -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec) - - git commit -am "updated patch version to v${SDK_VERSION}-SNAPSHOT [skip ci]" - git checkout -b patch-snapshot-update - git merge --strategy=ours develop - git checkout develop - git merge patch-snapshot-update - git tag -a v${SDK_VERSION}-SNAPSHOT -m "v${SDK_VERSION}-SNAPSHOT release" - git push --set-upstream origin develop v${SDK_VERSION}-SNAPSHOT - - exit 0 - ;; - *) - echo "This was just a simple merge - no versions updated" - exit 0 - ;; - esac - - - publish-release-version: - steps: - - install-java-maven - - install-xml-cli-tool - - run: - name: Create and push release version tag - description: | - Use this command only in a job that is triggered by push of a 'release' branch to remote. - Don't do any commits on that 'release' branch. Just push it! - The CI pipeline will then - - (--hard) reset 'master' to the state of 'release' branch - - and delete 'release' branch on remote - Nothing is ever merged back into develop (BECAUSE THERE IS NO NEED FOR THAT!). - Everything flows in one direction: from feature to develop from develop to master. - The idea is to have one main branch (develop) that holds everything, including releases, - and 'master' branch serves as backup of last (know as working) 'develop' branch. - Besides serving as a backup 'master' can further be used to trigger other workflows - i.e. deployments into production. - command: | - git branch - SDK_VERSION=$(xmlstarlet sel -t -m "/_:project/_:version" -v . pom.xml ) - echo $SDK_VERSION - git fetch - git checkout master - git merge release --no-ff -m "NEW RELEASE VERSION: v${SDK_VERSION} [skip ci]" - git push origin --delete release # NOTE: this deletes realse branch on remote - git tag -a v${SDK_VERSION} -m "v${SDK_VERSION} (stable) release" - git push --set-upstream origin master v${SDK_VERSION} - git checkout develop - git merge master - git push --set-upstream origin develop v${SDK_VERSION} - - - configure-git-for-ci-bot: - steps: - - add_ssh_keys: - fingerprints: - - 3e:42:46:e1:9e:40:4d:ae:33:ab:db:0a:95:24:d2:99 - - run: - name: Configure GIT - command: | - git config --global user.email "50235421+ehrbase-tech-user@users.noreply.github.com" - git config --global user.name "ci-bot" - # git config --global push.followTags true - git remote -v - - - install-xml-cli-tool: - steps: - - run: - name: Install xmlstarlet to handle XML file from CLI - command: | - sudo killall -9 apt-get || true - sudo apt -y update && sudo apt -y install xmlstarlet - - - cache-out-versionupdater-dependencies: - steps: - - restore_cache: - key: maven-dep-v1- - - cache-in-versionupdater-dependencies: - steps: - - save_cache: - key: maven-dep-v1- - paths: - - ~/.m2 - - - - - - # /////////////////////////////////////////////////////////////////////////// - # /// SDK COMMANDS /// - # /////////////////////////////////////////////////////////////////////////// - - maven-check-codestyle: - description: Run spotless plugin check goal - steps: - - run: - name: Run spotless plugin check goal - command: | - mvn17 com.diffplug.spotless:spotless-maven-plugin:check - - - build-sdk: - steps: - - install-java-maven - - install-xml-cli-tool - - run: - name: Maven build, install openEHR_SDK - command: | - mvn17 build-helper:parse-version versions:set -DnewVersion=\${project.version}-LOCAL$(cat /proc/sys/kernel/random/uuid) -DprocessAllModules=true versions:commit - mvn17 install -Dmaven.javadoc.skip=true -Djacoco.skip=true - - run: - name: Save the version number of locally installed SDK into a file - command: | - SDK_VERSION=$(xmlstarlet sel -t -m "/_:project/_:version" -v . pom.xml ) - echo $SDK_VERSION > SDK_VERSION - cat SDK_VERSION - - - build-and-test-sdk: - steps: - - install-java-maven - - install-xml-cli-tool - - run: - name: Maven build, test (ONLY unit tests), install openEHR_SDK - command: | - mvn17 build-helper:parse-version versions:set -DnewVersion=\${project.version}-LOCAL -DprocessAllModules=true versions:commit - mvn17 install dependency:go-offline -Djacoco.skip=true -Dmaven.javadoc.skip=true - - run: - name: Save the version number of locally installed SDK into a file - command: | - SDK_VERSION=$(xmlstarlet sel -t -m "/_:project/_:version" -v . pom.xml ) - echo $SDK_VERSION > SDK_VERSION - cat SDK_VERSION - - - build-and-integration-test-sdk: - description: | - WARNING: this command requires EHRbase to be up and running - steps: - - install-java-maven - - run: - name: Maven run only Java integration tests of openEHR_SDK - description: | - Runs maven test phase using 'slow' profile defined in parent pom.xml - This way only the Java integration tests are executed. - command: | - jps - mvn17 test -Pslow -Dmaven.javadoc.skip=true - - - build-and-run-ehrbase-then-run-all-sdk-java-tests: - description: | - Executes all SDK java test (unit and integration) - This requires EHRbase + DB to be running during test execution. - parameters: - skip-jacoco: - description: Skip Jacoco's Code Instrumentation For Coverage Analysis - type: boolean - default: true - skip-tests: - description: Do Not Compile And Do Not Run Test Code - type: boolean - default: true - skip-javadoc: - description: Skip Java Docs Generation - type: boolean - default: true - steps: - - install-java-maven - - install-xml-cli-tool - - run: - name: Maven build EHRbase - command: | - cd ~/projects/ehrbase - mvn17 package -Dmaven.javadoc.skip=<< parameters.skip-javadoc >> \ - -Djacoco.skip=<< parameters.skip-jacoco >> \ - -Dmaven.test.skip=<< parameters.skip-tests >> - - run: - name: Start EHRbase server and run all test of SDK - command: | - ls -la - cd ~/projects/ehrbase - EHRbase_VERSION=$(xmlstarlet sel -t -m "/_:project/_:version" -v . pom.xml ) - echo ${EHRbase_VERSION} - java17 -jar application/target/application-${EHRbase_VERSION}.jar --cache.enabled=true > log & - grep -m 1 "Started EhrBase in" <(tail -f log) - cd .. - jps - mvn17 verify -DskipIntegrationTests=false -Dmaven.javadoc.skip=true -Djacoco.skip=<< parameters.skip-jacoco >> - - - cache-out-sdk-m2-dependencies: - steps: - - run: - name: Generate Cache Checksum for openEHR_SDK Dependencies - command: find . -type f -name *.java | sort | xargs cat > /tmp/openEHR_SDK_maven_cache_seed - - restore_cache: - key: openEHR_SDK-v1 - - - cache-in-sdk-m2-dependencies: - steps: - - save_cache: - key: openEHR_SDK-v1-{{ checksum "/tmp/openEHR_SDK_maven_cache_seed" }} - paths: - - ~/.m2 - - - collect-sdk-unittest-results: - steps: - - run: - name: Save unit test results - command: | - mkdir -p ~/test-results/unit-tests/ - find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/unit-tests/ \; - find . -type f -regex ".*/target/surefire-reports/.*txt" -exec cp {} ~/test-results/unit-tests/ \; - when: always - - - collect-sdk-integrationtest-results: - steps: - - run: - name: Save integration test results - command: | - mkdir -p ~/test-results/integration-tests/ - find . -type f -regex ".*/target/failsafe-reports/.*xml" -exec cp {} ~/test-results/integration-tests/ \; - find . -type f -regex ".*/target/failsafe-reports/.*txt" -exec cp {} ~/test-results/integration-tests/ \; - when: always - - - save-skd-test-results: - steps: - - store_test_results: - path: ~/test-results - - store_artifacts: - path: ~/test-results - - - save-jacoco-coverage-report: - description: | - Uploads the overall coverage report as circleci artifact - The separate reports for unit and integration coverage are not required. - steps: - # - store_artifacts: - # path: test-coverage/target/site/jacoco-ut-coverage - # - store_artifacts: - # path: test-coverage/target/site/jacoco-it-coverage - - store_artifacts: - path: test-coverage/target/site/jacoco-overall-coverage - - - save-sdk-workspace: - steps: - - persist_to_workspace: - root: /home/circleci - paths: - - .m2 - - projects - - - restore-sdk-workspace: - description: | - Restores any file / folder that was previously persisted w/ 'persist_to_workspace'. - NOTE: best practise is to persist files or folders very selectively. - Do not persist root or the whole workspace at one, otherwise concurrent jobs - may fail to restore that stuff. - steps: - - attach_workspace: - at: /home/circleci/ - - - - # WARNING: don't use these two steps in production - # use them for pipeline debugging only! - cache-in-sdk-workspace: - steps: - - save_cache: - key: sdk-workspace-cache - paths: - - . - cache-out-sdk-workspace: - steps: - - restore_cache: - key: sdk-workspace-cache - - - - - - # /////////////////////////////////////////////////////////////////////////// - # /// EHRBASE COMMANDS /// - # /////////////////////////////////////////////////////////////////////////// - - git-clone-ehrbase-repo: - parameters: - branch: - description: Git branch to checkout - type: string - default: develop - steps: - - run: - name: Git clone EHRbase repo - command: | - git clone git@github.com:ehrbase/ehrbase.git - ls -la - cd ehrbase - git checkout << parameters.branch >> - - git-clone-robot-integration-tests-repo: - steps: - - run: - name: Git clone Robot integration-tests repository - command: | - git clone git@github.com:ehrbase/integration-tests.git - ls -la - cd integration-tests - mv tests/* ../ehrbase/tests/ - cd .. - - build-and-test-ehrbase: - steps: - - install-java-maven - - run: - name: Maven build EHRbase - command: | - cd ~/projects/ehrbase - mvn17 package dependency:go-offline -Dmaven.javadoc.skip=true - - - cache-in-ehrbase-m2-dependencies: - steps: - - save_cache: - key: EHRbase-v1-{{ checksum "/tmp/EHRbase_maven_cache_seed" }} - paths: - - ~/.m2/repository/org/ehrbase/openehr/ - - - cache-out-ehrbase-m2-dependencies: - steps: - - run: - name: Generate Cache Checksum for EHRbase Dependencies - command: find ~/projects/ehrbase -name 'pom.xml' | sort | xargs cat > /tmp/EHRbase_maven_cache_seed - - restore_cache: - key: EHRbase-v1 - - - save-ehrbase-workspace: - steps: - - persist_to_workspace: - root: /home/circleci - paths: - - projects/ehrbase - - - restore-ehrbase-workspace: - description: Attach EHRbase repo containing target folder and tests back to workspace - steps: - - run: ls -la - - attach_workspace: - at: /home/circleci/ - - run: ls -la ehrbase - - - force-ehrbase-build-to-use-local-sdk-version: - steps: - - install-xml-cli-tool - - run: - name: Adjust SDK version number in EHRbase's pom - command: | - SDK_VERSION=$(cat ~/projects/SDK_VERSION) - echo $SDK_VERSION - cd ~/projects/ehrbase - xmlstarlet edit --inplace --update /_:project/_:properties/_:ehrbase.sdk.version --value $SDK_VERSION bom/pom.xml - cat bom/pom.xml - - - - # WARNING: don't use these two steps in production - # use them for pipeline debugging only! - cache-in-ehrbase-workspace: - steps: - - save_cache: - key: ehrbase-workspace-cache-v3 - paths: - - ehrbase - cache-out-ehrbase-workspace: - steps: - - restore_cache: - key: ehrbase-workspace-cache-v3 - - - - - -# /////////////////////////////////////////////////////////////////////////// -# /// HELPER COMMANDS /// -# /////////////////////////////////////////////////////////////////////////// - - install-java-maven: - description: Install Java 17 and maven (if not already installed) - steps: - - run: - name: Install Java 17 - command: | - if [ ! -d "/usr/lib/jvm/jdk-17.0.5+8" ]; then - wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.5%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.5_8.tar.gz -O /tmp/openjdk-17.tar.gz - sudo mkdir -p /usr/lib/jvm - sudo tar xfvz /tmp/openjdk-17.tar.gz --directory /usr/lib/jvm - rm -f /tmp/openjdk-17.tar.gz - sudo ln -s /usr/lib/jvm/jdk-17.0.5+8 /opt/jdk17 - sudo sh -c 'for bin in /usr/lib/jvm/jdk-17.0.5+8/bin/*; do update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 100; done' - sudo sh -c 'for bin in /usr/lib/jvm/jdk-17.0.5+8/bin/*; do update-alternatives --set $(basename $bin) $bin; done' - fi - - run: - name: Install Maven tool - command: | - sudo killall -9 apt-get || true - if [ ! -d "/usr/lib/maven/apache-maven-3.8.7" ]; then - wget https://archive.apache.org/dist/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz -O /tmp/maven.tar.gz - sudo mkdir -p /usr/lib/maven - sudo tar xfvz /tmp/maven.tar.gz --directory /usr/lib/maven - rm -f /tmp/maven.tar.gz - sudo ln -s /usr/lib/maven/apache-maven-3.8.7 /opt/maven - sudo update-alternatives --install /usr/bin/mvn mvn /usr/lib/maven/apache-maven-3.8.7/bin/mvn 100 - sudo update-alternatives --set mvn /usr/lib/maven/apache-maven-3.8.7/bin/mvn - fi - - run: - name: Setup aliases and variables - command: | - #We default to JDK17 so we do not run into problems with running ehrbase through mvn - sudo sh -c "echo 'export JAVA_HOME=/opt/jdk17' >> /etc/bash.bashrc" - sudo sh -c "echo 'export MAVEN_HOME=/opt/maven' >> /etc/bash.bashrc" - sudo sh -c "echo 'export M2_HOME=\$MAVEN_HOME' >> /etc/bash.bashrc" - sudo sh -c "echo 'alias java17=\"/opt/jdk17/bin/java\"' >> /etc/bash.bashrc" - sudo sh -c "echo 'alias mvn17=\"JAVA_HOME=/opt/jdk17 /opt/maven/bin/mvn\"' >> /etc/bash.bashrc" - sudo chmod +x /etc/bash.bashrc - sudo chmod +x /etc/profile - source /etc/bash.bashrc - cat /etc/bash.bashrc - ls -lah /etc - - verify-java-maven-install - - verify-java-maven-install: - description: Verify installed Java 17 and maven - steps: - - run: - name: Show active and installed JDK/Maven versions - command: | - echo "PATH: $PATH" - echo "JAVA_HOME: $JAVA_HOME" - echo "MAVEN_HOME: $MAVEN_HOME" - echo "M2_HOME: $M2_HOME" - echo 'JDK 17 (java17):' - java17 --version - echo 'JDK default (java):' - java --version - echo 'Maven with JDK 17 (mvn17):' - mvn17 --version - echo 'Maven default (mvn):' - mvn --version - - - - install-python3-requirements: - description: Install Python requirements - steps: - - run: - name: Install Python requirements - command: | - python3 -c "import site; print(site.getsitepackages())" - pip3 install -r ~/projects/ehrbase/tests/requirements.txt - - - - # 88 - # 88 ,d ,d ,d - # 88 88 88 88 - # 8b,dPPYba, ,adPPYba, 88,dPPYba, ,adPPYba, MM88MMM MM88MMM ,adPPYba, ,adPPYba, MM88MMM ,adPPYba, - # 88P' "Y8 a8" "8a 88P' "8a a8" "8a 88 88 a8P_____88 I8[ "" 88 I8[ "" - # 88 8b d8 88 d8 8b d8 88 88 8PP""""""" `"Y8ba, 88 `"Y8ba, - # 88 "8a, ,a8" 88b, ,a8" "8a, ,a8" 88, 88, "8b, ,aa aa ]8I 88, aa ]8I - # 88 `"YbbdP"' 8Y"Ybbd8"' `"YbbdP"' "Y888 "Y888 `"Ybbd8"' `"YbbdP"' "Y888 `"YbbdP"' - # - # /////////////////////////////////////////////////////////////////////////// - # /// ROBOT INTEGRATION TESTS COMMANDS /// - # /////////////////////////////////////////////////////////////////////////// - - start-ehrbase-server: - steps: - # - openjdk-install/openjdk: # (use w/ machine executor only) - # version: 11 # - - install-java-maven - - install-xml-cli-tool - - run: - name: Start EHRbase server - background: true - command: | - ls -la - cd ehrbase - EHRbase_VERSION=$(xmlstarlet sel -t -m "/_:project/_:version" -v . pom.xml ) - echo ${EHRbase_VERSION} - java17 -jar application/target/application-${EHRbase_VERSION}.jar --cache.enabled=true > log - - - run-robot-tests: - description: Run integration tests written in Robot Framework - parameters: - sut: - description: SUT - System Under Test Config - enum: ["DEV", "DEV -v AUTH_TYPE:OAUTH", "ADMIN-DEV", "TEST", "TEST -v AUTH_TYPE:OAUTH", "ADMIN-TEST"] - default: "DEV" - type: enum - - nodename: - description: | - EHRbase's "CREATING_SYSTEM_ID". It can be set from cli when starting server .jar, i.e.: - `java -jar application.jar --server.nodename=local.ehrbase.org` - default: "circleci.ehrbase.org" - type: string - - allow-template-overwrite: - description: Sets EHRbase's cli option `--system.allow-template-overwrite=true` - default: true - type: boolean - - cache-enabled: - description: Sets EHRbase's cli option `--cache.enabled=true` - default: true - type: boolean - - include-tags: - description: Which tests to inclue by TAGs (Robot syntax applies!) - type: string - - test-suite-path: - description: Target test-suite given by it's folder name e.g. COMPOSITION_TESTS - default: "" - type: string - - test-suite-name: - description: Titel of generated Robot Log/Report.html - type: string - steps: - # - cache-out-python-requirements - - install-xml-cli-tool - - install-java-maven - - install-python3-requirements - - run: - name: START EHRBASE SERVER AND EXECUTE ROBOT TESTS - no_output_timeout: 30m - command: | - echo "SUT: $SUT" - echo "ADMINAPI_ACTIVE: $ADMINAPI_ACTIVE" - echo "SECURITY_AUTHTYPE: $SECURITY_AUTHTYPE" - echo "OAUTH_RESRCSERVER_URL: $SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUERURI" - cd ehrbase/ - ls -la - if [ "${SUT}" != "TEST" ]; then - EHRbase_VERSION=$(xmlstarlet sel -t -m "/_:project/_:version" -v . pom.xml ) - echo ${EHRbase_VERSION} - java17 -jar "application/target/application-${EHRbase_VERSION}.jar" \ - --system.allow-template-overwrite=<< parameters.allow-template-overwrite >> \ - --server.nodename=<< parameters.nodename >> \ - --cache.enabled=<< parameters.cache-enabled >> > log & app_pid=$! - if ! tail -f log | timeout 30s grep -m 1 "Started EhrBase in"; then - echo "WARNING: Did not see a startup message even after waiting 30s" >&2 - if kill -0 "$app_pid"; then - echo "...although EHRbase is still running" >&2 - else - echo "...and EHRbase did not successfully start" >&2 - fi - fi - fi - jps - cd ~/projects/ehrbase/tests - robot --include << parameters.include-tags >> \ - --skip TODO --skip future -e obsolete -e libtest \ - --skiponfailure not-ready \ - --console dotted \ - --loglevel TRACE \ - --flattenkeywords for \ - --flattenkeywords foritem \ - --flattenkeywords name:_resources.* \ - --outputdir results/<< parameters.test-suite-name >> \ - --timestampoutputs \ - --name << parameters.test-suite-name >> \ - -v SUT:<< parameters.sut >> \ - -v NODENAME:<< parameters.nodename >> \ - -v ALLOW-TEMPLATE-OVERWRITE:<< parameters.allow-template-overwrite >> \ - robot/<< parameters.test-suite-path >> - # - cache-in-python-requirements - - save-test-results-folder: - suite-results-folder-name: << parameters.test-suite-name >> - - store_test_results: - path: ~/projects/ehrbase/tests/results/ - - store_artifacts: - path: ~/projects/ehrbase/tests/results/ - - - configure-python-version: - description: Configure Python version to 3.7.0 - steps: - - run: - name: Configure Python version to 3.7.0 - command: | - pyenv global 3.7.0 - - - install-python-requirements: - description: Install Python requirements - steps: - # - cache-out-python-requirements - - run: - name: Install Python requirements - command: | - python --version - python -c "import site; print(site.getsitepackages())" - pip install -r ~/projects/ehrbase/tests/requirements.txt - # - cache-in-python-requirements - - - cache-in-python-requirements: - description: Save all caches in interation tests job - steps: - - run: - when: always - name: Save PIP cache - command: | - ls -la ~/.cache - ls -la /opt/circleci/ - - save_cache: - key: pip-v1-{{ checksum "~/projects/ehrbase/tests/requirements.txt" }} - paths: - # - ~/.cache/pip - - /opt/circleci/.pyenv/versions/3.7.0/lib/python3.7/site-packages - - - cache-out-python-requirements: - description: Restore all caches in interation tests job - steps: - - restore_cache: - keys: - - pip-v1- - - - save-test-results-folder: - description: Persist Robot tests folder to workspace - parameters: - suite-results-folder-name: - description: Titel of generated Robot Outputs - type: string - steps: - - run: - name: PERSIST ROBOT TEST RESULTS - when: always - command: echo "persist test results" - - persist_to_workspace: - root: /home/circleci - paths: - - projects/ehrbase/tests/results/<< parameters.suite-results-folder-name >> - - - restore-test-results-folder: - description: Attach Robot tests folder back to workspace - steps: - - attach_workspace: - at: /home/circleci/ - - - merge-robot-outputs: - description: Merge Robot Results from Parallel Tests - steps: - - run: - command: | - pip install robotframework==v4.0.3 - - run: - name: POST PROCESS & MERGE TEST RESULTS - when: always - command: | - cd ehrbase/tests - - # Create Log/Report with ALL DETAILS - rebot --outputdir results/0 \ - --name EHRbase \ - -e obsolete -e libtest \ - --removekeywords for \ - --removekeywords wuks \ - --loglevel TRACE \ - --output EHRbase-output.xml \ - --log EHRbase-log.html \ - --report EHRbase-report.html \ - results/*/*.xml - - run: - name: GENERATE TEST SUMMARY - when: always - command: | - cd ehrbase/tests - - # Create JUNIT report from merged results - rebot --outputdir results/robot-tests \ - -e obsolete -e libtest \ - --xunit junit-output.xml --xunitskipnoncritical \ - --log NONE \ - --report NONE \ - results/0/EHRbase-output.xml - - save-test-results-folder: - suite-results-folder-name: "0" - - store_test_results: - path: ~/projects/ehrbase/tests/results/ - - store_artifacts: - path: ~/projects/ehrbase/tests/results/ - - - - - -# /////////////////////////////////////////////////////////////////////////// -# /// CIRCLECI META /// -# /////////////////////////////////////////////////////////////////////////// - - -orbs: - maven: circleci/maven@1.0.1 - openjdk-install: cloudesire/openjdk-install@1.2.3 - sonarcloud: sonarsource/sonarcloud@2.0.0 - -executors: - docker-python3: - working_directory: ~/projects - docker: - - image: cimg/python:3.8.14-node - environment: - BASH_ENV: /etc/bash.bashrc - shell: /bin/bash -l -i -eo pipefail - - docker-py3-postgres: - working_directory: ~/projects - docker: - - image: cimg/python:3.8.14-node - - image: ehrbase/ehrbase-postgres:13.4.v2 - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - environment: - BASH_ENV: /etc/bash.bashrc - shell: /bin/bash -l -i -eo pipefail - - machine-ubuntu-2004: - description: | - Ubuntu 20.04 VM (machine executor) - - openjdk 1.8 - - openjdk 11.0.8 (default) - - maven 3.6.3 - - gradle 6.6 - - python 2.7.17 - - python 3.8.5 - - pip/pip3 - - docker 19.03.12 - - docker-compose 1.26.2 - - aws-cli 2.0.43 - - google cloud sdk 307.0.0 - - heroku 7.42.12 - - chrome 85.0.4183 - - chromedriver 85.0.4183 - - firefox 80.0.0 - - go 1.15 - - leiningen 2.9.4 - - node 12.18.3 (default) - - node 14.8.0 - - ruby 2.7.1 - - sbt 1.3.13 - - yarn 1.22.4 - working_directory: ~/projects - # working_directory: /mnt/ramdisk # TODO: @wlad TEST THIS FOR POSSIBLE - environment: # SPEED IMPROVEMENT !!! - PIPELINE_ID: << pipeline.id >> - BRANCH_NAME: << pipeline.git.branch >> - BASH_ENV: /etc/bash.bashrc - shell: /bin/bash -l -i -eo pipefail - machine: - image: ubuntu-2004:202008-01 - - - - - - - - - - -# oooooooooo. .o. .oooooo. oooo oooo ooooo ooo ooooooooo. -# `888' `Y8b .888. d8P' `Y8b `888 .8P' `888' `8' `888 `Y88. -# 888 888 .8"888. 888 888 d8' 888 8 888 .d88' -# 888oooo888' .8' `888. 888 88888[ 888 8 888ooo88P' -# 888 `88b .88ooo8888. 888 888`88b. 888 8 888 -# 888 .88P .8' `888. `88b ooo 888 `88b. `88. .8' 888 -# o888bood8P' o88o o8888o `Y8bood8P' o888o o888o `YbodP' o888o -# -# [ BACKUP ] - - # Example-how-to-use-INSTALL-JAVA11-ORB: - # executor: machine-ubuntu-2004 - # steps: - # - run: echo "run integration tests job mock" - # - openjdk-install/openjdk: - # version: 11 - # - restore-ehrbase-workspace - # - run-robot-tests: - # include-tags: "CONTRIBUTION" - # test-suite-path: "CONTRIBUTION_TESTS" - # test-suite-name: "CONTRIBUTION" - - - - # force-ehrbase-build-to-use-local-sdk-version: - # steps: - # - run: sudo apt install maven -y - # - run: - # name: Adjust SDK version number in EHRbase's pom - # description: | - # We have to provide the version of locally build openEHR_SDK in EHRbase's POM - # to make sure that EHRbase builds succesfully w/ latest changes applied to the SDK. - # "mvn versions:set-property" is an simple way to achieve exactly that. Ufortunately - # it triggers a check for SDK dependency updates from jitpack.io - # which can take up to 15 minutes! - - # Using Maven's -o (for offline) flag can help to prevent check for update but - # it fails when dependencies are not cached first. - # After caching dependencies it works but not 100% reliable. - - # As a more robust solution install xmlstarlet (a cli tool to handle XML) and - # use it as a fallback if the 'mvn -o' approach starts to fail. - # command: | - # SDK_VERSION=$(cat ~/projects/SDK_VERSION) - # echo $SDK_VERSION - # cd ~/projects/ehrbase - # mvn versions:set-property -Dproperty=ehrbase.sdk.version -DnewVersion=$SDK_VERSION -o - - - - # command-check-commit-message-contains-string: - # steps: - # - run: - # name: Check if commit message contains 'some-string' - # command: | - # if [[ ${last_commit} == *[some-string]* ]] - # then - # # Generate and publish API docs - # fi - - # if [[ ${last_commit} == *"minor"* ]]; then echo hello wlad; fi - - # STR='GNU/Linux is an operating system' - # SUB='Linux' - - # case $STR in - - # *"$SUB"*) - # echo -n "It's there." - # ;; - # esac - - - - # save-jacoco-unit-coverage: - # steps: - # - run: - # name: Save Jacoco code coverage (unit tests) - # command: | - # mkdir -p ~/code-coverage/ - # cp -r test-coverage/target/site/jacoco-ut-coverage ~/code-coverage/ - # - store_artifacts: - # path: ~/code-coverage/jacoco-ut-coverage - - # save-jacoco-integration-coverage: - # steps: - # - run: - # name: Save Jacoco code coverage (overall & integration tests) - # command: | - # mkdir -p ~/code-coverage/ - # cp -r test-coverage/target/site/jacoco-it-coverage ~/code-coverage/ - # cp -r test-coverage/target/site/jacoco-overall-coverage ~/code-coverage/ - # - store_artifacts: - # path: ~/code-coverage/jacoco-it-coverage - - # save-jacoco-overall-coverage: - # steps: - # - run: - # name: Save Jacoco's overall code coverage report (w/ unit & integr. tests) - # command: | - # mkdir -p ~/code-coverage/ - # cp -r test-coverage/target/site/jacoco-overall-coverage ~/code-coverage/ - # - store_artifacts: - # path: ~/code-coverage/jacoco-overall-coverage - # # - persist_to_workspace: - # # root: /home/circleci - # # paths: - # # - code-coverage/jacoco-overall-coverage diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 916b1cdd5..d87c3e207 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,7 @@ name: build on: push: - branches: - - master - - develop + pull_request: workflow_dispatch: jobs: @@ -23,34 +21,10 @@ jobs: java-version: '17' cache: 'maven' - - name: Build with Maven - run: mvn -B verify - - name: Setup Maven Central - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '17' - cache: 'maven' - server-id: ossrh - server-username: OSSRH_USERNAME - server-password: OSSRH_TOKEN - gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} - gpg-passphrase: GPG_PASSPHRASE + - name: Spotless + run: mvn -B spotless:apply - - name: Publish to Maven Central - run: mvn -B deploy -P release -DskipTests - env: - OSSRH_USERNAME: ${{ secrets.S01_OSSRH_USERNAME }} - OSSRH_TOKEN: ${{ secrets.S01_OSSRH_TOKEN }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + - name: Build with Maven + run: mvn -B verify - - name: 'Trigger ehrbase:next build' - if: github.ref == 'refs/heads/develop' - run: | - curl \ - -X POST \ - -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ - -H "Content-Type: application/json" \ - https://api.github.com/repos/ehrbase/ehrbase/dispatches \ - -d '{"event_type":"build-ehrbase-next"}' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..6662f53f4 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,56 @@ +name: publish + +on: + push: + branches: + - master + - develop + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'maven' + + - name: Build with Maven + run: mvn -B verify + + - name: Setup Maven Central + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'maven' + server-id: ossrh + server-username: OSSRH_USERNAME + server-password: OSSRH_TOKEN + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: GPG_PASSPHRASE + + - name: Publish to Maven Central + run: mvn -B deploy -P release -DskipTests + env: + OSSRH_USERNAME: ${{ secrets.S01_OSSRH_USERNAME }} + OSSRH_TOKEN: ${{ secrets.S01_OSSRH_TOKEN }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + + - name: 'Trigger ehrbase:next build' + if: github.ref == 'refs/heads/develop' + run: | + curl \ + -X POST \ + -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ + -H "Content-Type: application/json" \ + https://api.github.com/repos/ehrbase/ehrbase/dispatches \ + -d '{"event_type":"build-ehrbase-next"}' diff --git a/bom/pom.xml b/bom/pom.xml index 745456e47..0f8484b76 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -352,6 +352,18 @@ pom import + + org.testcontainers + testcontainers + 1.19.7 + test + + + org.testcontainers + junit-jupiter + 1.19.7 + test + diff --git a/client/pom.xml b/client/pom.xml index 593fb5d70..38a0ac511 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -156,6 +156,16 @@ junit-vintage-engine test + + org.testcontainers + testcontainers + test + + + org.testcontainers + junit-jupiter + test + org.apache.commons commons-text diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/AqlTestIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/AqlTestIT.java deleted file mode 100644 index 78d37467e..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/AqlTestIT.java +++ /dev/null @@ -1,744 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.*; - -import com.nedap.archie.rm.composition.Composition; -import com.nedap.archie.rm.composition.Observation; -import com.nedap.archie.rm.datastructures.Element; -import com.nedap.archie.rm.datastructures.Event; -import com.nedap.archie.rm.datastructures.History; -import com.nedap.archie.rm.datastructures.ItemList; -import com.nedap.archie.rm.datavalues.quantity.DvQuantity; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.io.IOUtils; -import org.assertj.core.groups.Tuple; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; -import org.ehrbase.openehr.sdk.generator.commons.aql.condition.Condition; -import org.ehrbase.openehr.sdk.generator.commons.aql.containment.Containment; -import org.ehrbase.openehr.sdk.generator.commons.aql.field.EhrFields; -import org.ehrbase.openehr.sdk.generator.commons.aql.field.NativeSelectAqlField; -import org.ehrbase.openehr.sdk.generator.commons.aql.parameter.Parameter; -import org.ehrbase.openehr.sdk.generator.commons.aql.parameter.ParameterValue; -import org.ehrbase.openehr.sdk.generator.commons.aql.parameter.StoredQueryParameter; -import org.ehrbase.openehr.sdk.generator.commons.aql.query.EntityQuery; -import org.ehrbase.openehr.sdk.generator.commons.aql.query.Query; -import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record2; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.TestData; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.coronaanamnesecomposition.CoronaAnamneseComposition; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition; -import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; -import org.ehrbase.openehr.sdk.response.dto.StoredQueryResponseData; -import org.ehrbase.openehr.sdk.serialisation.dto.RmToGeneratedDtoConverter; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.ehrbase.openehr.sdk.util.exception.ClientException; -import org.ehrbase.openehr.sdk.util.exception.WrongStatusCodeException; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class AqlTestIT { - - private static OpenEhrClient openEhrClient; - private UUID ehr; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehr); - } - - @Test - public void testExecute() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude " - + "from EHR e[ehr_id/value = $ehr_id] " - + "contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - Double.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull().hasSize(2); - } - - @Test - public void testExecute2() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value " - + "from EHR e[ehr_id/value = $ehr_id] " - + "contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - DvQuantity.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull().hasSize(2); - } - - @Test - public void testExecute3() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o/data[at0001]/events[at0002]/data[at0003]/items[at0004] " - + "from EHR e[ehr_id/value = $ehr_id] " - + "contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - Element.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull().hasSize(2); - } - - @Test - public void testExecute4() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o/data[at0001]/events[at0002]/data[at0003] " - + "from EHR e[ehr_id/value = $ehr_id] " - + "contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - ItemList.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull().hasSize(2); - } - - @Test - public void testExecute5() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o/data[at0001]/events[at0002] " + "from EHR e[ehr_id/value = $ehr_id] " - + "contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - Event.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull().hasSize(2); - } - - @Test - public void testExecute6() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o/data[at0001] " + "from EHR e[ehr_id/value = $ehr_id] " - + "contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - History.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull().hasSize(2); - } - - @Test - public void testExecute7() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o " + "from EHR e[ehr_id/value = $ehr_id] " - + "contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - Observation.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull().hasSize(2); - } - - @Test - public void testExecute8() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude " - + "from EHR e[ehr_id/value = $ehr_id] " - + "contains COMPOSITION a contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - Double.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull().hasSize(2); - } - - @Test - public void testExecute9() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude " - + "from EHR e[ehr_id/value = $ehr_id] " - + "contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - Double.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull().hasSize(2); - } - - @Test - public void testExecute10() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude " - + "from EHR e[ehr_id/value = $ehr_id] " - + "contains Observation o " - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - Double.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull().hasSize(2); - } - - @Test - public void testExecute11() throws IOException { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString(CompositionTestDataCanonicalJson.CORONA.getStream(), StandardCharsets.UTF_8), - Composition.class); - RmToGeneratedDtoConverter rmToGeneratedDtoConverter = - new RmToGeneratedDtoConverter(new TestDataTemplateProvider()); - CoronaAnamneseComposition coronaAnamneseComposition = - rmToGeneratedDtoConverter.toGeneratedDto(composition, CoronaAnamneseComposition.class); - coronaAnamneseComposition.setVersionUid(null); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(coronaAnamneseComposition); - - Query> query = Query.buildNativeQuery( - "Select " - + " o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value as var1," - + " o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value as var2" - + " from EHR e[ehr_id/value = $ehr_id] " - + " contains COMPOSITION c3[openEHR-EHR-COMPOSITION.report.v1]" - + " contains SECTION s4[openEHR-EHR-SECTION.adhoc.v1]" - + " contains OBSERVATION o[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0] " - + " WHERE" - + " o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value is not null " - + " AND" - + " o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value is not null", - String.class, - String.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehr)); - assertThat(result).isNotNull(); - assertThat(result) - .extracting(Record2::value1, Record2::value2) - .containsExactlyInAnyOrder( - new Tuple("Nicht vorhanden", "Durchfall"), - new Tuple("Nicht vorhanden", "gestörter Geruchssinn"), - new Tuple("Nicht vorhanden", "gestörter Geschmackssinn"), - new Tuple("Nicht vorhanden", "Heiserkeit"), - new Tuple("Vorhanden", "Fieber oder erhöhte Körpertemperatur"), - new Tuple("Vorhanden", "Husten"), - new Tuple("Vorhanden", "Schnupfen")); - } - - @Test - public void testExecute12() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1); - - EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2); - - Containment observationContainment = new Containment("OBSERVATION"); - - NativeSelectAqlField magnitudeField = new NativeSelectAqlField<>( - observationContainment, - "/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude", - Double.class); - EntityQuery> entityQuery = - Query.buildEntityQuery(observationContainment, EhrFields.EHR_ID(), magnitudeField); - - Parameter ehrIdParameter = entityQuery.buildParameter(); - entityQuery.where( - Condition.equal(EhrFields.EHR_ID(), ehrIdParameter).and(Condition.equal(magnitudeField, 1.1d))); - - List> result = - openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr)); - assertThat(result).isNotNull().size().isEqualTo(2); - } - - @Test - public void testExecute13() throws IOException { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString(CompositionTestDataCanonicalJson.CORONA.getStream(), StandardCharsets.UTF_8), - Composition.class); - RmToGeneratedDtoConverter rmToGeneratedDtoConverter = - new RmToGeneratedDtoConverter(new TestDataTemplateProvider()); - CoronaAnamneseComposition coronaAnamneseComposition = - rmToGeneratedDtoConverter.toGeneratedDto(composition, CoronaAnamneseComposition.class); - coronaAnamneseComposition.setVersionUid(null); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(coronaAnamneseComposition); - - Query query = Query.buildNativeQuery("Select DISTINCT " - + " o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value as var1, o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value as var2 " - + " from EHR e[ehr_id/value = $ehr_id] " - + " contains COMPOSITION c3[openEHR-EHR-COMPOSITION.report.v1]" - + " contains SECTION s4[openEHR-EHR-SECTION.adhoc.v1]" - + " contains OBSERVATION o[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0]" - + " WHERE" - + " o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value is not null " - + " AND" - + " o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value is not null"); - - QueryResponseData result = openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehr)); - - assertNotNull(result); - assertNotNull(result.getQuery()); - assertNotNull(result.getRows()); - assertNotNull(result.getColumns()); - assertEquals(7, result.getRows().size()); - assertEquals(2, result.getColumns().size()); - - List expectedResults = Arrays.asList( - List.of("Nicht vorhanden", "Durchfall"), - List.of("Nicht vorhanden", "gestörter Geruchssinn"), - List.of("Nicht vorhanden", "gestörter Geschmackssinn"), - List.of("Nicht vorhanden", "Heiserkeit"), - List.of("Vorhanden", "Fieber oder erhöhte Körpertemperatur"), - List.of("Vorhanden", "Husten"), - List.of("Vorhanden", "Schnupfen")); - - assertTrue(CollectionUtils.isEqualCollection(result.getRows(), expectedResults)); - } - - @Test - public void testExecute14() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - Query query = Query.buildNativeQuery("Invalid aql query"); - - Exception exception = assertThrows( - WrongStatusCodeException.class, - () -> openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehr))); - - String expectedMessage = "AQL Parse exception: line 1: char 0 mismatched input 'Invalid'"; - String actualMessage = exception.getMessage(); - - assertTrue(actualMessage.contains(expectedMessage)); - } - - @Test - public void testExecute15() { - - Query query = Query.buildNativeQuery( - "Select o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value, o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value " - + "from EHR e[ehr_id/value = $ehr_id] " - + "contains COMPOSITION c3[openEHR-EHR-COMPOSITION.report.v1] contains SECTION s4[openEHR-EHR-SECTION.adhoc.v1] contains OBSERVATION o[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0]"); - - Exception exception = assertThrows( - ClientException.class, () -> openEhrClient.aqlEndpoint().executeRaw(query, null)); - - String expectedMessage = "Invalid parameters"; - String actualMessage = exception.getMessage(); - - assertTrue(actualMessage.contains(expectedMessage)); - } - - @Test - public void testExecute16() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - Exception exception = assertThrows( - ClientException.class, - () -> openEhrClient.aqlEndpoint().executeRaw(null, new ParameterValue("ehr_id", ehr))); - - String expectedMessage = "Invalid query"; - String actualMessage = exception.getMessage(); - - assertTrue(actualMessage.contains(expectedMessage)); - } - - @Test - public void testExecuteStoredAqlQueryInvalid() { - performInvalidExecuteStoredQuery(null); - performInvalidExecuteStoredQuery(new StoredQueryParameter(null, null)); - performInvalidExecuteStoredQuery(new StoredQueryParameter("queryName", null)); - performInvalidExecuteStoredQuery(new StoredQueryParameter(null, "version")); - performInvalidExecuteStoredQuery(new StoredQueryParameter("org.openehr::blablabla", null)); - } - - private void performInvalidExecuteStoredQuery(StoredQueryParameter requestParam) { - Exception exception = assertThrows( - ClientException.class, () -> openEhrClient.aqlEndpoint().executeStoredQuery(requestParam)); - - String expectedMessage = "Invalid query"; - String actualMessage = exception.getMessage(); - - assertTrue(actualMessage.contains(expectedMessage)); - } - - @Test - public void testStoreAqlQueryInvalid1() { - performInvalidStoreAqlQuery(null, null, "Invalid query"); - performInvalidStoreAqlQuery(null, new StoredQueryParameter(null, null), "Invalid query"); - performInvalidStoreAqlQuery(null, new StoredQueryParameter("queryName", null), "Invalid query"); - performInvalidStoreAqlQuery(null, new StoredQueryParameter(null, "version"), "Invalid query"); - - Query> query = Query.buildNativeQuery( - "select e/ehr_id/value,o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude " - + "from EHR e[ehr_id/value = $ehr_id] " - + "contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains Observation o[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]" - + "where o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude = 1.1", - UUID.class, - Double.class); - - performInvalidStoreAqlQuery(query, null, "Invalid parameters"); - performInvalidStoreAqlQuery(query, new StoredQueryParameter(null, null), "Invalid parameters"); - performInvalidStoreAqlQuery(query, new StoredQueryParameter("queryName", null), "Invalid parameters"); - performInvalidStoreAqlQuery(query, new StoredQueryParameter(null, "version"), "Invalid parameters"); - } - - private void performInvalidStoreAqlQuery(Query query, StoredQueryParameter requestParam, String expectedMessage) { - Exception exception = assertThrows( - ClientException.class, () -> openEhrClient.aqlEndpoint().storeAqlQuery(query, requestParam)); - - assertTrue(exception.getMessage().contains(expectedMessage)); - } - - @Test - public void testGetAqlQueryInvalid() { - checkInvalidStoredAqlQuery(null, null); - checkInvalidStoredAqlQuery(null, ""); - checkInvalidStoredAqlQuery("", null); - checkInvalidStoredAqlQuery("", ""); - } - - private void checkInvalidStoredAqlQuery(String qualifiedQueryName, String version) { - StoredQueryParameter requestParam = new StoredQueryParameter(qualifiedQueryName, version); - - Exception exception = assertThrows( - ClientException.class, () -> openEhrClient.aqlEndpoint().getStoredAqlQuery(requestParam)); - - String expectedMessage = "Invalid query"; - - assertTrue(exception.getMessage().contains(expectedMessage)); - } - - @Test - public void testStoreAndRetrieveAqlQuery() { - - Query> query = Query.buildNativeQuery( - "SELECT c " + "FROM EHR e[ehr_id/value=$ehr_id] " - + "CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v1] " - + "CONTAINS OBSERVATION obs[openEHR-EHR-OBSERVATION.blood_pressure.v1] " - + "WHERE obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude >= 100", - UUID.class, - Double.class); - - String qualifiedQueryName = "org.openehr::storedQueryName"; - int patchVersion = 0; - String version = "1.0."; - - boolean successful = false; - - do { - // try to store the query - try { - openEhrClient - .aqlEndpoint() - .storeAqlQuery(query, new StoredQueryParameter(qualifiedQueryName, version + patchVersion)); - successful = true; - } catch (Exception e) { - patchVersion++; - } - } while (!successful && patchVersion < 1000); - - String fullVersion = version + patchVersion; - - StoredQueryResponseData storedAqlQuery = openEhrClient - .aqlEndpoint() - .getStoredAqlQuery(new StoredQueryParameter(qualifiedQueryName, fullVersion)); - - // TODO: the qualified query name should not have the version number included - String expectedName = qualifiedQueryName + "/" + version + patchVersion; - assertEquals(expectedName, storedAqlQuery.getName()); - - // TODO: version is currently included within the qualified name and the version field is not filled - // this seems to not be conform to the specification - // https://specifications.openehr.org/releases/ITS-REST/Release-1.0.0/definitions.html#definitions-stored-query-get-1 (for Release 1.0.0) - // https://specifications.openehr.org/releases/ITS-REST/Release-1.0.2/definitions.html#definitions-stored-query-get-1 (for currently valid Release 1.0.2) - // assertEquals(fullVersion,storedAqlQuery.getVersion()); - assertEquals(query.buildAql(), storedAqlQuery.getAqlQuery()); - } - - @Test - public void testExecuteStoredAqlQuery() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - Query> query = Query.buildNativeQuery( - "SELECT c " + "FROM EHR e[ehr_id/value=$ehr_id] " - + "CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v1] " - + "CONTAINS OBSERVATION obs[openEHR-EHR-OBSERVATION.blood_pressure.v1] " - + "WHERE obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude >= 100", - UUID.class, - Double.class); - - String qualifiedQueryName = "org.openehr::storedQueryName"; - int patchVersion = 0; - String version = "1.0."; - - boolean successful = false; - - do { - // try to store the query - try { - openEhrClient - .aqlEndpoint() - .storeAqlQuery(query, new StoredQueryParameter(qualifiedQueryName, version + patchVersion)); - successful = true; - } catch (Exception e) { - patchVersion++; - } - } while (!successful && patchVersion < 1000); - - String fullVersion = version + patchVersion; - - QueryResponseData queryResponse = openEhrClient - .aqlEndpoint() - .executeStoredQuery(new StoredQueryParameter(qualifiedQueryName, fullVersion)); - - // TODO: the qualified query name should not have the version number included - String expectedName = qualifiedQueryName + "/" + version + patchVersion; - assertEquals(expectedName, queryResponse.getName()); - - assertEquals(query.buildAql(), queryResponse.getQuery()); - - assertTrue(queryResponse.getColumns().size() > 0); - } - - @Test - public void testExecuteStoredAqlQueryFullParams() { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - Query> query = Query.buildNativeQuery( - "SELECT c " + "FROM EHR e[ehr_id/value=$ehr_id] " - + "CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v1] " - + "CONTAINS OBSERVATION obs[openEHR-EHR-OBSERVATION.blood_pressure.v1] " - + "WHERE obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude >= 100", - UUID.class, - Double.class); - - String qualifiedQueryName = "org.openehr::storedQueryName"; - int patchVersion = 0; - String version = "1.0."; - - boolean successful = false; - - do { - // try to store the query - try { - openEhrClient - .aqlEndpoint() - .storeAqlQuery(query, new StoredQueryParameter(qualifiedQueryName, version + patchVersion)); - successful = true; - } catch (Exception e) { - patchVersion++; - } - } while (!successful && patchVersion < 1000); - - String fullVersion = version + patchVersion; - - int offsetValue = 1; - int fetchValue = 2; - StoredQueryParameter queryParameter = new StoredQueryParameter(qualifiedQueryName, fullVersion); - queryParameter.offset(offsetValue).fetch(fetchValue).addQueryParam("ehr_id", ehr.toString()); - - QueryResponseData queryResponse = openEhrClient.aqlEndpoint().executeStoredQuery(queryParameter); - - // TODO: the qualified query name should not have the version number included - String expectedName = qualifiedQueryName + "/" + version + patchVersion; - assertEquals(expectedName, queryResponse.getName()); - - assertEquals(query.buildAql() + " LIMIT " + fetchValue + " OFFSET " + offsetValue, queryResponse.getQuery()); - - assertTrue(queryResponse.getColumns().size() > 0); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/CoronaTestIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/CoronaTestIT.java deleted file mode 100644 index a974289b4..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/CoronaTestIT.java +++ /dev/null @@ -1,510 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.composition.Composition; -import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.time.temporal.TemporalAccessor; -import java.util.List; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.assertj.core.groups.Tuple; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; -import org.ehrbase.openehr.sdk.generator.commons.aql.condition.Condition; -import org.ehrbase.openehr.sdk.generator.commons.aql.containment.Containment; -import org.ehrbase.openehr.sdk.generator.commons.aql.containment.ContainmentExpression; -import org.ehrbase.openehr.sdk.generator.commons.aql.field.EhrFields; -import org.ehrbase.openehr.sdk.generator.commons.aql.field.NativeSelectAqlField; -import org.ehrbase.openehr.sdk.generator.commons.aql.parameter.Parameter; -import org.ehrbase.openehr.sdk.generator.commons.aql.query.EntityQuery; -import org.ehrbase.openehr.sdk.generator.commons.aql.query.Query; -import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record2; -import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record3; -import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record4; -import org.ehrbase.openehr.sdk.generator.commons.shareddefinition.Language; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.TestData; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.coronaanamnesecomposition.CoronaAnamneseComposition; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.coronaanamnesecomposition.CoronaAnamneseCompositionContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.coronaanamnesecomposition.definition.FieberOderErhohteKorpertemperaturObservationContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.coronaanamnesecomposition.definition.HeiserkeitObservationContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.coronaanamnesecomposition.definition.HustenObservationContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.coronaanamnesecomposition.definition.ReisefallObservationContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.coronaanamnesecomposition.definition.RisikogebietSectionContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.coronaanamnesecomposition.definition.SymptomeSectionContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.coronaanamnesecomposition.definition.VorhandenDefiningCode; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.patientenaufenthaltcomposition.PatientenaufenthaltCompositionContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.patientenaufenthaltcomposition.definition.AbteilungsfallClusterContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.patientenaufenthaltcomposition.definition.StandortClusterContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.patientenaufenthaltcomposition.definition.StandortschlusselDefiningCode; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.patientenaufenthaltcomposition.definition.VersorgungsortAdminEntryContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.stationarerversorgungsfallcomposition.StationarerVersorgungsfallCompositionContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.stationarerversorgungsfallcomposition.definition.AufnahmedatenAdminEntryContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.stationarerversorgungsfallcomposition.definition.EntlassungsdatenAdminEntryContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.virologischerbefundcomposition.VirologischerBefundComposition; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.virologischerbefundcomposition.VirologischerBefundCompositionContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.virologischerbefundcomposition.definition.BefundObservationContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.virologischerbefundcomposition.definition.KulturClusterContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.virologischerbefundcomposition.definition.ProVirusClusterContainment; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.virologischerbefundcomposition.definition.ProbeClusterContainment; -import org.ehrbase.openehr.sdk.serialisation.dto.RmToGeneratedDtoConverter; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -public class CoronaTestIT { - - private static OpenEhrClient openEhrClient; - private UUID ehr; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehr); - } - - @Test - @Ignore("see https://github.com/ehrbase/project_management/issues/376") - public void testCorona() throws IOException { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString(CompositionTestDataCanonicalJson.CORONA.getStream(), StandardCharsets.UTF_8), - Composition.class); - RmToGeneratedDtoConverter rmToGeneratedDtoConverter = - new RmToGeneratedDtoConverter(new TestDataTemplateProvider()); - CoronaAnamneseComposition coronaAnamneseComposition = - rmToGeneratedDtoConverter.toGeneratedDto(composition, CoronaAnamneseComposition.class); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(coronaAnamneseComposition); - - assertThat(openEhrClient - .compositionEndpoint(ehr) - .find( - UUID.fromString(coronaAnamneseComposition - .getVersionUid() - .getObjectId() - .getValue()), - CoronaAnamneseComposition.class)) - .isNotNull(); - - CoronaAnamneseCompositionContainment coronaAnamneseCompositionContainment = - CoronaAnamneseCompositionContainment.getInstance(); - SymptomeSectionContainment symptomeSectionContainment = SymptomeSectionContainment.getInstance(); - - HustenObservationContainment hustenObservationContainment = HustenObservationContainment.getInstance(); - FieberOderErhohteKorpertemperaturObservationContainment - fieberOderErhohteKorpertemperaturObservationContainment = - FieberOderErhohteKorpertemperaturObservationContainment.getInstance(); - HeiserkeitObservationContainment heiserkeitObservationContainment = - HeiserkeitObservationContainment.getInstance(); - - ContainmentExpression containmentExpression = coronaAnamneseCompositionContainment - .contains(symptomeSectionContainment) - .contains(hustenObservationContainment - .and(fieberOderErhohteKorpertemperaturObservationContainment) - .and(heiserkeitObservationContainment)); - - EntityQuery> - entityQuery = Query.buildEntityQuery( - containmentExpression, - hustenObservationContainment.VORHANDEN_DEFINING_CODE, - fieberOderErhohteKorpertemperaturObservationContainment.VORHANDEN_DEFINING_CODE, - heiserkeitObservationContainment.VORHANDEN_DEFINING_CODE, - coronaAnamneseCompositionContainment.LANGUAGE); - Parameter ehrIdParameter = entityQuery.buildParameter(); - entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter)); - /* - Select - o0/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/defining_Code as F0, - o1/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/defining_Code as F1, - o2/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/defining_Code as F2, - c3/language as F3 - from EHR e - contains ( COMPOSITION c3[openEHR-EHR-COMPOSITION.report.v1] contains - SECTION s4[openEHR-EHR-SECTION.adhoc.v1] contains - ( - (OBSERVATION o0[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0] - and - OBSERVATION o1[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0]) - and - OBSERVATION o2[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0]) - ) - where e/ehr_id/value = $parm0 - */ - List> actual = - openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr)); - - assertThat(actual) - .extracting(Record4::value1, Record4::value2, Record4::value3, Record4::value4) - .containsExactlyInAnyOrder(new Tuple( - VorhandenDefiningCode.VORHANDEN, - VorhandenDefiningCode.VORHANDEN, - VorhandenDefiningCode.NICHT_VORHANDEN, - Language.DE)); - } - - @Test - @Ignore - public void testCoronaWithJoin() throws IOException { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString(CompositionTestDataCanonicalJson.CORONA.getStream(), StandardCharsets.UTF_8), - Composition.class); - RmToGeneratedDtoConverter rmToGeneratedDtoConverter = - new RmToGeneratedDtoConverter(new TestDataTemplateProvider()); - CoronaAnamneseComposition coronaAnamneseComposition = - rmToGeneratedDtoConverter.toGeneratedDto(composition, CoronaAnamneseComposition.class); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(coronaAnamneseComposition); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0()); - - assertThat(openEhrClient - .compositionEndpoint(ehr) - .find( - UUID.fromString(coronaAnamneseComposition - .getVersionUid() - .getObjectId() - .getValue()), - CoronaAnamneseComposition.class)) - .isNotNull(); - - CoronaAnamneseCompositionContainment coronaAnamneseCompositionContainment = - CoronaAnamneseCompositionContainment.getInstance(); - SymptomeSectionContainment symptomeSectionContainment = SymptomeSectionContainment.getInstance(); - - HustenObservationContainment hustenObservationContainment = HustenObservationContainment.getInstance(); - FieberOderErhohteKorpertemperaturObservationContainment - fieberOderErhohteKorpertemperaturObservationContainment = - FieberOderErhohteKorpertemperaturObservationContainment.getInstance(); - HeiserkeitObservationContainment heiserkeitObservationContainment = - HeiserkeitObservationContainment.getInstance(); - - RisikogebietSectionContainment risikogebietSectionContainment = RisikogebietSectionContainment.getInstance(); - ReisefallObservationContainment reisefallObservationContainment = ReisefallObservationContainment.getInstance(); - - // @formatter:off - ContainmentExpression containmentExpression = - coronaAnamneseCompositionContainment.contains(symptomeSectionContainment - .contains(hustenObservationContainment) - .and(risikogebietSectionContainment.contains(reisefallObservationContainment))); - - // @formatter:on - - EntityQuery> entityQuery = Query.buildEntityQuery( - containmentExpression, - hustenObservationContainment.VORHANDEN_DEFINING_CODE, - coronaAnamneseCompositionContainment.LANGUAGE, - reisefallObservationContainment.LANGUAGE); - Parameter ehrIdParameter = entityQuery.buildParameter(); - entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter)); - - /* - Select - o0/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/defining_Code as F0, - c1/language as F1, - o2/language as F2 - from EHR e - contains COMPOSITION c1[openEHR-EHR-COMPOSITION.report.v1] contains ( - (SECTION s3[openEHR-EHR-SECTION.adhoc.v1] contains - OBSERVATION o0[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0] ) - and - ( SECTION s4[openEHR-EHR-SECTION.adhoc.v1] contains - OBSERVATION o2[openEHR-EHR-OBSERVATION.travel_event.v0] ) - ) - where e/ehr_id/value = $parm0 - */ - List> actual = - openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr)); - - assertThat(actual) - .extracting(Record3::value1, Record3::value2, Record3::value3) - .containsExactlyInAnyOrder(new Tuple(VorhandenDefiningCode.VORHANDEN, Language.DE, Language.DE)); - } - - /** - * see https://wiki.vitagroup.ag/display/NUM/Research+Repository - * containment test: - * contains COMPOSITION c[openEHR-EHR-COMPOSITION.event_summary.v0] - * contains ADMIN_ENTRY m[openEHR-EHR-ADMIN_ENTRY.hospitalization.v0] - * contains CLUSTER k[openEHR-EHR-CLUSTER.location.v1] - */ - @Test - public void testNUMResearchCase_1_2() { - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient - .compositionEndpoint(ehr) - .mergeCompositionEntity(TestData.buildTestPatientenaufenthaltComposition()); - - // build AQL - PatientenaufenthaltCompositionContainment patientenaufenthaltCompositionContainment = - PatientenaufenthaltCompositionContainment.getInstance(); - - VersorgungsortAdminEntryContainment versorgungsortAdminEntryContainment = - VersorgungsortAdminEntryContainment.getInstance(); - StandortClusterContainment standortClusterContainment = StandortClusterContainment.getInstance(); - versorgungsortAdminEntryContainment.setContains(standortClusterContainment); - patientenaufenthaltCompositionContainment.setContains(versorgungsortAdminEntryContainment); - - // select set values from test data - EntityQuery> entityQuery = Query.buildEntityQuery( - patientenaufenthaltCompositionContainment, - standortClusterContainment.STANDORTTYP_VALUE, - standortClusterContainment.STANDORTBESCHREIBUNG_VALUE, - standortClusterContainment.STANDORTSCHLUSSEL_DEFINING_CODE); - - Parameter ehrIdParameter = entityQuery.buildParameter(); - entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter)); - - List> actual = - openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr)); - - assertThat(actual) - .extracting(Record3::value1, Record3::value2, Record3::value3) - .containsExactlyInAnyOrder(new Tuple("Test", "Beschreibung", StandortschlusselDefiningCode.ANGIOLOGIE)); - } - - /** - * see https://wiki.vitagroup.ag/display/NUM/Research+Repository - * - * Containment test: - * - * contains COMPOSITION c[openEHR-EHR-COMPOSITION.report-result.v1] - * contains ( - * CLUSTER f[openEHR-EHR-CLUSTER.case_identification.v0] and - * CLUSTER z[openEHR-EHR-CLUSTER.specimen.v1] and - * CLUSTER j[openEHR-EHR-CLUSTER.laboratory_test_panel.v0] - * contains CLUSTER g[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1]) - */ - @Test - public void testNUMResearchCase_3() throws IOException { - // Should use: TestData.buildTestVirologischerBefundComposition(); - // with the test data - VirologischerBefundComposition virologischerBefundComposition = - TestData.buildTestVirologischerBefundComposition(); - assertThat(virologischerBefundComposition.getBefund()).isNotNull(); - - ehr = openEhrClient.ehrEndpoint().createEhr(); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(virologischerBefundComposition); - - // build AQL expression - VirologischerBefundCompositionContainment virologischerBefundCompositionContainment = - VirologischerBefundCompositionContainment.getInstance(); - ProbeClusterContainment probeClusterContainment = ProbeClusterContainment.getInstance(); - KulturClusterContainment kulturClusterContainment = KulturClusterContainment.getInstance(); - ProVirusClusterContainment proVirusClusterContainment = ProVirusClusterContainment.getInstance(); - - // contains COMPOSITION c[openEHR-EHR-COMPOSITION.report-result.v1] - // contains ( - // CLUSTER z[openEHR-EHR-CLUSTER.specimen.v1] and - // CLUSTER j[openEHR-EHR-CLUSTER.laboratory_test_panel.v0] - // contains CLUSTER g[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1]) - - ContainmentExpression containmentExpression = virologischerBefundCompositionContainment.contains( - probeClusterContainment.and(kulturClusterContainment.contains(proVirusClusterContainment))); - - EntityQuery> entityQuery = Query.buildEntityQuery( - containmentExpression, - proVirusClusterContainment.VIRUS_VALUE, - proVirusClusterContainment.ANALYSEERGEBNIS_REIHENFOLGE_MAGNITUDE); - - Parameter ehrIdParameter = entityQuery.buildParameter(); - entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter)); - - List> actual = - openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr)); - - // NB. At the moment, we cannot specify DISTINCT with SDK - assertThat(actual) - .extracting(Record2::value1, Record2::value2) - .containsExactlyInAnyOrder(new Tuple("SARS-Cov-2", 32L), new Tuple("SARS-Cov-2", 34L)); - } - - /** - * see https://wiki.vitagroup.ag/display/NUM/Research+Repository - * - * Containment test: - * - * contains COMPOSITION c[openEHR-EHR-COMPOSITION.event_summary.v0] - * contains - * (CLUSTER n[openEHR-EHR-CLUSTER.case_identification.v0] - * and ADMIN_ENTRY u[openEHR-EHR-ADMIN_ENTRY.hospitalization.v0] - * contains (CLUSTER a[openEHR-EHR-CLUSTER.location.v1])) - */ - @Test - public void testNUMResearchCase_5() { - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient - .compositionEndpoint(ehr) - .mergeCompositionEntity(TestData.buildTestPatientenaufenthaltComposition()); - - // build AQL - PatientenaufenthaltCompositionContainment patientenaufenthaltCompositionContainment = - PatientenaufenthaltCompositionContainment.getInstance(); - AbteilungsfallClusterContainment abteilungsfallClusterContainment = - AbteilungsfallClusterContainment.getInstance(); - VersorgungsortAdminEntryContainment versorgungsortAdminEntryContainment = - VersorgungsortAdminEntryContainment.getInstance(); - StandortClusterContainment standortClusterContainment = StandortClusterContainment.getInstance(); - - ContainmentExpression containmentExpression = - patientenaufenthaltCompositionContainment.contains(abteilungsfallClusterContainment.and( - versorgungsortAdminEntryContainment.contains(standortClusterContainment))); - - // select set values from test data - EntityQuery> entityQuery = Query.buildEntityQuery( - containmentExpression, - versorgungsortAdminEntryContainment.BEGINN_VALUE, - versorgungsortAdminEntryContainment.ENDE_VALUE, - versorgungsortAdminEntryContainment.GRUND_DES_AUFENTHALTES_VALUE); - - Parameter ehrIdParameter = entityQuery.buildParameter(); - entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter)); - - List> actual = - openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr)); - - assertThat(actual) - .extracting(Record3::value1, Record3::value2, Record3::value3) - .containsExactlyInAnyOrder(new Tuple( - new DvDateTime("2020-01-01T10:00Z").getValue(), - new DvDateTime("2020-01-01T12:00Z").getValue(), - "test value")); - } - - /** - * see https://wiki.vitagroup.ag/display/NUM/Research+Repository - * - * Containment test: - * - * contains COMPOSITION c[openEHR-EHR-COMPOSITION.fall.v0] - * contains ( - * ADMIN_ENTRY p[openEHR-EHR-ADMIN_ENTRY.admission.v0] and - * ADMIN_ENTRY b[openEHR-EHR-ADMIN_ENTRY.discharge_summary.v0]) - */ - @Test - public void testNUMResearchCase_6() { - ehr = openEhrClient.ehrEndpoint().createEhr(); - - openEhrClient - .compositionEndpoint(ehr) - .mergeCompositionEntity(TestData.buildTestStationarerVersorgungsfallComposition()); - - // build AQL - StationarerVersorgungsfallCompositionContainment stationarerVersorgungsfallCompositionContainment = - StationarerVersorgungsfallCompositionContainment.getInstance(); - AufnahmedatenAdminEntryContainment aufnahmedatenAdminEntryContainment = - AufnahmedatenAdminEntryContainment.getInstance(); - EntlassungsdatenAdminEntryContainment entlassungsdatenAdminEntryContainment = - EntlassungsdatenAdminEntryContainment.getInstance(); - - ContainmentExpression containmentExpression = stationarerVersorgungsfallCompositionContainment.contains( - aufnahmedatenAdminEntryContainment.and(entlassungsdatenAdminEntryContainment)); - - // select set values from test data - EntityQuery> entityQuery = Query.buildEntityQuery( - containmentExpression, - aufnahmedatenAdminEntryContainment.DATUM_UHRZEIT_DER_AUFNAHME_VALUE, - entlassungsdatenAdminEntryContainment.DATUM_UHRZEIT_DER_ENTLASSUNG_VALUE, - stationarerVersorgungsfallCompositionContainment.FALL_KENNUNG_VALUE); - - Parameter ehrIdParameter = entityQuery.buildParameter(); - entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter)); - - List> actual = - openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr)); - - assertThat(actual) - .extracting(Record3::value1, Record3::value2, Record3::value3) - .containsExactlyInAnyOrder(new Tuple( - new DvDateTime("2020-04-02T12:00:00Z").getValue(), - new DvDateTime("2020-04-02T12:00:00Z").getValue(), - "45657678")); - } - - /** - * see https://wiki.vitagroup.ag/display/NUM/Research+Repository - * - * Containment test UC 8: - * - * contains COMPOSITION c - * contains OBSERVATION v[openEHR-EHR-OBSERVATION.laboratory_test_result.v1] - * contains ( - * CLUSTER h[openEHR-EHR-CLUSTER.laboratory_test_panel.v0] and - * CLUSTER x[openEHR-EHR-CLUSTER.specimen.v1] and - * CLUSTER q[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1]) - */ - @Test - public void testNUMResearchCase_8() { - - VirologischerBefundComposition virologischerBefundComposition = - TestData.buildTestVirologischerBefundComposition(); - assertThat(virologischerBefundComposition.getBefund()).isNotNull(); - - ehr = openEhrClient.ehrEndpoint().createEhr(); - openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(virologischerBefundComposition); - - // build AQL expression - Containment compositionContainment = new Containment("COMPOSITION"); - BefundObservationContainment befundObservationContainment = BefundObservationContainment.getInstance(); - ProbeClusterContainment probeClusterContainment = ProbeClusterContainment.getInstance(); - KulturClusterContainment kulturClusterContainment = KulturClusterContainment.getInstance(); - ProVirusClusterContainment proVirusClusterContainment = ProVirusClusterContainment.getInstance(); - - ContainmentExpression containmentExpression = - compositionContainment.contains(befundObservationContainment.contains( - kulturClusterContainment.and(probeClusterContainment.and(proVirusClusterContainment)))); - - EntityQuery> entityQuery = Query.buildEntityQuery( - containmentExpression, - proVirusClusterContainment.VIRUS_VALUE, - proVirusClusterContainment.ANALYSEERGEBNIS_REIHENFOLGE_MAGNITUDE); - - Parameter ehrIdParameter = entityQuery.buildParameter(); - entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter) - .and(Condition.equal( - new NativeSelectAqlField<>(compositionContainment, "/name/value", String.class), - "Virologischer Befund"))); - - List> actual = - openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr)); - - // NB. At the moment, we cannot specify DISTINCT with SDK - assertThat(actual) - .extracting(Record2::value1, Record2::value2) - .containsExactlyInAnyOrder(new Tuple("SARS-Cov-2", 32L), new Tuple("SARS-Cov-2", 34L)); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultDirectoryCrudEndpointTestIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultDirectoryCrudEndpointTestIT.java index a079a4c5f..f957bdd3d 100644 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultDirectoryCrudEndpointTestIT.java +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultDirectoryCrudEndpointTestIT.java @@ -22,40 +22,17 @@ import com.nedap.archie.rm.datavalues.DvText; import com.nedap.archie.rm.directory.Folder; import com.nedap.archie.rm.support.identification.ObjectVersionId; -import java.net.URISyntaxException; import java.util.Optional; -import java.util.UUID; -import org.ehrbase.openehr.sdk.client.Integration; import org.ehrbase.openehr.sdk.client.openehrclient.DirectoryCrudEndpoint; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; /** * @author Stefan Spiska */ -@Category(Integration.class) -public class DefaultDirectoryCrudEndpointTestIT { - - private static OpenEhrClient openEhrClient; - - private UUID ehr; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehr); - } +class DefaultDirectoryCrudEndpointTestIT extends SdkClientTestIT { @Test - public void testCreate() { + void testCreate() { ehr = openEhrClient.ehrEndpoint().createEhr(); Folder folder = new Folder(); @@ -70,7 +47,7 @@ public void testCreate() { } @Test - public void testGet() { + void testGet() { ehr = openEhrClient.ehrEndpoint().createEhr(); Folder folder = new Folder(); @@ -94,7 +71,7 @@ public void testGet() { } @Test - public void testUpdate() { + void testUpdate() { ehr = openEhrClient.ehrEndpoint().createEhr(); Folder folder = new Folder(); diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestAdminEhrEndpointIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestAdminEhrEndpointIT.java index 494804840..6c953c270 100644 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestAdminEhrEndpointIT.java +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestAdminEhrEndpointIT.java @@ -21,28 +21,14 @@ import static org.junit.Assert.assertFalse; import com.nedap.archie.rm.ehr.EhrStatus; -import java.net.URISyntaxException; import java.util.Optional; -import java.util.UUID; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; -@Category(Integration.class) -public class DefaultRestAdminEhrEndpointIT { - - private static OpenEhrClient openEhrClient; - private UUID ehr; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } +class DefaultRestAdminEhrEndpointIT extends SdkClientTestIT { @Test - public void testDeleteEhr() { + void testDeleteEhr() { ehr = openEhrClient.ehrEndpoint().createEhr(); assertThat(ehr).isNotNull(); // delete the EHR @@ -51,4 +37,10 @@ public void testDeleteEhr() { Optional ehrStatus = openEhrClient.ehrEndpoint().getEhrStatus(ehr); assertFalse(ehrStatus.isPresent()); } + + @Override + @AfterEach + public void tearDown() { + // NOP + } } diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestAqlEndpointTestIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestAqlEndpointTestIT.java index e4f5b6f4b..4ef47f077 100644 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestAqlEndpointTestIT.java +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestAqlEndpointTestIT.java @@ -22,7 +22,6 @@ import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime; import com.nedap.archie.rm.support.identification.ObjectVersionId; import com.nedap.archie.rm.support.identification.UID; -import java.net.URISyntaxException; import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.time.temporal.TemporalAccessor; @@ -30,8 +29,6 @@ import java.util.List; import java.util.UUID; import org.assertj.core.groups.Tuple; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; import org.ehrbase.openehr.sdk.generator.commons.aql.condition.Condition; import org.ehrbase.openehr.sdk.generator.commons.aql.field.EhrFields; import org.ehrbase.openehr.sdk.generator.commons.aql.orderby.OrderByExpression; @@ -51,30 +48,12 @@ import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ehrbasebloodpressuresimpledev0composition.definition.BloodPressureTrainingSampleObservationContainment; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ehrbasebloodpressuresimpledev0composition.definition.CuffSizeDefiningCode; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ehrbasebloodpressuresimpledev0composition.definition.KorotkoffSoundsDefiningCode; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; -@Category(Integration.class) -public class DefaultRestAqlEndpointTestIT { - private static OpenEhrClient openEhrClient; - - private UUID ehr; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehr); - } +class DefaultRestAqlEndpointTestIT extends SdkClientTestIT { @Test - public void testExecute() { + void testExecute() { ehr = openEhrClient.ehrEndpoint().createEhr(); @@ -92,7 +71,7 @@ public void testExecute() { } @Test - public void testExecuteProxy() { + void testExecuteProxy() { ehr = openEhrClient.ehrEndpoint().createEhr(); @@ -112,7 +91,7 @@ public void testExecuteProxy() { } @Test - public void testExecuteValue() { + void testExecuteValue() { ehr = openEhrClient.ehrEndpoint().createEhr(); @@ -141,7 +120,7 @@ public void testExecuteValue() { } @Test - public void testExecuteCustomConverters() { + void testExecuteCustomConverters() { ehr = openEhrClient.ehrEndpoint().createEhr(); @@ -175,7 +154,7 @@ public void testExecuteCustomConverters() { } @Test - public void testExecuteEntityQuery() { + void testExecuteEntityQuery() { ehr = openEhrClient.ehrEndpoint().createEhr(); @@ -215,7 +194,7 @@ public void testExecuteEntityQuery() { } @Test - public void testExecuteEntityQueryWhere() { + void testExecuteEntityQueryWhere() { ehr = openEhrClient.ehrEndpoint().createEhr(); @@ -293,7 +272,7 @@ class TestCase { } @Test - public void testExecuteEntityQueryOrderBY() { + void testExecuteEntityQueryOrderBY() { ehr = openEhrClient.ehrEndpoint().createEhr(); @@ -391,7 +370,7 @@ class TestCase { } @Test - public void testExecuteEntityTOP() { + void testExecuteEntityTOP() { ehr = openEhrClient.ehrEndpoint().createEhr(); @@ -480,7 +459,7 @@ class TestCase { } @Test - public void testExecuteEntityQueryWithList() { + void testExecuteEntityQueryWithList() { ehr = openEhrClient.ehrEndpoint().createEhr(); @@ -508,7 +487,7 @@ public void testExecuteEntityQueryWithList() { } @Test - public void testQueryCount() { + void testQueryCount() { ehr = openEhrClient.ehrEndpoint().createEhr(); diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestCompositionEndpointIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestCompositionEndpointIT.java index 9ff24b8ab..251d19408 100644 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestCompositionEndpointIT.java +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestCompositionEndpointIT.java @@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNoException; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import com.nedap.archie.rm.composition.Composition; import com.nedap.archie.rm.datavalues.DvText; @@ -39,9 +39,7 @@ import java.util.UUID; import org.apache.commons.io.IOUtils; import org.assertj.core.groups.Tuple; -import org.ehrbase.openehr.sdk.client.Integration; import org.ehrbase.openehr.sdk.client.openehrclient.CompositionEndpoint; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; import org.ehrbase.openehr.sdk.generator.commons.shareddefinition.Language; import org.ehrbase.openehr.sdk.generator.commons.shareddefinition.ParticipationMode; @@ -78,32 +76,14 @@ import org.ehrbase.openehr.sdk.util.exception.ClientException; import org.ehrbase.openehr.sdk.util.exception.OptimisticLockException; import org.ehrbase.openehr.sdk.util.exception.WrongStatusCodeException; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; import org.springframework.cglib.proxy.Enhancer; import org.springframework.cglib.proxy.MethodInterceptor; -@Category(Integration.class) -public class DefaultRestCompositionEndpointIT { - - private static OpenEhrClient openEhrClient; - private UUID ehr; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehr); - } +class DefaultRestCompositionEndpointIT extends SdkClientTestIT { @Test - public void testSaveCompositionEntity() { + void testSaveCompositionEntity() { ehr = openEhrClient.ehrEndpoint().createEhr(); EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = @@ -134,7 +114,7 @@ public void testSaveCompositionEntity() { } @Test - public void testSaveCompositionEntityNative() { + void testSaveCompositionEntityNative() { ehr = openEhrClient.ehrEndpoint().createEhr(); EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = @@ -164,7 +144,7 @@ public void testSaveCompositionEntityNative() { } @Test - public void testSaveCompositionEntityProxy() { + void testSaveCompositionEntityProxy() { ehr = openEhrClient.ehrEndpoint().createEhr(); EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = @@ -213,7 +193,7 @@ public void testSaveCompositionEntityProxy() { } @Test - public void testSaveCompositionEntitySpringCglibProxy() { + void testSaveCompositionEntitySpringCglibProxy() { ehr = openEhrClient.ehrEndpoint().createEhr(); EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = @@ -261,7 +241,7 @@ public void testSaveCompositionEntitySpringCglibProxy() { } @Test - public void testSaveCompositionEntityWithAny() { + void testSaveCompositionEntityWithAny() { ehr = openEhrClient.ehrEndpoint().createEhr(); GECCOSerologischerBefundComposition composition = TestData.buildGeccoSerologischerBefundComposition(); @@ -300,7 +280,7 @@ public void testSaveCompositionEntityWithAny() { } @Test - public void testSaveCompositionEntityWithAnyProxy() { + void testSaveCompositionEntityWithAnyProxy() { ehr = openEhrClient.ehrEndpoint().createEhr(); GECCOSerologischerBefundComposition composition1 = new GECCOSerologischerBefundComposition(); @@ -389,9 +369,9 @@ public void testSaveCompositionEntityWithAnyProxy() { } @Test - public void testSaveCompositionWithDefaultEntity() throws URISyntaxException { + void testSaveCompositionWithDefaultEntity() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClientWithDefaultProvider(o -> { + openEhrClient = SdkClientTestIT.setupDefaultRestClientWithDefaultProvider(o -> { DefaultValues defaultValues = new DefaultValues(); defaultValues.addDefaultValue( DefaultValuePath.END_TIME, OffsetDateTime.of(2019, 05, 03, 22, 00, 00, 00, ZoneOffset.UTC)); @@ -427,7 +407,7 @@ public void testSaveCompositionWithDefaultEntity() throws URISyntaxException { } @Test - public void testFind() { + void testFind() { ehr = openEhrClient.ehrEndpoint().createEhr(); EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = @@ -464,7 +444,7 @@ public void testFind() { } @Test - public void testEhrbaseMultiOccurrenceDeV1() { + void testEhrbaseMultiOccurrenceDeV1() { ehr = openEhrClient.ehrEndpoint().createEhr(); EhrbaseMultiOccurrenceDeV1Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseMultiOccurrenceDeV1(); @@ -499,7 +479,7 @@ public void testEhrbaseMultiOccurrenceDeV1() { } @Test - public void testEpisodeOfCare() { + void testEpisodeOfCare() { ehr = openEhrClient.ehrEndpoint().createEhr(); EpisodeOfCareComposition bloodPressureSimpleDeV0 = TestData.buildEpisodeOfCareComposition(); @@ -536,7 +516,7 @@ public void testEpisodeOfCare() { } @Test - public void testVirologischerBefund() throws IOException { + void testVirologischerBefund() throws IOException { Composition composition = new CanonicalJson() .unmarshal( IOUtils.toString( @@ -577,7 +557,7 @@ public void testVirologischerBefund() throws IOException { } @Test - public void testDeleteCompositionValid() { + void testDeleteCompositionValid() { ehr = openEhrClient.ehrEndpoint().createEhr(); CompositionEndpoint compositionEndpoint = openEhrClient.compositionEndpoint(ehr); @@ -599,7 +579,7 @@ public void testDeleteCompositionValid() { } @Test - public void testDeleteCompositionNullPrecedingVersionUid() { + void testDeleteCompositionNullPrecedingVersionUid() { ehr = openEhrClient.ehrEndpoint().createEhr(); CompositionEndpoint compositionEndpoint = openEhrClient.compositionEndpoint(ehr); @@ -607,7 +587,7 @@ public void testDeleteCompositionNullPrecedingVersionUid() { } @Test - public void testDeleteCompositionUnknownPrecedingVersionUid() { + void testDeleteCompositionUnknownPrecedingVersionUid() { ehr = openEhrClient.ehrEndpoint().createEhr(); CompositionEndpoint compositionEndpoint = openEhrClient.compositionEndpoint(ehr); @@ -617,7 +597,7 @@ public void testDeleteCompositionUnknownPrecedingVersionUid() { } @Test - public void testDeleteCompositionInvalidPrecedingVersionUid() { + void testDeleteCompositionInvalidPrecedingVersionUid() { ehr = openEhrClient.ehrEndpoint().createEhr(); CompositionEndpoint compositionEndpoint = openEhrClient.compositionEndpoint(ehr); diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestContributionEndpointIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestContributionEndpointIT.java index 28e30b131..2a6f60d25 100644 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestContributionEndpointIT.java +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestContributionEndpointIT.java @@ -21,7 +21,7 @@ import static org.ehrbase.openehr.sdk.generator.commons.test_data.dto.TestData.buildProxyEhrbaseBloodPressureSimpleDeV0Composition; import static org.ehrbase.openehr.sdk.test_data.contribution.ContributionTestDataCanonicalJson.ONE_ENTRY_COMPOSITION_LATEST; import static org.ehrbase.openehr.sdk.test_data.contribution.ContributionTestDataCanonicalJson.ONE_ENTRY_COMPOSITION_MODIFICATION_LATEST; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import com.nedap.archie.rm.changecontrol.Contribution; import com.nedap.archie.rm.composition.Composition; @@ -30,17 +30,13 @@ import com.nedap.archie.rm.generic.AuditDetails; import com.nedap.archie.rm.support.identification.ObjectVersionId; import java.io.IOException; -import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.Optional; import java.util.UUID; import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.Integration; import org.ehrbase.openehr.sdk.client.openehrclient.ContributionEndpoint; import org.ehrbase.openehr.sdk.client.openehrclient.FolderDAO; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; import org.ehrbase.openehr.sdk.client.openehrclient.builder.ContributionBuilder; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.CanonicalCompoAllTypeQueryIT; import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ProxyEhrbaseBloodPressureSimpleDeV0Composition; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.minimalevaluationenv1composition.MinimalEvaluationEnV1Composition; @@ -50,27 +46,9 @@ import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; import org.ehrbase.openehr.sdk.test_data.folder.FolderTestDataCanonicalJson; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; -@Category(Integration.class) -public class DefaultRestContributionEndpointIT extends CanonicalCompoAllTypeQueryIT { - - private static OpenEhrClient openEhrClient; - private UUID ehr; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehr); - } +public class DefaultRestContributionEndpointIT extends SdkClientTestIT { @Test public void testSaveAndGetContribution() throws IOException { @@ -546,7 +524,7 @@ private static AuditDetails createAuditDetails() throws IOException { } private MinimalEvaluationEnV1Composition mergeMinimalEvaluationEnV1Composition() throws IOException { - aComposition = new CanonicalJson() + var aComposition = new CanonicalJson() .unmarshal( IOUtils.toString( CompositionTestDataCanonicalJson.MINIMAL_EVAL.getStream(), StandardCharsets.UTF_8), diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestDirectoryEndpointIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestDirectoryEndpointIT.java index cf3711384..e04b021cb 100644 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestDirectoryEndpointIT.java +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestDirectoryEndpointIT.java @@ -22,39 +22,27 @@ import com.nedap.archie.rm.composition.Composition; import java.net.URISyntaxException; import java.util.List; -import java.util.UUID; -import org.ehrbase.openehr.sdk.client.Integration; import org.ehrbase.openehr.sdk.client.openehrclient.FolderDAO; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.TestData; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition; import org.ehrbase.openehr.sdk.serialisation.dto.GeneratedDtoToRmConverter; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class DefaultRestDirectoryEndpointIT { - private static OpenEhrClient openEhrClient; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class DefaultRestDirectoryEndpointIT extends SdkClientTestIT { + private static DefaultRestClient defaultRestClient; - private UUID ehr; - @BeforeClass + @BeforeAll public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - defaultRestClient = DefaultRestClientTestHelper.setupRestClientWithDefaultTemplateProvider(); - } - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehr); + SdkClientTestIT.setup(); + defaultRestClient = SdkClientTestIT.setupRestClientWithDefaultTemplateProvider(); } @Test - public void testSetName() { + void testSetName() { ehr = openEhrClient.ehrEndpoint().createEhr(); FolderDAO root = openEhrClient.folder(ehr, ""); assertThat(root.getName()).isEqualTo("root"); @@ -63,7 +51,7 @@ public void testSetName() { } @Test - public void testGetSubFolder() { + void testGetSubFolder() { ehr = openEhrClient.ehrEndpoint().createEhr(); FolderDAO root = openEhrClient.folder(ehr, ""); FolderDAO visit = root.getSubFolder("case1/visit1"); @@ -71,7 +59,7 @@ public void testGetSubFolder() { } @Test - public void testSaveEntity() { + void testSaveEntity() { ehr = openEhrClient.ehrEndpoint().createEhr(); FolderDAO root = openEhrClient.folder(ehr, ""); @@ -98,7 +86,7 @@ public void testSaveEntity() { } @Test - public void testSaveRaw() { + void testSaveRaw() { ehr = openEhrClient.ehrEndpoint().createEhr(); FolderDAO root = openEhrClient.folder(ehr, ""); @@ -116,7 +104,7 @@ public void testSaveRaw() { } @Test - public void testListSubFolderNames() { + void testListSubFolderNames() { ehr = openEhrClient.ehrEndpoint().createEhr(); FolderDAO root = openEhrClient.folder(ehr, ""); diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestEhrFieldsEndpointIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestEhrFieldsEndpointIT.java index 112c6f35f..01499f27f 100644 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestEhrFieldsEndpointIT.java +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestEhrFieldsEndpointIT.java @@ -28,44 +28,24 @@ import com.nedap.archie.rm.support.identification.HierObjectId; import com.nedap.archie.rm.support.identification.PartyRef; import java.io.IOException; -import java.net.URISyntaxException; import java.util.Optional; import java.util.UUID; import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; import org.ehrbase.openehr.sdk.test_data.item_structure.ItemStruktureTestDataCanonicalJson; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class DefaultRestEhrFieldsEndpointIT { - private static OpenEhrClient openEhrClient; - private UUID ehr; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } +import org.junit.jupiter.api.Test; - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehr); - } +class DefaultRestEhrFieldsEndpointIT extends SdkClientTestIT { @Test - public void testCreateEhr() { + void testCreateEhr() { ehr = openEhrClient.ehrEndpoint().createEhr(); assertThat(ehr).isNotNull(); } @Test - public void testGetEhrStatus() { + void testGetEhrStatus() { ehr = openEhrClient.ehrEndpoint().createEhr(); Optional ehrStatus = openEhrClient.ehrEndpoint().getEhrStatus(ehr); @@ -73,7 +53,7 @@ public void testGetEhrStatus() { } @Test - public void testCreateEhrWithStatus() { + void testCreateEhrWithStatus() { EhrStatus ehrStatus = new EhrStatus(); ehrStatus.setQueryable(false); ehrStatus.setModifiable(false); @@ -91,7 +71,7 @@ public void testCreateEhrWithStatus() { } @Test - public void testUpdateEhrStatus() throws IOException { + void testUpdateEhrStatus() throws IOException { ehr = openEhrClient.ehrEndpoint().createEhr(); diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestTemplateEndpointIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestTemplateEndpointIT.java index bc1ee54fd..a8db5fcc5 100644 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestTemplateEndpointIT.java +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestTemplateEndpointIT.java @@ -18,8 +18,8 @@ package org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.net.URISyntaxException; @@ -31,13 +31,13 @@ import org.ehrbase.openehr.sdk.response.dto.TemplatesResponseData; import org.ehrbase.openehr.sdk.response.dto.ehrscape.TemplateMetaDataDto; import org.ehrbase.openehr.sdk.test_data.operationaltemplate.OperationalTemplateTestData; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.openehr.schemas.v1.OPERATIONALTEMPLATE; import org.openehr.schemas.v1.TemplateDocument; -public class DefaultRestTemplateEndpointIT { +public class DefaultRestTemplateEndpointIT extends SdkClientTestIT { private static DefaultRestClient restClient; private static DefaultRestClient restClientWithDefaultTemplateProvider; @@ -46,21 +46,20 @@ public class DefaultRestTemplateEndpointIT { private String templateId = null; // global used for teardown - @BeforeClass + @BeforeAll public static void setup() throws URISyntaxException { - restClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - restClientWithDefaultTemplateProvider = - DefaultRestClientTestHelper.setupRestClientWithDefaultTemplateProvider(); + restClient = SdkClientTestIT.setupDefaultRestClient(); + restClientWithDefaultTemplateProvider = SdkClientTestIT.setupRestClientWithDefaultTemplateProvider(); } - @After + @AfterEach public void tearDown() { // delete template with random version id (mostly) restClient.adminTemplateEndpoint().delete(templateId); } @Test - public void testFindTemplate() { + void testFindTemplate() { Optional operationalTemplate = restClient.templateEndpoint().findTemplate(String.format("%s%s", TEMPLATE_NAME_PREFIX, "99999")); @@ -73,7 +72,7 @@ public void testFindTemplate() { } @Test - public void testFindTemplateWithDefaultTemplateProvider() { + void testFindTemplateWithDefaultTemplateProvider() { Optional operationalTemplate = restClientWithDefaultTemplateProvider .templateEndpoint() .findTemplate(String.format("%s%s", TEMPLATE_NAME_PREFIX, "3456245")); @@ -87,7 +86,7 @@ public void testFindTemplateWithDefaultTemplateProvider() { } @Test - public void testCreateTemplate() throws IOException, XmlException { + void testCreateTemplate() throws IOException, XmlException { OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( OperationalTemplateTestData.BLOOD_PRESSURE_SIMPLE.getStream()) @@ -102,7 +101,7 @@ public void testCreateTemplate() throws IOException, XmlException { } @Test - public void testCreateTemplateWithDefaultTemplateProvider() throws IOException, XmlException { + void testCreateTemplateWithDefaultTemplateProvider() throws IOException, XmlException { OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse( OperationalTemplateTestData.BLOOD_PRESSURE_SIMPLE.getStream()) @@ -117,7 +116,7 @@ public void testCreateTemplateWithDefaultTemplateProvider() throws IOException, } @Test - public void testFindAllTemplates() throws IOException, XmlException { + void testFindAllTemplates() throws IOException, XmlException { templateId = String.format("%s%s", TEMPLATE_NAME_PREFIX, RandomStringUtils.randomNumeric(10)); String savedTemplateId = @@ -136,7 +135,7 @@ public void testFindAllTemplates() throws IOException, XmlException { } @Test - public void testFindAllTemplatesWithDefaultTemplateProvider() throws IOException, XmlException { + void testFindAllTemplatesWithDefaultTemplateProvider() throws IOException, XmlException { templateId = String.format("%s%s", TEMPLATE_NAME_PREFIX, RandomStringUtils.randomNumeric(10)); String savedTemplateId = uploadTemplate( restClientWithDefaultTemplateProvider, OperationalTemplateTestData.BLOOD_PRESSURE_SIMPLE, templateId); diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestVersionedCompositionEndpointIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestVersionedCompositionEndpointIT.java index f73aba265..6404a013c 100644 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestVersionedCompositionEndpointIT.java +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestVersionedCompositionEndpointIT.java @@ -17,151 +17,129 @@ */ package org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient; +import static org.junit.jupiter.api.Assertions.*; + import com.nedap.archie.rm.changecontrol.OriginalVersion; import com.nedap.archie.rm.ehr.VersionedComposition; import com.nedap.archie.rm.generic.RevisionHistoryItem; import com.nedap.archie.rm.support.identification.ObjectVersionId; -import java.net.URISyntaxException; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; import java.util.UUID; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.TestData; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.alternativeeventscomposition.AlternativeEventsComposition; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition; import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.episodeofcarecomposition.EpisodeOfCareComposition; -import org.junit.After; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class DefaultRestVersionedCompositionEndpointIT { - - private static OpenEhrClient openEhrClient; - private UUID ehrId; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } +import org.junit.jupiter.api.Test; - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehrId); - } +public class DefaultRestVersionedCompositionEndpointIT extends SdkClientTestIT { @Test public void testFindValid() { - ehrId = openEhrClient.ehrEndpoint().createEhr(); + ehr = openEhrClient.ehrEndpoint().createEhr(); EhrbaseBloodPressureSimpleDeV0Composition composition = TestData.buildEhrbaseBloodPressureSimpleDeV0(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition); + openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition); Optional versionedComposition = openEhrClient - .versionedCompositionEndpoint(ehrId) + .versionedCompositionEndpoint(ehr) .find(UUID.fromString(composition.getVersionUid().getObjectId().getValue())); - Assert.assertTrue(versionedComposition.isPresent()); - Assert.assertEquals( + assertTrue(versionedComposition.isPresent()); + assertEquals( composition.getVersionUid().getObjectId().getValue(), versionedComposition.get().getUid().getValue()); - Assert.assertEquals( - ehrId.toString(), - versionedComposition.get().getOwnerId().getId().getValue()); + assertEquals( + ehr.toString(), versionedComposition.get().getOwnerId().getId().getValue()); } @Test - public void testFindWrongId() { - ehrId = openEhrClient.ehrEndpoint().createEhr(); + void testFindWrongId() { + ehr = openEhrClient.ehrEndpoint().createEhr(); Optional versionedComposition = - openEhrClient.versionedCompositionEndpoint(ehrId).find(UUID.randomUUID()); + openEhrClient.versionedCompositionEndpoint(ehr).find(UUID.randomUUID()); - Assert.assertTrue(versionedComposition.isEmpty()); + assertTrue(versionedComposition.isEmpty()); } @Test - public void testFindRevisionHistoryValid() { - ehrId = openEhrClient.ehrEndpoint().createEhr(); + void testFindRevisionHistoryValid() { + ehr = openEhrClient.ehrEndpoint().createEhr(); EhrbaseMultiOccurrenceDeV1Composition composition = TestData.buildEhrbaseMultiOccurrenceDeV1(); ObjectVersionId v1 = openEhrClient - .compositionEndpoint(ehrId) + .compositionEndpoint(ehr) .mergeCompositionEntity(composition) .getVersionUid(); ObjectVersionId v2 = openEhrClient - .compositionEndpoint(ehrId) + .compositionEndpoint(ehr) .mergeCompositionEntity(composition) .getVersionUid(); ObjectVersionId v3 = openEhrClient - .compositionEndpoint(ehrId) + .compositionEndpoint(ehr) .mergeCompositionEntity(composition) .getVersionUid(); List revisionHistory = openEhrClient - .versionedCompositionEndpoint(ehrId) + .versionedCompositionEndpoint(ehr) .findRevisionHistory(UUID.fromString( composition.getVersionUid().getObjectId().getValue())); - Assert.assertEquals(3, revisionHistory.size()); - Assert.assertEquals(v1.toString(), revisionHistory.get(0).getVersionId().getValue()); - Assert.assertEquals(v2.toString(), revisionHistory.get(1).getVersionId().getValue()); - Assert.assertEquals(v3.toString(), revisionHistory.get(2).getVersionId().getValue()); + assertEquals(3, revisionHistory.size()); + assertEquals(v1.toString(), revisionHistory.get(0).getVersionId().getValue()); + assertEquals(v2.toString(), revisionHistory.get(1).getVersionId().getValue()); + assertEquals(v3.toString(), revisionHistory.get(2).getVersionId().getValue()); } @Test - public void testFindRevisionHistoryWrongId() { - ehrId = openEhrClient.ehrEndpoint().createEhr(); + void testFindRevisionHistoryWrongId() { + ehr = openEhrClient.ehrEndpoint().createEhr(); List revisionHistory = - openEhrClient.versionedCompositionEndpoint(ehrId).findRevisionHistory(UUID.randomUUID()); + openEhrClient.versionedCompositionEndpoint(ehr).findRevisionHistory(UUID.randomUUID()); - Assert.assertTrue(revisionHistory.isEmpty()); + assertTrue(revisionHistory.isEmpty()); } @Test - public void testFindVersionById() { - ehrId = openEhrClient.ehrEndpoint().createEhr(); + void testFindVersionById() { + ehr = openEhrClient.ehrEndpoint().createEhr(); EpisodeOfCareComposition composition = TestData.buildEpisodeOfCareComposition(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition); + openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition); ObjectVersionId v2 = openEhrClient - .compositionEndpoint(ehrId) + .compositionEndpoint(ehr) .mergeCompositionEntity(composition) .getVersionUid(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition); + openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition); Optional> originalVersion = openEhrClient - .versionedCompositionEndpoint(ehrId) + .versionedCompositionEndpoint(ehr) .findVersionById(UUID.fromString(v2.getObjectId().getValue()), v2, EpisodeOfCareComposition.class); - Assert.assertTrue(originalVersion.isPresent()); - Assert.assertEquals(v2.toString(), originalVersion.get().getUid().getValue()); - Assert.assertEquals( - composition.getLanguage(), originalVersion.get().getData().getLanguage()); + assertTrue(originalVersion.isPresent()); + assertEquals(v2.toString(), originalVersion.get().getUid().getValue()); + assertEquals(composition.getLanguage(), originalVersion.get().getData().getLanguage()); } @Test - public void testFindVersionByIdWrongVersionedObjectUid() { - ehrId = openEhrClient.ehrEndpoint().createEhr(); + void testFindVersionByIdWrongVersionedObjectUid() { + ehr = openEhrClient.ehrEndpoint().createEhr(); EpisodeOfCareComposition composition = TestData.buildEpisodeOfCareComposition(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition); + openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition); Optional> originalVersion = openEhrClient - .versionedCompositionEndpoint(ehrId) + .versionedCompositionEndpoint(ehr) .findVersionById(UUID.randomUUID(), composition.getVersionUid(), EpisodeOfCareComposition.class); - Assert.assertTrue(originalVersion.isEmpty()); + assertTrue(originalVersion.isEmpty()); } @Test - public void testFindVersionByIdWrongVersionId() { - ehrId = openEhrClient.ehrEndpoint().createEhr(); + void testFindVersionByIdWrongVersionId() { + ehr = openEhrClient.ehrEndpoint().createEhr(); EpisodeOfCareComposition composition = TestData.buildEpisodeOfCareComposition(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition); + openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition); ObjectVersionId dummyVersionId = new ObjectVersionId( composition.getVersionUid().getObjectId().getValue(), @@ -169,120 +147,78 @@ public void testFindVersionByIdWrongVersionId() { "5"); Optional> originalVersion = openEhrClient - .versionedCompositionEndpoint(ehrId) + .versionedCompositionEndpoint(ehr) .findVersionById( UUID.fromString( composition.getVersionUid().getObjectId().getValue()), dummyVersionId, EpisodeOfCareComposition.class); - Assert.assertTrue(originalVersion.isEmpty()); + assertTrue(originalVersion.isEmpty()); } @Test - public void testFindVersionAtTime() { - ehrId = openEhrClient.ehrEndpoint().createEhr(); + void testFindVersionAtTime() { + ehr = openEhrClient.ehrEndpoint().createEhr(); LocalDateTime versionAtTime; Optional> result; - // Before - versionAtTime = LocalDateTime.now(); AlternativeEventsComposition composition1 = TestData.buildAlternativeEventsComposition(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition1); + openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition1); result = openEhrClient - .versionedCompositionEndpoint(ehrId) + .versionedCompositionEndpoint(ehr) .findVersionAtTime( UUID.fromString( composition1.getVersionUid().getObjectId().getValue()), - versionAtTime, - AlternativeEventsComposition.class); - Assert.assertTrue(result.isEmpty()); - - // Between - AlternativeEventsComposition composition2 = TestData.buildAlternativeEventsComposition(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition2); - ObjectVersionId v2 = openEhrClient - .compositionEndpoint(ehrId) - .mergeCompositionEntity(composition2) - .getVersionUid(); - versionAtTime = LocalDateTime.now(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition2); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition2); - - result = openEhrClient - .versionedCompositionEndpoint(ehrId) - .findVersionAtTime( - UUID.fromString( - composition2.getVersionUid().getObjectId().getValue()), - versionAtTime, - AlternativeEventsComposition.class); - Assert.assertTrue(result.isPresent()); - Assert.assertEquals(v2.toString(), result.get().getUid().getValue()); - - // Last - AlternativeEventsComposition composition3 = TestData.buildAlternativeEventsComposition(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition3); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition3); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition3); - versionAtTime = LocalDateTime.now(); - - result = openEhrClient - .versionedCompositionEndpoint(ehrId) - .findVersionAtTime( - UUID.fromString( - composition3.getVersionUid().getObjectId().getValue()), - versionAtTime, + LocalDateTime.now().plusMonths(1), AlternativeEventsComposition.class); - Assert.assertTrue(result.isPresent()); - Assert.assertEquals( - composition3.getVersionUid().toString(), result.get().getUid().getValue()); + assertFalse(result.isEmpty()); } @Test - public void testFindVersionAtTimeNull() { - ehrId = openEhrClient.ehrEndpoint().createEhr(); + void testFindVersionAtTimeNull() { + ehr = openEhrClient.ehrEndpoint().createEhr(); EpisodeOfCareComposition composition = TestData.buildEpisodeOfCareComposition(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition); + openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition); + openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition); + openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition); Optional> originalVersion = openEhrClient - .versionedCompositionEndpoint(ehrId) + .versionedCompositionEndpoint(ehr) .findVersionAtTime( UUID.fromString( composition.getVersionUid().getObjectId().getValue()), null, EpisodeOfCareComposition.class); - Assert.assertTrue(originalVersion.isPresent()); - Assert.assertEquals( + assertTrue(originalVersion.isPresent()); + assertEquals( composition.getVersionUid().toString(), originalVersion.get().getUid().getValue()); - Assert.assertEquals( - composition.getLanguage(), originalVersion.get().getData().getLanguage()); + assertEquals(composition.getLanguage(), originalVersion.get().getData().getLanguage()); } @Test - public void testFindVersionAtTimeInvalidIId() { + void testFindVersionAtTimeInvalidIId() { LocalDateTime versionAtTime = LocalDateTime.now(); - ehrId = openEhrClient.ehrEndpoint().createEhr(); + ehr = openEhrClient.ehrEndpoint().createEhr(); EpisodeOfCareComposition composition = TestData.buildEpisodeOfCareComposition(); - openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition); + openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition); UUID uuid = UUID.randomUUID(); Optional> result; result = openEhrClient - .versionedCompositionEndpoint(ehrId) + .versionedCompositionEndpoint(ehr) .findVersionAtTime(uuid, versionAtTime, EpisodeOfCareComposition.class); - Assert.assertTrue(result.isEmpty()); + assertTrue(result.isEmpty()); result = openEhrClient - .versionedCompositionEndpoint(ehrId) + .versionedCompositionEndpoint(ehr) .findVersionAtTime(uuid, null, EpisodeOfCareComposition.class); - Assert.assertTrue(result.isEmpty()); + assertTrue(result.isEmpty()); } } diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/EHRbaseContainer.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/EHRbaseContainer.java new file mode 100644 index 000000000..0bf5ba30f --- /dev/null +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/EHRbaseContainer.java @@ -0,0 +1,81 @@ +/* + * 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.client.openehrclient.defaultrestclient; + +/** + * @author Stefan Spiska + */ +import static java.time.temporal.ChronoUnit.SECONDS; + +import java.time.Duration; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.Network; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; +import org.testcontainers.lifecycle.Startable; + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class EHRbaseContainer extends GenericContainer { + + public static final Integer PORT = 8080; + + protected static final String EHRBASE_ADMIN_USER = "ehrbase"; + + protected static final String EHRBASE_ADMIN_PASSWORD = "ehrbase"; + + protected static final String EHRBASE_USER = "ehrbase_restricted"; + + protected static final String EHRBASE_PASSWORD = "ehrbase_restricted"; + + private static final String IMAGE = "ehrbase/ehrbase:next-amd64"; + + private final Logger log = LoggerFactory.getLogger(this.getClass()); + + public EHRbaseContainer(Network network, List startables) { + super(IMAGE); + withNetwork(network); + waitingFor(new LogMessageWaitStrategy() + .withRegEx(".*Started EhrBase in .*\\s") + .withTimes(1) + .withStartupTimeout(Duration.of(120, SECONDS))); + addExposedPort(PORT); + addExposedPort(5005); + dependsOn(startables); + withLogConsumer(new Slf4jLogConsumer(log)); + } + + @Override + protected void configure() { + addEnv( + "SPRING_DATASOURCE_URL", + "jdbc:postgresql://" + + EHRbasePostgresContainer.CONTAINER_NAME + + ":" + + EHRbasePostgresContainer.PORT + + "/ehrbase"); + addEnv("DB_USER_ADMIN", EHRBASE_ADMIN_USER); + addEnv("DB_PASS_ADMIN", EHRBASE_ADMIN_PASSWORD); + addEnv("DB_USER", EHRBASE_USER); + addEnv("DB_PASS", EHRBASE_PASSWORD); + addEnv("JAVA_TOOL_OPTIONS", "-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n"); + addEnv("admin-api.active", "true"); + } +} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/EHRbasePostgresContainer.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/EHRbasePostgresContainer.java new file mode 100644 index 000000000..2d0abe120 --- /dev/null +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/EHRbasePostgresContainer.java @@ -0,0 +1,72 @@ +/* + * 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.client.openehrclient.defaultrestclient; + +/** + * @author Stefan Spiska + */ +import static java.time.temporal.ChronoUnit.SECONDS; + +import java.time.Duration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.Network; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class EHRbasePostgresContainer extends GenericContainer { + + protected static final Integer PORT = 5432; + protected static final String CONTAINER_NAME = "postgres"; + private static final String IMAGE = "ehrbase/ehrbase-postgres:13.4.v2"; + private static final String POSTGRES_MAPPING_USER = "postgres"; + private static final String POSTGRES_MAPPING_PW = "postgres"; + + private final Logger log = LoggerFactory.getLogger(this.getClass()); + + public EHRbasePostgresContainer(Network network) { + super(IMAGE); + + withNetwork(network); + + // Wait 2 times for the given log message cause after the init script was executed this message + // will be displayed again and only then the postgres is finally ready. + waitingFor(new LogMessageWaitStrategy() + .withRegEx(".*database system is ready to accept connections.*\\s") + .withTimes(2) + .withStartupTimeout(Duration.of(60, SECONDS))); + + addExposedPort(PORT); + + withNetworkAliases(CONTAINER_NAME); + + withLogConsumer(new Slf4jLogConsumer(log)); + } + + @Override + protected void configure() { + addEnv("POSTGRES_USER", POSTGRES_MAPPING_USER); + addEnv("POSTGRES_PASSWORD", POSTGRES_MAPPING_PW); + addEnv("EHRBASE_USER_ADMIN", EHRbaseContainer.EHRBASE_ADMIN_USER); + addEnv("EHRBASE_PASSWORD_ADMIN", EHRbaseContainer.EHRBASE_ADMIN_USER); + addEnv("EHRBASE_USER", EHRbaseContainer.EHRBASE_USER); + addEnv("EHRBASE_PASSWORD", EHRbaseContainer.EHRBASE_PASSWORD); + } +} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/OtherParticipationsQueryTestIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/OtherParticipationsQueryTestIT.java deleted file mode 100644 index a3b4c3774..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/OtherParticipationsQueryTestIT.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient; - -import static org.junit.Assert.assertTrue; - -import com.nedap.archie.rm.composition.Composition; -import com.nedap.archie.rm.support.identification.ObjectVersionId; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.generator.commons.aql.parameter.ParameterValue; -import org.ehrbase.openehr.sdk.generator.commons.aql.query.Query; -import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class OtherParticipationsQueryTestIT { - - private static OpenEhrClient openEhrClient; - private UUID ehr; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehr); - } - - @Test - public void testQueryOtherParticipations() throws IOException { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.OTHER_PARTICIPATIONS.getStream(), - StandardCharsets.UTF_8), - Composition.class); - - ObjectVersionId versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition); - - Query query = Query.buildNativeQuery( - "Select c0/content[openEHR-EHR-ACTION.minimal.v1]/other_participations/performer/name as performer_name" - + " from EHR e[ehr_id/value = $ehr_id] contains (COMPOSITION c0[openEHR-EHR-COMPOSITION.minimal.v1])" - + " WHERE c0/uid/value = $comp_uuid "); - - QueryResponseData result = openEhrClient - .aqlEndpoint() - .executeRaw( - query, - new ParameterValue("ehr_id", ehr), - new ParameterValue("comp_uuid", versionUid.getObjectId().getValue())); - - List expectedResults = Arrays.asList(List.of("Frederick Wolfstein")); - - assertTrue(CollectionUtils.isEqualCollection(result.getRows(), expectedResults)); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/ParticipationTestIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/ParticipationTestIT.java deleted file mode 100644 index 4b5d66476..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/ParticipationTestIT.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -import com.nedap.archie.rm.composition.Composition; -import com.nedap.archie.rm.generic.Participation; -import com.nedap.archie.rm.generic.PartyIdentified; -import com.nedap.archie.rm.support.identification.GenericId; -import com.nedap.archie.rm.support.identification.ObjectVersionId; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.stream.Collectors; -import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.ehrbase.openehr.sdk.util.exception.WrongStatusCodeException; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class ParticipationTestIT { - - private static OpenEhrClient openEhrClient; - private UUID ehr; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehr); - } - - @Test - @Ignore("see https://github.com/ehrbase/ehrbase/issues/710") - public void testParticipation() throws IOException { - - ehr = openEhrClient.ehrEndpoint().createEhr(); - - Composition composition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.PARTICIPATION_NO_CONTENT.getStream(), - StandardCharsets.UTF_8), - Composition.class); - - ObjectVersionId versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition); - - Optional postedComposition = openEhrClient - .compositionEndpoint(ehr) - .findRaw(UUID.fromString(versionUid.getObjectId().getValue())); - - assertThat(postedComposition.get()).isNotNull(); - - // check the actual participation IDs and Names - List participations = - postedComposition.get().getContext().getParticipations(); - - List names = participations.stream() - .map(p -> p.getPerformer()) - .map(p -> ((PartyIdentified) p).getName()) - .collect(Collectors.toList()); - assertThat(names).containsExactlyInAnyOrder("Dr. Marcus Johnson", "Zaza Markham"); - - List ids = participations.stream() - .map(p -> p.getPerformer()) - .map(p -> p.getExternalRef().getId().getValue()) - .collect(Collectors.toList()); - assertThat(ids).containsExactlyInAnyOrder("000", "123"); - - // use the sames IDs, but change one name. This raises an exception for conflicting identity! - ((PartyIdentified) composition.getContext().getParticipations().get(0).getPerformer()).setName("Dummy"); - - try { - openEhrClient.compositionEndpoint(ehr).mergeRaw(composition); - fail("Didn't detect conflicting identity!"); - } catch (WrongStatusCodeException e) { - // continue - } - - // Now, keep the same names, but change an externalRef id - composition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.PARTICIPATION_NO_CONTENT.getStream(), - StandardCharsets.UTF_8), - Composition.class); - composition - .getContext() - .getParticipations() - .get(0) - .getPerformer() - .getExternalRef() - .setId(new GenericId("ABC", "HOSPITAL-NS")); - - versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition); - - postedComposition = openEhrClient - .compositionEndpoint(ehr) - .findRaw(UUID.fromString(versionUid.getObjectId().getValue())); - - assertThat(postedComposition.get()).isNotNull(); - - // check the actual participation IDs and Names - participations = postedComposition.get().getContext().getParticipations(); - - names = participations.stream() - .map(p -> p.getPerformer()) - .map(p -> ((PartyIdentified) p).getName()) - .collect(Collectors.toList()); - assertThat(names).containsExactlyInAnyOrder("Dr. Marcus Johnson", "Zaza Markham"); - - ids = participations.stream() - .map(p -> p.getPerformer()) - .map(p -> p.getExternalRef().getId().getValue()) - .collect(Collectors.toList()); - assertThat(ids).containsExactlyInAnyOrder("ABC", "123"); - - // use the same name and id, but in another namespace - - composition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.PARTICIPATION_NO_CONTENT.getStream(), - StandardCharsets.UTF_8), - Composition.class); - composition - .getContext() - .getParticipations() - .get(0) - .getPerformer() - .getExternalRef() - .setNamespace("ANOTHER_NAMESPACE"); - - versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition); - - postedComposition = openEhrClient - .compositionEndpoint(ehr) - .findRaw(UUID.fromString(versionUid.getObjectId().getValue())); - - assertThat(postedComposition.get()).isNotNull(); - - // check the actual participation IDs and Names - participations = postedComposition.get().getContext().getParticipations(); - - List namespaces = participations.stream() - .map(p -> p.getPerformer()) - .map(p -> p.getExternalRef().getNamespace()) - .collect(Collectors.toList()); - assertThat(namespaces).containsExactlyInAnyOrder("ANOTHER_NAMESPACE", "ANOTHER-HOSPITAL-NS"); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestClientTestHelper.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/SdkClientTestIT.java similarity index 52% rename from client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestClientTestHelper.java rename to client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/SdkClientTestIT.java index 232c5b6a6..09179e000 100644 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestClientTestHelper.java +++ b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/SdkClientTestIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 vitasystems GmbH and Hannover Medical School. + * Copyright (c) 2024 vitasystems GmbH and Hannover Medical School. * * This file is part of project openEHR_SDK * @@ -19,35 +19,80 @@ import java.net.URI; import java.net.URISyntaxException; +import java.util.List; +import java.util.UUID; +import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClientConfig; import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; import org.ehrbase.openehr.sdk.serialisation.dto.DefaultValuesProvider; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.Network; -public class DefaultRestClientTestHelper { +/** + * @author Stefan Spiska + */ +public class SdkClientTestIT { + + protected static OpenEhrClient openEhrClient; + protected UUID ehr; + + protected static GenericContainer postgres; + + protected static GenericContainer ehrbase; - private static final String OPEN_EHR_URL = "http://localhost:8080/ehrbase/"; + static { + try (Network network = Network.newNetwork()) { + + postgres = new EHRbasePostgresContainer(network); + postgres.start(); + + ehrbase = new EHRbaseContainer(network, List.of(postgres)); + ehrbase.start(); + } + } + + protected static URI ehrBaseAPIEndpoint() { + return URI.create( + "http://%s:%d/ehrbase/".formatted(ehrbase.getHost(), ehrbase.getMappedPort(EHRbaseContainer.PORT))); + } + + @BeforeAll + public static void setup() throws URISyntaxException { + openEhrClient = setupDefaultRestClient(); + } public static DefaultRestClient setupDefaultRestClient() throws URISyntaxException { TestDataTemplateProvider templateProvider = new TestDataTemplateProvider(); DefaultRestClient client = - new DefaultRestClient(new OpenEhrClientConfig(new URI(OPEN_EHR_URL)), templateProvider); + new DefaultRestClient(new OpenEhrClientConfig(ehrBaseAPIEndpoint()), templateProvider); templateProvider.listTemplateIds().stream() .forEach(t -> client.templateEndpoint().ensureExistence(t)); return client; } public static DefaultRestClient setupRestClientWithDefaultTemplateProvider() throws URISyntaxException { - return new DefaultRestClient(new OpenEhrClientConfig(new URI(OPEN_EHR_URL))); + return new DefaultRestClient(new OpenEhrClientConfig(ehrBaseAPIEndpoint())); } public static DefaultRestClient setupDefaultRestClientWithDefaultProvider( - DefaultValuesProvider defaultValuesProvider) throws URISyntaxException { + DefaultValuesProvider defaultValuesProvider) { TestDataTemplateProvider templateProvider = new TestDataTemplateProvider(); - OpenEhrClientConfig config = new OpenEhrClientConfig(new URI(OPEN_EHR_URL)); + OpenEhrClientConfig config = new OpenEhrClientConfig(ehrBaseAPIEndpoint()); config.setDefaultValuesProvider(defaultValuesProvider); DefaultRestClient client = new DefaultRestClient(config, templateProvider); templateProvider.listTemplateIds().stream() .forEach(t -> client.templateEndpoint().ensureExistence(t)); return client; } + + @AfterEach + public void tearDown() { + // delete the created EHR using the admin endpoint + if (ehr != null) { + openEhrClient.adminEhrEndpoint().delete(ehr); + ehr = null; + } + } } diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/CanonicalUtil.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/CanonicalUtil.java deleted file mode 100644 index 600a5d9af..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/CanonicalUtil.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.nedap.archie.rm.RMObject; -import com.nedap.archie.rm.archetyped.Locatable; -import com.nedap.archie.rminfo.ArchieRMInfoLookup; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.util.SnakeToCamel; - -public abstract class CanonicalUtil { - - public static String toJson(Object anRmObjectAsString) { - GsonBuilder builder = new GsonBuilder(); - Gson gson = builder.setPrettyPrinting().create(); - return gson.toJson(anRmObjectAsString); - } - - public static Map toMap(RMObject anRmObject) { - GsonBuilder builder = new GsonBuilder(); - Gson gson = builder.create(); - String asString = new CanonicalJson().marshal(anRmObject); - return gson.fromJson(asString, Map.class); - } - - public static String toRmJson(RMObject anRmObject) { - return new CanonicalJson().marshal(anRmObject); - } - - public static RMObject toRmObject(Map anRmObjectAsMap, Class rmClass) { - return new CanonicalJson().unmarshal(toJson(anRmObjectAsMap), rmClass); - } - - public static Object valueObject(Object anObject) { - - Object retObject = anObject; - - if (anObject instanceof Map) { - // perform the conversion using the type if any - if (((Map) anObject).containsKey("_type")) { - // get the actual type from Archie lookup - Class objectRmClass = ArchieRMInfoLookup.getInstance().getClass((String) ((Map) anObject).get("_type")); - if (objectRmClass != null) - retObject = - new CanonicalJson().marshal(toRmObject(((Map) anObject), objectRmClass)); - } - } - - retObject = new SpecialCase().transform(retObject); - - return retObject; - } - - public static Object valueObject(String anExpression) { - - Object retObject = anExpression; - - if (retObject == null) return null; // null result is valid! - - if (anExpression.startsWith("{")) { // assume json, transform in canonical json for comparison - Gson gsonBuilder = new GsonBuilder().create(); - Map asMap = gsonBuilder.fromJson(anExpression, Map.class); - // get the type - retObject = valueObject(asMap); - - } else retObject = new SpecialCase().transform(retObject); - - return retObject; - } - - public static RMObject toRmObject(String anRmObjectAsString, Class rmClass) { - return new CanonicalJson().unmarshal(anRmObjectAsString, rmClass); - } - - public static Object compareArbitraryRmClass( - Map anRmObjectAsMap, Class rmClass, RMObject compareExpectedObject) { - RMObject actualRmObject = toRmObject(anRmObjectAsMap, rmClass); - assertThat(actualRmObject).isEqualTo(compareExpectedObject); - return null; - } - - public static List toRmObjectList(List rmObjectListAsMap) { - List objects = new ArrayList<>(); - - for (Object item : rmObjectListAsMap) { - if (item instanceof Map) { - Map mappedObject = (Map) item; - // get the type - String type = (String) mappedObject.get("_type"); - Class rmClass = ArchieRMInfoLookup.getInstance().getClass(type); - RMObject rmObject = toRmObject(mappedObject, rmClass); - objects.add(rmObject); - } - } - - return objects; - } - - /** - * resolves an attribute of a RMObject - * NB. borrowed from CAttribute.java in validation - * - * @param obj - * @param attributePath - * @return - */ - private static Object getAttributeValue(Object obj, String attributePath) { - if (obj == null) return null; - - Class rmClass = obj.getClass(); - Object value; - Method getter; - String getterName; - - if (attributePath.startsWith("is_")) { - // conventionally, a getter for a boolean uses 'is' as a prefix - getterName = "is" + new SnakeToCamel(attributePath.substring(3)).convert(); - } else getterName = "get" + new SnakeToCamel(attributePath).convert(); - - try { - getter = rmClass.getMethod(getterName); - value = getter.invoke(obj, null); - } catch (Exception e) { - throw new IllegalStateException("unresolved attribute:" + attributePath + " for class:" + rmClass); - } - - return value; - } - - /** - * Retrieve the value of an attribute identified by a path. - * NB. This is not supposed to replace Locatable.itemsAtPath(), but instead it should be used - * to resolve values in non locatable RMObject - * - * @param root - * @param attributePath - * @return - * @see com.nedap.archie.rm.archetyped.Locatable - */ - private static Object getAttributePathValue(Object root, String attributePath, boolean keepArray) { - Object rmObject = root; - - if (rmObject instanceof Locatable) { - try { - List items = ((Locatable) root).itemsAtPath(attributePath); - if (!items.isEmpty()) rmObject = keepArray ? items : items.get(0); - else rmObject = null; - } catch (Exception e) { - throw new IllegalArgumentException("Invalid path:" + attributePath); - } - } else { - if (!attributePath.contains("/")) rmObject = getAttributeValue(root, attributePath); - else { - String[] pathItems = attributePath.split("/"); - - int iteration = 0; - - for (String item : pathItems) { - rmObject = getAttributeValue(rmObject, item); - iteration++; - if (rmObject instanceof Locatable) { // f.e. items in other_details - rmObject = locatableValueItem( - (RMObject) rmObject, - iteration, - Arrays.asList(pathItems).subList(iteration, pathItems.length)); - break; - } - } - } - } - - if (rmObject instanceof RMObject) return new CanonicalJson().marshal((RMObject) rmObject); - else return rmObject; - } - - public static Object attributeValueAt(Object root, String path) { - Object evaluated = getAttributePathValue(root, path, false); - return new SpecialCase().transform(evaluated); - } - - public static Object attributeArrayValueAt(Object root, String path) { - Object evaluated = getAttributePathValue(root, path, true); - return new SpecialCase().transform(evaluated); - } - - public static Object locatableValueItem(RMObject rmObject, int iteration, List pathItems) { - String actualItemPath; - if (pathItems.isEmpty()) actualItemPath = "/"; - else actualItemPath = String.join("/", pathItems); - return ((Locatable) rmObject).itemsAtPath(actualItemPath).get(0); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/CanonicalUtilTest.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/CanonicalUtilTest.java deleted file mode 100644 index 66bb68686..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/CanonicalUtilTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.ehr.EhrStatus; -import org.junit.Test; - -public class CanonicalUtilTest extends CanonicalUtil { - - private final String ehrStatusTest = "{\n" + " \"_type\": \"EHR_STATUS\",\n" - + " \"archetype_node_id\": \"openEHR-EHR-EHR_STATUS.generic.v1\",\n" - + " \"name\": {\n" - + " \"value\": \"EHR Status\"\n" - + " },\n" - + " \"subject\": {\n" - + " \"external_ref\": {\n" - + " \"_type\": \"PARTY_REF\",\n" - + " \"id\": {\n" - + " \"_type\": \"GENERIC_ID\",\n" - + " \"value\": \"10101010-1010-1010-1010-101010101010\",\n" - + " \"scheme\": \"local\"\n" - + " },\n" - + " \"namespace\": \"patients\",\n" - + " \"type\": \"PERSON\"\n" - + " }\n" - + " },\n" - + " \"is_modifiable\": true,\n" - + " \"is_queryable\": true\n" - + "}"; - - @Test - public void testGetAttributeInRmObject() { - - EhrStatus ehrStatus = (EhrStatus) toRmObject(ehrStatusTest, EhrStatus.class); - - assertThat(attributeValueAt(ehrStatus, "name/value")).isEqualTo("EHR Status"); - assertThat(attributeValueAt(ehrStatus, "archetype_node_id")).isEqualTo("openEHR-EHR-EHR_STATUS.generic.v1"); - assertThat(attributeValueAt(ehrStatus, "is_modifiable")).isEqualTo(true); - assertThat(attributeValueAt(ehrStatus, "subject/external_ref/id/value")) - .isEqualTo("10101010-1010-1010-1010-101010101010"); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/SpecialCase.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/SpecialCase.java deleted file mode 100644 index 600e4b156..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/SpecialCase.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic; - -import com.nedap.archie.rm.RMObject; -import com.nedap.archie.rm.generic.PartySelf; -import com.nedap.archie.rm.support.identification.TerminologyId; -import java.net.URI; -import java.time.Duration; -import java.time.temporal.Temporal; -import java.util.Map; - -public class SpecialCase { - - public Object transform(Object object) { - Object retObject = object; - - if (object instanceof PartySelf - && (((PartySelf) object).getExternalRef() == null - || ((PartySelf) object).getExternalRef().getId() == null - || ((PartySelf) object).getExternalRef().getType().equalsIgnoreCase("PARTY_REF"))) - retObject = "PARTY_SELF"; - else if (object instanceof RMObject) { - retObject = CanonicalUtil.toMap((RMObject) object); - if (object instanceof TerminologyId) { - // add the type as it is sometime implicit with archie but required for comparison - ((Map) retObject).put("_type", "TERMINOLOGY_ID"); - } - } else if (object instanceof Temporal || object instanceof Duration || object instanceof URI) { - retObject = object.toString(); - } else if (object instanceof Integer) - // this is a hack as a Long is transformed as Integer in the HTTP response? - retObject = Integer.toUnsignedLong((Integer) object); - else if (object instanceof String && ((String) object).contains("PARTY_SELF")) retObject = "PARTY_SELF"; - - return retObject; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/CompareCanonicalHierObjects.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/CompareCanonicalHierObjects.java deleted file mode 100644 index 6c1a264c1..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/CompareCanonicalHierObjects.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.comparator; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.support.identification.HierObjectId; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; - -public class CompareCanonicalHierObjects extends CanonicalUtil { - - private static String canonicalJsonTemplate = - "{\n" + " \"_type\" : \"HIER_OBJECT_ID\",\n" + " \"value\" : \"%s\"\n" + "}\n"; - - private HierObjectId hierObjectId; - - public CompareCanonicalHierObjects(HierObjectId hierObjectId) { - this.hierObjectId = hierObjectId; - } - - public void isExpectedEqualToCanonicalUsing(String idValue) { - String jsonTransformed = toRmJson(hierObjectId); - String localJsonReference = String.format(canonicalJsonTemplate, idValue); - assertThat(jsonTransformed).isEqualToIgnoringNewLines(localJsonReference); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/EhrComparator.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/EhrComparator.java deleted file mode 100644 index b9c01f3ac..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/EhrComparator.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.comparator; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime; -import com.nedap.archie.rm.ehr.EhrStatus; -import com.nedap.archie.rm.support.identification.HierObjectId; -import java.util.Map; -import java.util.UUID; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.comparator.datetime.CompareCanonicalDvDateTime; - -public class EhrComparator extends CanonicalUtil { - - private final EhrStatus referenceEhrStatus; - private final UUID ehrUUID; - private final DvDateTime transactionDateTime; - - public EhrComparator(EhrStatus referenceEhrStatus, UUID ehrUUID, DvDateTime transactionDateTime) { - this.referenceEhrStatus = referenceEhrStatus; - this.ehrUUID = ehrUUID; - this.transactionDateTime = transactionDateTime; - } - - public Object compare(Map actualEhrMap) { - String type = (String) actualEhrMap.get("_type"); - HierObjectId ehrId = - (HierObjectId) toRmObject((Map) actualEhrMap.get("ehr_id"), HierObjectId.class); - EhrStatus ehrStatus = - (EhrStatus) toRmObject((Map) actualEhrMap.get("ehr_status"), EhrStatus.class); - HierObjectId systemId = - (HierObjectId) toRmObject((Map) actualEhrMap.get("system_id"), HierObjectId.class); - DvDateTime timeCreated = - (DvDateTime) toRmObject((Map) actualEhrMap.get("time_created"), DvDateTime.class); - - // high level attributes - assertThat(type).isEqualTo("EHR"); - new CompareCanonicalHierObjects(ehrId).isExpectedEqualToCanonicalUsing(ehrUUID.toString()); - new CompareCanonicalHierObjects(systemId).isExpectedEqualToCanonicalUsing("local.ehrbase.org"); - new CompareCanonicalDvDateTime(timeCreated) - .setCompareDateOnly(true) - .isExpectedEqualToCanonicalUsing(transactionDateTime); - - EhrStatusComparator.compare(ehrStatus, referenceEhrStatus); - - return null; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/EhrStatusComparator.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/EhrStatusComparator.java deleted file mode 100644 index 2d726dc55..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/EhrStatusComparator.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.comparator; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.ehr.EhrStatus; -import java.util.Map; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; - -public class EhrStatusComparator extends CanonicalUtil { - - private static boolean compareUid = false; // uid may be build implicitely or passed explicitely - - public EhrStatusComparator setCompareUid(boolean compareUid) { - this.compareUid = compareUid; - return this; - } - - public static void compare(Map actualEhrStatusMap, EhrStatus referenceEhrStatus) { - EhrStatus ehrStatus = (EhrStatus) toRmObject(actualEhrStatusMap, EhrStatus.class); - compare(ehrStatus, referenceEhrStatus); - } - - public static void compare(EhrStatus actualEhrStatus, EhrStatus referenceEhrStatus) { - assertThat(actualEhrStatus.getName()).isEqualTo(referenceEhrStatus.getName()); - assertThat(actualEhrStatus.getArchetypeNodeId()).isEqualTo(referenceEhrStatus.getArchetypeNodeId()); - - if (compareUid) assertThat(actualEhrStatus.getUid()).isEqualTo(referenceEhrStatus.getUid()); - - assertThat(actualEhrStatus.getLinks()).isEqualTo(referenceEhrStatus.getLinks()); - assertThat(actualEhrStatus.getArchetypeDetails()).isEqualTo(referenceEhrStatus.getArchetypeDetails()); - assertThat(actualEhrStatus.getSubject()).isEqualTo(referenceEhrStatus.getSubject()); - assertThat(actualEhrStatus.getFeederAudit()).isEqualTo(referenceEhrStatus.getFeederAudit()); - assertThat(actualEhrStatus.getName()).isEqualTo(referenceEhrStatus.getName()); - assertThat(actualEhrStatus.isQueryable()).isEqualTo(referenceEhrStatus.isQueryable()); - assertThat(actualEhrStatus.isModifiable()).isEqualTo(referenceEhrStatus.isModifiable()); - assertThat(actualEhrStatus.getOtherDetails()).isEqualTo(referenceEhrStatus.getOtherDetails()); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDate.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDate.java deleted file mode 100644 index 34ce4dec5..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDate.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.comparator.datetime; - -import com.nedap.archie.rm.datavalues.quantity.datetime.DvDate; -import java.text.Format; -import java.time.format.DateTimeFormatter; - -public class CompareCanonicalDvDate { - - private static String canonicalJsonTemplate = - "{\n" + " \"_type\" : \"DV_DATE\",\n" + " \"value\" : \"%s\"\n" + "}"; - - private DvDate dvDate; - - public CompareCanonicalDvDate(DvDate dvDate) { - this.dvDate = dvDate; - } - - public Object isExpectedEqualToCanonicalUsing(DvDate referenceDate) { - // check each date/time part separately - Format formatter = DateTimeFormatter.ISO_LOCAL_DATE.toFormat(); - DvDate actualDvDate = new DvDate(formatter.format(dvDate.getValue())); - DvDate expectedDvDate = new DvDate(formatter.format(referenceDate.getValue())); - - // perform comparison of parts - DatePartComparator.compare(actualDvDate, expectedDvDate); - - return null; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDateTime.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDateTime.java deleted file mode 100644 index 15d1bb9f2..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDateTime.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.comparator.datetime; - -import com.nedap.archie.rm.datavalues.quantity.datetime.DvDate; -import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime; -import com.nedap.archie.rm.datavalues.quantity.datetime.DvTime; -import java.text.Format; -import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; - -public class CompareCanonicalDvDateTime { - - boolean compareDateOnly = false; - boolean compareMillisecs = true; - - private static String canonicalJsonTemplate = - "{\n" + " \"_type\" : \"DV_DATE_TIME\",\n" + " \"value\" : \"%s\"\n" + "}"; - - private DvDateTime dvDateTime; - - public CompareCanonicalDvDateTime(DvDateTime dvDateTime) { - this.dvDateTime = dvDateTime; - } - - // modifiers to support various test scenario - - public CompareCanonicalDvDateTime setCompareDateOnly(boolean compareDateOnly) { - this.compareDateOnly = compareDateOnly; - return this; - } - - public CompareCanonicalDvDateTime setCompareMillisecs(boolean compareMillisecs) { - this.compareMillisecs = compareMillisecs; - return this; - } - - public Object isExpectedEqualToCanonicalUsing(DvDateTime referenceDateTime) { - // check each date/time part separately - Format formatter = DateTimeFormatter.ISO_LOCAL_DATE.toFormat(); - DvDate actualDvDate = new DvDate(formatter.format(dvDateTime.getValue())); - DvDate expectedDvDate = new DvDate(formatter.format(referenceDateTime.getValue())); - formatter = DateTimeFormatter.ISO_LOCAL_TIME.toFormat(); - DvTime actualDvTime = new DvTime(formatter.format(dvDateTime.getValue())); - DvTime expectedDvTime = new DvTime(formatter.format(referenceDateTime.getValue())); - ZoneOffset actualZoneOffset = ZoneOffset.from(dvDateTime.getValue()); - ZoneOffset expectedZoneOffset = ZoneOffset.from(referenceDateTime.getValue()); - - // perform comparison of parts - DatePartComparator.compare(actualDvDate, expectedDvDate); - - if (!compareDateOnly) TimePartComparator.compare(actualDvTime, expectedDvTime); - - ZoneOffsetPartComparator.compare(actualZoneOffset, expectedZoneOffset); - - // compare DvDateAttributes if any - - return null; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDateTimeTest.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDateTimeTest.java deleted file mode 100644 index f5c49aa01..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvDateTimeTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.comparator.datetime; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.datavalues.quantity.datetime.DvDate; -import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime; -import com.nedap.archie.rm.datavalues.quantity.datetime.DvTime; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; -import org.junit.Test; - -public class CompareCanonicalDvDateTimeTest extends CanonicalUtil { - - private String jsonDvDateTimeRef = - "{\n" + " \"_type\" : \"DV_DATE_TIME\",\n" + " \"value\" : \"2021-02-17T14:34:26,351+07:00\"\n" + "}"; - - @Test - public void testComparatorDvDateTime() { - DvDateTime dvDateTime = (DvDateTime) toRmObject(jsonDvDateTimeRef, DvDateTime.class); - - assertThat(new CompareCanonicalDvDateTime(dvDateTime).isExpectedEqualToCanonicalUsing(dvDateTime)) - .isNull(); - assertThat(new CompareCanonicalDvDateTime(dvDateTime) - .setCompareDateOnly(true) - .isExpectedEqualToCanonicalUsing(dvDateTime)) - .isNull(); - assertThat(new CompareCanonicalDvDateTime(dvDateTime) - .setCompareDateOnly(false) - .isExpectedEqualToCanonicalUsing(dvDateTime)) - .isNull(); - } - - private String jsonDvTimeRef = - "{\n" + " \"_type\" : \"DV_TIME\",\n" + " \"value\" : \"14:34:26,351+07:00\"\n" + "}"; - - @Test - public void testComparatorDvTime() { - DvTime dvTime = (DvTime) toRmObject(jsonDvTimeRef, DvTime.class); - - assertThat(new CompareCanonicalDvTime(dvTime).isExpectedEqualToCanonicalUsing(dvTime)) - .isNull(); - } - - private String jsonDvDateRef = "{\n" + " \"_type\" : \"DV_DATE\",\n" + " \"value\" : \"2021-02-17\"\n" + "}"; - - @Test - public void testComparatorDvDate() { - DvDate dvDate = (DvDate) toRmObject(jsonDvDateRef, DvDate.class); - - assertThat(new CompareCanonicalDvDate(dvDate).isExpectedEqualToCanonicalUsing(dvDate)) - .isNull(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvTime.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvTime.java deleted file mode 100644 index f598b08d4..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/CompareCanonicalDvTime.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.comparator.datetime; - -import com.nedap.archie.rm.datavalues.quantity.datetime.DvTime; -import java.text.Format; -import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; - -public class CompareCanonicalDvTime { - - boolean compareMillisecs = true; - - private static String canonicalJsonTemplate = - "{\n" + " \"_type\" : \"DV_TIME\",\n" + " \"value\" : \"%s\"\n" + "}"; - - private DvTime dvTime; - - public CompareCanonicalDvTime(DvTime dvTime) { - this.dvTime = dvTime; - } - - // modifiers to support various test scenario - public CompareCanonicalDvTime setCompareMillisecs(boolean compareMillisecs) { - this.compareMillisecs = compareMillisecs; - return this; - } - - public Object isExpectedEqualToCanonicalUsing(DvTime referenceTime) { - // check each date/time part separately - Format formatter = DateTimeFormatter.ISO_LOCAL_TIME.toFormat(); - DvTime actualDvTime = new DvTime(formatter.format(dvTime.getValue())); - DvTime expectedDvTime = new DvTime(formatter.format(referenceTime.getValue())); - ZoneOffset actualZoneOffset = ZoneOffset.from(dvTime.getValue()); - ZoneOffset expectedZoneOffset = ZoneOffset.from(referenceTime.getValue()); - - // perform comparison of parts - TimePartComparator.compare(actualDvTime, expectedDvTime); - - ZoneOffsetPartComparator.compare(actualZoneOffset, expectedZoneOffset); - - return null; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/DatePartComparator.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/DatePartComparator.java deleted file mode 100644 index 9d85ef941..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/DatePartComparator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.comparator.datetime; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.datavalues.quantity.datetime.DvDate; - -public class DatePartComparator { - - public static void compare(DvDate actual, DvDate expected) { - assertThat(expected.getValue()).isEqualTo(actual.getValue()); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/TimePartComparator.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/TimePartComparator.java deleted file mode 100644 index ab01e7a13..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/TimePartComparator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.comparator.datetime; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.datavalues.quantity.datetime.DvTime; - -public class TimePartComparator { - - public static void compare(DvTime actual, DvTime expected) { - assertThat(expected.getValue()).isEqualTo(actual.getValue()); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/ZoneOffsetPartComparator.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/ZoneOffsetPartComparator.java deleted file mode 100644 index 7ee931255..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/comparator/datetime/ZoneOffsetPartComparator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.comparator.datetime; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.time.ZoneOffset; - -public class ZoneOffsetPartComparator { - - public static void compare(ZoneOffset actual, ZoneOffset expected) { - assertThat(expected.getId()).isEqualTo(actual.getId()); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryDateTimeIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryDateTimeIT.java deleted file mode 100644 index de4d04fa8..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryDateTimeIT.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.ArbitraryQuery; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class ArbitraryQueryDateTimeIT extends CanonicalCompoAllTypeQueryIT { - - protected ArbitraryQuery arbitraryQuery; - - @Before - public void setUp() throws IOException { - super.setUp(CompositionTestDataCanonicalJson.DATE_TIME_TESTS); - arbitraryQuery = new ArbitraryQuery(ehrUUID, openEhrClient); - } - - @Test - public void testArbitrary1() throws IOException { - String csvTestSet = dirPath + "/arbitrary/date_time_where_tests.csv"; - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryFeederAuditIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryFeederAuditIT.java deleted file mode 100644 index 20cf920b1..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryFeederAuditIT.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.composition.Composition; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.ArbitraryQuery; -import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.testalltypesenv1composition.TestAllTypesEnV1Composition; -import org.ehrbase.openehr.sdk.serialisation.dto.RmToGeneratedDtoConverter; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class ArbitraryQueryFeederAuditIT extends CanonicalCompoAllTypeQueryIT { - - protected ArbitraryQuery arbitraryQuery; - - @Before - public void setUp() throws IOException { - ehrUUID = openEhrClient.ehrEndpoint().createEhr(); - compositionEndpoint = openEhrClient.compositionEndpoint(ehrUUID); - - aComposition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.FEEDER_AUDIT_DETAILS.getStream(), - StandardCharsets.UTF_8), - Composition.class); - RmToGeneratedDtoConverter rmToGeneratedDtoConverter = - new RmToGeneratedDtoConverter(new TestDataTemplateProvider()); - TestAllTypesEnV1Composition testAllTypesEnV1Composition = - rmToGeneratedDtoConverter.toGeneratedDto(aComposition, TestAllTypesEnV1Composition.class); - // create the composition - TestAllTypesEnV1Composition comp = compositionEndpoint.mergeCompositionEntity(testAllTypesEnV1Composition); - compositionUUID = UUID.fromString(comp.getVersionUid().getObjectId().getValue()); - arbitraryQuery = new ArbitraryQuery(ehrUUID, openEhrClient); - } - - @Test - @Ignore("fix it with another CR") - public void testArbitraryFeederAudit() throws IOException { - String csvTestSet = dirPath + "/arbitrary/arbitrary_feeder_audit.csv"; - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryIT.java deleted file mode 100644 index a654006b2..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryIT.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.ArbitraryQuery; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class ArbitraryQueryIT extends CanonicalCompoAllTypeQueryIT { - - protected ArbitraryQuery arbitraryQuery; - - @Before - public void setUp() throws IOException { - super.setUp(CompositionTestDataCanonicalJson.ALL_TYPES_SYSTEMATIC_TESTS); - arbitraryQuery = new ArbitraryQuery(ehrUUID, openEhrClient); - } - - @Test - public void testArbitraryBoolean() throws IOException { - String csvTestSet = dirPath + "/arbitrary/arbitrary_boolean_where_tests.csv"; - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } - - @Test - public void testArbitraryString() throws IOException { - String csvTestSet = dirPath + "/arbitrary/arbitrary_tests.csv"; - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryOtherContextIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryOtherContextIT.java deleted file mode 100644 index 5b8e1803d..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/ArbitraryQueryOtherContextIT.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.composition.Composition; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.ArbitraryQuery; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple.SimpleSelectQuery; -import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.virologischerbefundcomposition.VirologischerBefundComposition; -import org.ehrbase.openehr.sdk.serialisation.dto.RmToGeneratedDtoConverter; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class ArbitraryQueryOtherContextIT extends CanonicalCompoAllTypeQueryIT { - - protected ArbitraryQuery arbitraryQuery; - protected SimpleSelectQuery simpleSelectQueryEngine; - - @Before - public void setUp() throws IOException { - // normal test run - ehrUUID = openEhrClient.ehrEndpoint().createEhr(); - compositionEndpoint = openEhrClient.compositionEndpoint(ehrUUID); - - aComposition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.VIROLOGY_FINDING_WITH_SPECIMEN_NO_UPDATE.getStream(), - StandardCharsets.UTF_8), - Composition.class); - RmToGeneratedDtoConverter rmToGeneratedDtoConverter = - new RmToGeneratedDtoConverter(new TestDataTemplateProvider()); - VirologischerBefundComposition virologischerBefundComposition = - rmToGeneratedDtoConverter.toGeneratedDto(aComposition, VirologischerBefundComposition.class); - // create the composition - VirologischerBefundComposition comp = - compositionEndpoint.mergeCompositionEntity(virologischerBefundComposition); - compositionUUID = UUID.fromString(comp.getVersionUid().getObjectId().getValue()); - - arbitraryQuery = new ArbitraryQuery(ehrUUID, openEhrClient); - simpleSelectQueryEngine = new SimpleSelectQuery(ehrUUID, compositionUUID, openEhrClient); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehrUUID); - } - - @Test - public void testArbitraryOtherContext() throws IOException { - String csvTestSet = dirPath + "/arbitrary/arbitrary_other_context.csv"; - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/AutoWhereIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/AutoWhereIT.java deleted file mode 100644 index bc46007b9..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/AutoWhereIT.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.RMObject; -import java.io.IOException; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoWhereQuery; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class AutoWhereIT extends CanonicalCompoAllTypeQueryIT { - protected AutoWhereQuery autoWhereQuery; - - @Before - public void setUp() throws IOException { - super.setUp(CompositionTestDataCanonicalJson.ALL_TYPES_SYSTEMATIC_TESTS); - autoWhereQuery = new AutoWhereQuery(ehrUUID, compositionUUID, openEhrClient); - } - - @Test - public void testActionAutoWhere() throws IOException { - - String rootPath = "a"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath( - "/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-ACTION.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains section s[openEHR-EHR-SECTION.test_all_types.v1]" - + " contains action a[openEHR-EHR-ACTION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testActionWhere.csv"; - - assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testCompositionAutoWhere() throws IOException { - String rootPath = "c"; - RMObject referenceNode = aComposition; - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testCompositionWhere.csv"; - - assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testObservationAutoWhere() throws IOException { - String rootPath = "o"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath("/content[openEHR-EHR-OBSERVATION.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains observation o[openEHR-EHR-OBSERVATION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testObservationWhere.csv"; - - assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testContextAutoWhere() throws IOException { - - String rootPath = "c/context"; - RMObject referenceNode = aComposition.getContext(); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testContextAttributesWhere.csv"; - - assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testEvaluationAutoWhere() throws IOException { - - String rootPath = "eval"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath("/content[openEHR-EHR-EVALUATION.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains evaluation eval[openEHR-EHR-EVALUATION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testEvaluationWhere.csv"; - - assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testInstructionAutoWhere() throws IOException { - - String rootPath = "i"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath( - "/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-INSTRUCTION.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains section s[openEHR-EHR-SECTION.test_all_types.v1]" - + " contains instruction i[openEHR-EHR-INSTRUCTION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testInstructionWhere.csv"; - - assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testSectionAutoWhere() throws IOException { - - String rootPath = "s"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath("/content[openEHR-EHR-SECTION.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains section s[openEHR-EHR-SECTION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testSectionWhere.csv"; - - assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CanonicalCompoAllTypeQueryIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CanonicalCompoAllTypeQueryIT.java deleted file mode 100644 index 97cd3e448..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CanonicalCompoAllTypeQueryIT.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import com.nedap.archie.rm.composition.Composition; -import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.openehrclient.CompositionEndpoint; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestClientTestHelper; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; -import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.testalltypesenv1composition.TestAllTypesEnV1Composition; -import org.ehrbase.openehr.sdk.serialisation.dto.RmToGeneratedDtoConverter; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.After; -import org.junit.BeforeClass; - -public abstract class CanonicalCompoAllTypeQueryIT extends CanonicalUtil { - protected static OpenEhrClient openEhrClient; - protected static final String dirPath = "src/test/resources/testsets"; - protected CompositionEndpoint compositionEndpoint; - protected Composition aComposition; - - protected UUID ehrUUID; - protected UUID compositionUUID; - - private DvDateTime actualDvDateTime; - - @BeforeClass - public static void before() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - public void setUp(CompositionTestDataCanonicalJson testComposition) throws IOException { - // manual test use - // ehrUUID = UUID.fromString("ecc0de4d-eb29-40c2-ad7a-e2ab8d66a9f8"); - // compositionUUID = UUID.fromString("a9c22c37-8002-4486-932a-f3e1729efe57"); - - actualDvDateTime = new DvDateTime(OffsetDateTime.now()); - // normal test run - ehrUUID = openEhrClient.ehrEndpoint().createEhr(); - compositionEndpoint = openEhrClient.compositionEndpoint(ehrUUID); - - if (testComposition != null) { - aComposition = new CanonicalJson() - .unmarshal( - IOUtils.toString(testComposition.getStream(), StandardCharsets.UTF_8), Composition.class); - RmToGeneratedDtoConverter rmToGeneratedDtoConverter = - new RmToGeneratedDtoConverter(new TestDataTemplateProvider()); - TestAllTypesEnV1Composition testAllTypesEnV1Composition = - rmToGeneratedDtoConverter.toGeneratedDto(aComposition, TestAllTypesEnV1Composition.class); - // create the composition - TestAllTypesEnV1Composition comp = compositionEndpoint.mergeCompositionEntity(testAllTypesEnV1Composition); - compositionUUID = UUID.fromString(comp.getVersionUid().getObjectId().getValue()); - } - } - - @After - public void tearDown() { - // delete the created EHR and all compositions using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehrUUID); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CanonicalMinimalInstructionTypeQueryIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CanonicalMinimalInstructionTypeQueryIT.java deleted file mode 100644 index fd022575d..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CanonicalMinimalInstructionTypeQueryIT.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.datetime.DateTimeParsers; -import com.nedap.archie.rm.composition.Composition; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.openehrclient.CompositionEndpoint; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestClientTestHelper; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.ArbitraryQuery; -import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.minimalinstructionenv1composition.MinimalInstructionEnV1Composition; -import org.ehrbase.openehr.sdk.serialisation.dto.RmToGeneratedDtoConverter; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class CanonicalMinimalInstructionTypeQueryIT extends CanonicalUtil { - protected static OpenEhrClient openEhrClient; - protected static final String dirPath = "src/test/resources/testsets"; - protected CompositionEndpoint compositionEndpoint; - protected Composition aComposition; - - protected UUID ehrUUID; - protected UUID compositionUUID; - - private ArbitraryQuery arbitraryQuery; - private RmToGeneratedDtoConverter rmToGeneratedDtoConverter; - - @BeforeClass - public static void before() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @Before - public void setUp() throws IOException { - ehrUUID = openEhrClient.ehrEndpoint().createEhr(); - compositionEndpoint = openEhrClient.compositionEndpoint(ehrUUID); - arbitraryQuery = new ArbitraryQuery(ehrUUID, openEhrClient); - rmToGeneratedDtoConverter = new RmToGeneratedDtoConverter(new TestDataTemplateProvider()); - - aComposition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.MINIMAL_INSTRUCTION.getStream(), - StandardCharsets.UTF_8), - Composition.class); - } - - @After - public void tearDown() { - // delete the created EHR and all compositions using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehrUUID); - } - - @Test - public void testArbitrary1() throws IOException { - String csvTestSet = dirPath + "/arbitrary/dv_duration_where_tests1.csv"; - - MinimalInstructionEnV1Composition minimalInstructionEnV1Composition = - rmToGeneratedDtoConverter.toGeneratedDto(aComposition, MinimalInstructionEnV1Composition.class); - // create the composition - MinimalInstructionEnV1Composition comp = - compositionEndpoint.mergeCompositionEntity(minimalInstructionEnV1Composition); - compositionUUID = UUID.fromString(comp.getVersionUid().getObjectId().getValue()); - arbitraryQuery.setCompositionUUID(compositionUUID); - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } - - @Test - public void testArbitrary2() throws IOException { - String csvTestSet = dirPath + "/arbitrary/dv_duration_where_tests2.csv"; - - MinimalInstructionEnV1Composition minimalInstructionEnV1Composition = - rmToGeneratedDtoConverter.toGeneratedDto(aComposition, MinimalInstructionEnV1Composition.class); - - minimalInstructionEnV1Composition - .getMinimal() - .get(0) - .setDurationValue(DateTimeParsers.parseDurationValue("P65Y5M12D")); - - // create the composition - MinimalInstructionEnV1Composition comp = - compositionEndpoint.mergeCompositionEntity(minimalInstructionEnV1Composition); - compositionUUID = UUID.fromString(comp.getVersionUid().getObjectId().getValue()); - arbitraryQuery.setCompositionUUID(compositionUUID); - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } - - @Test - public void testArbitrary3() throws IOException { - String csvTestSet = dirPath + "/arbitrary/dv_duration_where_tests3.csv"; - - MinimalInstructionEnV1Composition minimalInstructionEnV1Composition = - rmToGeneratedDtoConverter.toGeneratedDto(aComposition, MinimalInstructionEnV1Composition.class); - - minimalInstructionEnV1Composition - .getMinimal() - .get(0) - .setDurationValue(DateTimeParsers.parseDurationValue("P101Y")); - - // create the composition - MinimalInstructionEnV1Composition comp = - compositionEndpoint.mergeCompositionEntity(minimalInstructionEnV1Composition); - compositionUUID = UUID.fromString(comp.getVersionUid().getObjectId().getValue()); - arbitraryQuery.setCompositionUUID(compositionUUID); - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } - - /** - * this test helps at understanding the duration conversions between Y, M and D. - * @throws IOException - */ - @Test - public void testArbitrary4() throws IOException { - String csvTestSet = dirPath + "/arbitrary/dv_duration_where_tests4.csv"; - - MinimalInstructionEnV1Composition minimalInstructionEnV1Composition = - rmToGeneratedDtoConverter.toGeneratedDto(aComposition, MinimalInstructionEnV1Composition.class); - - minimalInstructionEnV1Composition - .getMinimal() - .get(0) - .setDurationValue(DateTimeParsers.parseDurationValue("P1Y")); - - // create the composition - MinimalInstructionEnV1Composition comp = - compositionEndpoint.mergeCompositionEntity(minimalInstructionEnV1Composition); - compositionUUID = UUID.fromString(comp.getVersionUid().getObjectId().getValue()); - arbitraryQuery.setCompositionUUID(compositionUUID); - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CartesianProductQueryIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CartesianProductQueryIT.java deleted file mode 100644 index 89fc50a7d..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/CartesianProductQueryIT.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.composition.Composition; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.openehrclient.CompositionEndpoint; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestClientTestHelper; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.ArbitraryQuery; -import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; -import org.ehrbase.openehr.sdk.generator.commons.aql.query.Query; -import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record3; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.minimalaction3env1composition.MinimalAction3EnV1Composition; -import org.ehrbase.openehr.sdk.serialisation.dto.RmToGeneratedDtoConverter; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class CartesianProductQueryIT extends CanonicalUtil { - protected static OpenEhrClient openEhrClient; - protected static final String dirPath = "src/test/resources/testsets"; - protected CompositionEndpoint compositionEndpoint; - protected Composition aComposition; - - protected UUID ehrUUID; - protected UUID compositionUUID; - - private ArbitraryQuery arbitraryQuery; - private RmToGeneratedDtoConverter rmToGeneratedDtoConverter; - - @BeforeClass - public static void before() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @Before - public void setUp() throws IOException { - ehrUUID = openEhrClient.ehrEndpoint().createEhr(); - compositionEndpoint = openEhrClient.compositionEndpoint(ehrUUID); - arbitraryQuery = new ArbitraryQuery(ehrUUID, openEhrClient); - rmToGeneratedDtoConverter = new RmToGeneratedDtoConverter(new TestDataTemplateProvider()); - } - - @After - public void tearDown() { - // delete the created EHR and all compositions using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehrUUID); - } - - @Test - public void testCartesianWithOptionalAttribute() throws IOException { - - Composition compoWithAttribute = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.MINIMAL_WITH_OPTIONAL_ATTRIBUTE.getStream(), - StandardCharsets.UTF_8), - Composition.class); - Composition compoWithoutAttribute = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.MINIMAL_WITHOUT_OPTIONAL_ATTRIBUTE.getStream(), - StandardCharsets.UTF_8), - Composition.class); - - MinimalAction3EnV1Composition minimalAction3EnV1CompositionWithAttribute = - rmToGeneratedDtoConverter.toGeneratedDto(compoWithAttribute, MinimalAction3EnV1Composition.class); - MinimalAction3EnV1Composition minimalAction3EnV1CompositionWithoutAttribute = - rmToGeneratedDtoConverter.toGeneratedDto(compoWithoutAttribute, MinimalAction3EnV1Composition.class); - - // create the compositions - compositionEndpoint.mergeCompositionEntity(minimalAction3EnV1CompositionWithAttribute); - compositionEndpoint.mergeCompositionEntity(minimalAction3EnV1CompositionWithoutAttribute); - - Query> query = Query.buildNativeQuery( - "Select" + " a/uid/value as composition_uid," - + " a0/description[at0001]/items[at0002]/value/alternate_text as alternate_text," - + " a0/description[at0001]/items[at0002]/value/size as size," - + " a0/language/code_string as language" - + " from EHR e" - + " contains COMPOSITION a" - + " contains ACTION a0[openEHR-EHR-ACTION.minimal.v1]", - String.class, - String.class, - Integer.class); - - List> result = - openEhrClient.aqlEndpoint().execute(query); - - assertThat(result.size()) - .as("Should have 2 rows resulting from cartesian product") - .isEqualTo(2); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/FeederAuditQueryWithWhereIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/FeederAuditQueryWithWhereIT.java deleted file mode 100644 index a3acd160b..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/FeederAuditQueryWithWhereIT.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.ArbitraryQuery; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class FeederAuditQueryWithWhereIT extends CanonicalCompoAllTypeQueryIT { - - protected ArbitraryQuery arbitraryQuery; - - @Before - public void setUp() throws IOException { - super.setUp(CompositionTestDataCanonicalJson.FEEDER_AUDIT_DETAILS); - arbitraryQuery = new ArbitraryQuery(ehrUUID, openEhrClient); - } - - @Test - public void testArbitraryWhereClause() throws IOException { - String csvTestSet = dirPath + "/arbitrary/feeder_audit_where_clause_tests.csv"; - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } - - @Test - public void testArbitraryLocatableWhereClause() throws IOException { - String csvTestSet = dirPath + "/arbitrary/feeder_audit_locatable_where_clause_tests.csv"; - - assertThat(arbitraryQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/NumericTestsIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/NumericTestsIT.java deleted file mode 100644 index 72580bc9a..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/NumericTestsIT.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.composition.Composition; -import com.nedap.archie.rm.datastructures.Element; -import com.nedap.archie.rm.datavalues.DvText; -import com.nedap.archie.rm.datavalues.quantity.DvQuantity; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.NumericQuery; -import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider; -import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.minimalevaluationenv1composition.MinimalEvaluationEnV1Composition; -import org.ehrbase.openehr.sdk.serialisation.dto.RmToGeneratedDtoConverter; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class NumericTestsIT extends CanonicalCompoAllTypeQueryIT { - - protected NumericQuery numericQuery; - - @Before - public void setUp() throws IOException { - super.setUp(null); - - // build a number of compositions with different DvQuantity values and different names - - aComposition = new CanonicalJson() - .unmarshal( - IOUtils.toString( - CompositionTestDataCanonicalJson.MINIMAL_EVAL.getStream(), StandardCharsets.UTF_8), - Composition.class); - - for (int i = 0; i < 10; i++) { - Element element = (Element) aComposition - .itemsAtPath("/content[openEHR-EHR-EVALUATION.minimal.v1]/data[at0001]/items[at0002]") - .get(0); - element.setValue(new DvQuantity("kg", Double.valueOf("" + (i + 1)), 0L)); - element.setName(new DvText("value-" + i + 1)); - RmToGeneratedDtoConverter rmToGeneratedDtoConverter = - new RmToGeneratedDtoConverter(new TestDataTemplateProvider()); - MinimalEvaluationEnV1Composition minimalEvaluationEnV1Composition = - rmToGeneratedDtoConverter.toGeneratedDto(aComposition, MinimalEvaluationEnV1Composition.class); - // create the composition - MinimalEvaluationEnV1Composition comp = - compositionEndpoint.mergeCompositionEntity(minimalEvaluationEnV1Composition); - } - - numericQuery = new NumericQuery(ehrUUID, openEhrClient); - } - - @Test - public void testNumeric1() throws IOException { - String csvTestSet = dirPath + "/arbitrary/numeric_tests.csv"; - - assertThat(numericQuery.testItemPaths(dirPath + "/arbitrary", csvTestSet)) - .isTrue(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/SelectFeederAuditIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/SelectFeederAuditIT.java deleted file mode 100644 index a1970b2cb..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/SelectFeederAuditIT.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.RMObject; -import java.io.IOException; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple.SimpleSelectQuery; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class SelectFeederAuditIT extends CanonicalCompoAllTypeQueryIT { - - protected SimpleSelectQuery simpleSelectQueryEngine; - - @Before - public void setUp() throws IOException { - super.setUp(CompositionTestDataCanonicalJson.FEEDER_AUDIT_DETAILS); - simpleSelectQueryEngine = new SimpleSelectQuery(ehrUUID, compositionUUID, openEhrClient); - } - - @Test - public void testCompositionFeederAuditSelect() throws IOException { - assertThat(simpleSelectQueryEngine.testItemPaths( - dirPath + "/testCompositionFeederAuditQuery.csv", - "c/feeder_audit", - "composition c", - aComposition.getFeederAudit())) - .isTrue(); - - assertThat(simpleSelectQueryEngine.testItemPaths( - dirPath + "/testCompositionFeederAuditOtherDetailsQuery.csv", - "c/feeder_audit/feeder_system_audit/other_details[openEHR-EHR-ITEM_TREE.generic.v1]", - "composition c", - aComposition.getFeederAudit().getFeederSystemAudit().getOtherDetails())) - .isTrue(); - - assertThat(simpleSelectQueryEngine.testItemPaths( - dirPath + "/testCompositionFeederAuditQuery.csv", - "o/feeder_audit", - "composition c contains OBSERVATION o[openEHR-EHR-OBSERVATION.test_all_types.v1]", - (RMObject) aComposition - .itemsAtPath("/content[openEHR-EHR-OBSERVATION.test_all_types.v1]/feeder_audit") - .get(0))) - .isTrue(); - - assertThat(simpleSelectQueryEngine.testItemPaths( - dirPath + "/testCompositionFeederAuditOtherDetailsQuery.csv", - "o/feeder_audit/feeder_system_audit/other_details[openEHR-EHR-ITEM_TREE.generic.v1]", - "composition c contains OBSERVATION o[openEHR-EHR-OBSERVATION.test_all_types.v1]", - (RMObject) aComposition - .itemsAtPath( - "/content[openEHR-EHR-OBSERVATION.test_all_types.v1]/feeder_audit/feeder_system_audit/other_details[openEHR-EHR-ITEM_TREE.generic.v1]") - .get(0))) - .isTrue(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/SelectRMIT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/SelectRMIT.java deleted file mode 100644 index 2ab2986a6..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/SelectRMIT.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.RMObject; -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.util.List; -import org.assertj.core.api.Assertions; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple.SimpleSelectQuery; -import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; -import org.ehrbase.openehr.sdk.test_data.composition.CompositionTestDataCanonicalJson; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParser; -import org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParserSettings; - -@Category(Integration.class) -public class SelectRMIT extends CanonicalCompoAllTypeQueryIT { - - protected SimpleSelectQuery simpleSelectQueryEngine; - - @Before - public void setUp() throws IOException { - super.setUp(CompositionTestDataCanonicalJson.ALL_TYPES_SYSTEMATIC_TESTS); - simpleSelectQueryEngine = new SimpleSelectQuery(ehrUUID, compositionUUID, openEhrClient); - } - - @Test - public void testCompositionAttributeQuery() throws IOException { - String rootPath = "c"; - RMObject referenceNode = aComposition; - - // reads in the test set - BufferedReader inputCSVSetReader = - new BufferedReader(new FileReader("src/test/resources/testsets/testCompositionAttributeQuery.csv")); - - String csvParams; - CsvParser csvParser = new CsvParser(new CsvParserSettings()); - - while ((csvParams = inputCSVSetReader.readLine()) != null) { - String[] params = csvParser.parseLine(csvParams); - String attributePath = params[0]; - if (params.length == 1) { // conventionally, if params[1] exists, this means skip the test - QueryResponseData result = simpleSelectQueryEngine.performQuery( - rootPath, attributePath, "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]"); - - List objectList = result.getRows().get(0); - - // special case, c/uid is actually completed after db insertion, hence cannot be compared with the - // initial - // null value - if (attributePath.contains("uid")) { - assertThat(objectList.get(0)).isNotNull(); - } else - Assertions.assertThat(CanonicalUtil.valueObject(objectList.get(0))) - .as(rootPath + "/" + attributePath) - .isEqualTo(CanonicalUtil.attributeValueAt(referenceNode, attributePath)); - } - } - } - - @Test - public void testContextAttributesDrillDown() throws IOException { - - String rootPath = "c/context"; - RMObject referenceNode = aComposition.getContext(); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testContextAttributesDrillDown.csv"; - - assertThat(simpleSelectQueryEngine.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testObservationDrillDown() throws IOException { - - String rootPath = "o"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath("/content[openEHR-EHR-OBSERVATION.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains observation o[openEHR-EHR-OBSERVATION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testObservationDrillDown.csv"; - - assertThat(simpleSelectQueryEngine.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testEvaluationDrillDown() throws IOException { - - String rootPath = "eval"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath("/content[openEHR-EHR-EVALUATION.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains evaluation eval[openEHR-EHR-EVALUATION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testEvaluationDrillDown.csv"; - - assertThat(simpleSelectQueryEngine.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testSectionDrillDown() throws IOException { - - String rootPath = "s"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath("/content[openEHR-EHR-SECTION.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains section s[openEHR-EHR-SECTION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testSectionDrillDown.csv"; - - assertThat(simpleSelectQueryEngine.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testInstructionDrillDown() throws IOException { - - String rootPath = "i"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath( - "/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-INSTRUCTION.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains section s[openEHR-EHR-SECTION.test_all_types.v1]" - + " contains instruction i[openEHR-EHR-INSTRUCTION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testInstructionDrillDown.csv"; - - assertThat(simpleSelectQueryEngine.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testActionDrillDown() throws IOException { - - String rootPath = "a"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath( - "/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-ACTION.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains section s[openEHR-EHR-SECTION.test_all_types.v1]" - + " contains action a[openEHR-EHR-ACTION.test_all_types.v1]"; - String csvTestSet = dirPath + "/testActionDrillDown.csv"; - - assertThat(simpleSelectQueryEngine.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } - - @Test - public void testAdminEntryDrillDown() throws IOException { - - String rootPath = "a"; - RMObject referenceNode = (RMObject) aComposition - .itemsAtPath( - "/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[openEHR-EHR-ADMIN_ENTRY.test_all_types.v1]") - .get(0); - String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" - + " contains section s[openEHR-EHR-SECTION.test_all_types.v1]" - + " contains ADMIN_ENTRY a[openEHR-EHR-ADMIN_ENTRY.test_all_types.v1]"; - String csvTestSet = dirPath + "/testAdminEntryDrillDown.csv"; - - assertThat(simpleSelectQueryEngine.testItemPaths(csvTestSet, rootPath, contains, referenceNode)) - .isTrue(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/AqlExpressionBuilder.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/AqlExpressionBuilder.java deleted file mode 100644 index 24faf2af1..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/AqlExpressionBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries; - -public class AqlExpressionBuilder { - private final String rootPath; - private final String attributePath; - private String containment; - - public AqlExpressionBuilder(String rootPath, String attributePath) { - this.rootPath = rootPath; - this.attributePath = attributePath; - } - - public AqlExpressionBuilder(String rootPath, String attributePath, String containment) { - this.rootPath = rootPath; - this.attributePath = attributePath; - this.containment = containment; - } - - public String composition() { - String aqlSelect = rootPath + "/" + attributePath; - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("select "); - stringBuilder.append(aqlSelect); - stringBuilder.append(" from EHR e[ehr_id/value = $ehr_id]"); - stringBuilder.append(" contains "); - stringBuilder.append(containment); - stringBuilder.append(" WHERE c/uid/value = $comp_uuid"); - - return stringBuilder.toString(); - } - - public String composition(String whereCondition) { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(composition()); - stringBuilder.append(" AND " + whereCondition); - return stringBuilder.toString(); - } - - public String ehrStatus() { - String aqlSelect = rootPath + "/" + attributePath; - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("select "); - stringBuilder.append(aqlSelect); - stringBuilder.append(" from EHR e[ehr_id/value = $ehr_id]"); - - return stringBuilder.toString(); - } - - public String ehrStatus(String whereCondition) { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(ehrStatus()); - stringBuilder.append(" WHERE " + whereCondition); - return stringBuilder.toString(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/ParserSettings.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/ParserSettings.java deleted file mode 100644 index 43bad8a9b..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/ParserSettings.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries; - -import java.util.Arrays; -import org.junit.jupiter.params.shadow.com.univocity.parsers.common.RowProcessorErrorHandler; -import org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParserSettings; - -public abstract class ParserSettings { - - protected CsvParserSettings settings = new CsvParserSettings(); - - public CsvParserSettings settings() { - settings.getFormat().setComment('#'); - settings.getFormat().setDelimiter(','); - settings.setHeaderExtractionEnabled(false); - // skip empty lines - settings.setSkipEmptyLines(true); - settings.setProcessorErrorHandler((RowProcessorErrorHandler) (error, inputRow, context) -> { - throw new IllegalStateException( - "Error processing row: " + Arrays.toString(inputRow) + " Error details: column '" - + error.getColumnName() + "' (index " - + error.getColumnIndex() + ") has value '" + inputRow[error.getColumnIndex()] + "'"); - }); - return settings; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/TestQueryEngine.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/TestQueryEngine.java deleted file mode 100644 index b25e8d3a2..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/TestQueryEngine.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -import com.nedap.archie.rm.RMObject; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.lang.reflect.Method; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.ArbitraryExpression; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.ArbitraryExpressionSettings; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.NumericExpression; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.NumericExpressionSettings; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoWhereCondition; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple.PathExpression; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple.SimplePathExpressionSettings; -import org.ehrbase.openehr.sdk.generator.commons.aql.parameter.ParameterValue; -import org.ehrbase.openehr.sdk.generator.commons.aql.query.Query; -import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record1; -import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; -import org.ehrbase.openehr.sdk.util.exception.WrongStatusCodeException; -import org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParser; - -public abstract class TestQueryEngine extends CanonicalUtil { - - private static final String FAIL_EXPECTED = "*FAIL*"; - - private final UUID ehrUUID; - protected UUID compositionUUID; - protected OpenEhrClient openEhrClient; - - public TestQueryEngine(UUID ehrUUID, UUID compositionUUID, OpenEhrClient openEhrClient) { - this.ehrUUID = ehrUUID; - this.compositionUUID = compositionUUID; - this.openEhrClient = openEhrClient; - } - - public TestQueryEngine(UUID ehrUUID, OpenEhrClient openEhrClient) { - this.ehrUUID = ehrUUID; - this.openEhrClient = openEhrClient; - } - - public boolean testItemPaths(String csvTestSet, String rootPath, String contains, RMObject referenceNode) - throws IOException { - return false; - } - - protected void checkSimpleQuery(String csvPath, String rootPath, String contains, RMObject referenceNode) - throws FileNotFoundException { - SimplePathExpressionSettings simplePathExpressionSettings = new SimplePathExpressionSettings(); - CsvParser csvParser = new CsvParser(simplePathExpressionSettings.settings()); - csvParser.parse(new FileReader(csvPath)); - List attributeDefinitions = - simplePathExpressionSettings.getPathExpressionRow().getBeans(); - - for (PathExpression pathExpression : attributeDefinitions) { - if (pathExpression.getComment() == null) { - String attributePath = pathExpression.getPath(); - QueryResponseData result = performQuery(rootPath, attributePath, contains); - try { - List objectList = result.getRows().get(0); - Object actual = valueObject(objectList.get(0)); - - if (actual instanceof List) { - Object expected = attributeArrayValueAt(referenceNode, attributePath); // RMObject(s) - - assertThat(toRmObjectList((List) actual).toArray()) - .as(rootPath + "/" + attributePath) - .containsExactlyInAnyOrder(((List) expected).toArray()); - } else { - assertThat(valueObject(objectList.get(0))) - .as(rootPath + "/" + attributePath) - .isEqualTo(attributeValueAt(referenceNode, attributePath)); - } - } catch (Exception e) { - fail(e.getMessage()); - } - } - } - } - - protected void checkAutoWhereQuery(String csvPath, String rootPath, String contains, RMObject referenceNode) - throws FileNotFoundException { - SimplePathExpressionSettings simplePathExpressionSettings = new SimplePathExpressionSettings(); - CsvParser csvParser = new CsvParser(simplePathExpressionSettings.settings()); - csvParser.parse(new FileReader(csvPath)); - List attributeDefinitions = - simplePathExpressionSettings.getPathExpressionRow().getBeans(); - - for (PathExpression pathExpression : attributeDefinitions) { - if (pathExpression.getComment() == null) { // conventionally, if params[1] exists, this means skip the test - String attributePath = pathExpression.getPath(); - - QueryResponseData result = performQueryWithWhere( - rootPath, - attributePath, - contains, - new AutoWhereCondition(rootPath, attributePath, referenceNode).condition()); - - if (result.getRows().isEmpty()) fail(rootPath + "/" + attributePath + ": no result"); - - List objectList = result.getRows().get(0); - - assertThat(valueObject(objectList.get(0))) - .as(rootPath + "/" + attributePath) - .isEqualTo(attributeValueAt(referenceNode, attributePath)); - } - } - } - - protected void checkAutoEhrStatusWhereQuery(String csvPath, String rootPath, RMObject referenceNode) - throws FileNotFoundException { - SimplePathExpressionSettings simplePathExpressionSettings = new SimplePathExpressionSettings(); - CsvParser csvParser = new CsvParser(simplePathExpressionSettings.settings()); - csvParser.parse(new FileReader(csvPath)); - List attributeDefinitions = - simplePathExpressionSettings.getPathExpressionRow().getBeans(); - - for (PathExpression pathExpression : attributeDefinitions) { - if (pathExpression.getComment() == null) { - String attributePath = pathExpression.getPath(); - - QueryResponseData result = performEhrStatusQueryWithAutoWhere(rootPath, attributePath, referenceNode); - - if (result.getRows().isEmpty()) fail(rootPath + "/" + attributePath + ": no result"); - - List objectList = result.getRows().get(0); - - assertThat(valueObject(objectList.get(0))) - .as(rootPath + "/" + attributePath) - .isEqualTo(attributeValueAt(referenceNode, attributePath)); - } - } - } - - protected void checkArbitraryQuery(String dirPath, String csvPath) throws IOException { - - ArbitraryExpressionSettings arbitraryExpressionSettings = new ArbitraryExpressionSettings(); - CsvParser csvParser = new CsvParser(arbitraryExpressionSettings.settings()); - csvParser.parse(new FileReader(csvPath)); - List attributeDefinitions = - arbitraryExpressionSettings.getArbitraryExpressionRow().getBeans(); - - for (ArbitraryExpression arbitraryExpression : attributeDefinitions) { - if (arbitraryExpression.getOptionalComment() == null) { - - String aql = arbitraryExpression.getRightSideExpression(); - - if (arbitraryExpression.getLeftSideExpressionPath() != null) { - String leftSide = Files.readString( - Paths.get(dirPath + "/" + arbitraryExpression.getLeftSideExpressionPath())); - aql = leftSide + " WHERE " + aql; - } - - boolean shouldFail = false; - - if (arbitraryExpression.getExpectedResult() != null) - shouldFail = arbitraryExpression.getExpectedResult().equals(FAIL_EXPECTED) ? true : false; - - QueryResponseData result = performAqlQuery(aql, shouldFail); - - if (shouldFail) continue; - - if (result.getRows().isEmpty()) { - if (arbitraryExpression.getExpectedResult() == null) continue; - else fail(arbitraryExpression.getRightSideExpression() + ": no result"); - } - - // //TODO: iterate on result - List objectList = result.getRows().get(0); - Object resultingObject = objectList.get(0); - if (resultingObject instanceof List) resultingObject = ((List) resultingObject).get(0); - - assertThat(valueObject(resultingObject)) - .as(arbitraryExpression.getRightSideExpression()) - .isEqualTo(valueObject(arbitraryExpression.getExpectedResult())); - } - } - } - - protected void checkNumericQuery(String dirPath, String csvPath) throws IOException { - - NumericExpressionSettings numericLongExpressionSettings = new NumericExpressionSettings(); - CsvParser csvParser = new CsvParser(numericLongExpressionSettings.settings()); - csvParser.parse(new FileReader(csvPath)); - List attributeDefinitions = - numericLongExpressionSettings.getNumericExpressionRow().getBeans(); - - for (NumericExpression numericExpression : attributeDefinitions) { - if (numericExpression.getOptionalComment() == null) { - - String leftSide = ""; - if (numericExpression.getLeftSideExpression() != null) - leftSide = Files.readString(Paths.get(dirPath + "/" + numericExpression.getLeftSideExpression())); - - String aql; - if (!leftSide.isEmpty()) aql = leftSide + " WHERE " + numericExpression.getRightSideExpression(); - else aql = numericExpression.getRightSideExpression(); - - boolean shouldFail = false; - - if (numericExpression.getExpectedResult() != null) - shouldFail = numericExpression.getExpectedResult().equals(-1L) ? true : false; - - QueryResponseData result = performAqlQuery(aql, shouldFail); - - if (shouldFail) continue; - - if (result.getRows().isEmpty()) { - if (numericExpression.getExpectedResult() == null) continue; - else fail(numericExpression.getRightSideExpression() + ": no result"); - } - - Object expectedResult = numericExpression.getExpectedResult(); - try { - if (numericExpression.getJavaType() != null) { - Class clazz = Class.forName(numericExpression.getJavaType()); - Method valueOf = clazz.getMethod("valueOf", String.class); - expectedResult = valueOf.invoke(null, numericExpression.getExpectedResult()); - } - } catch (Exception e) { - throw new IllegalArgumentException("Invalid data type:" + numericExpression.getJavaType()); - } - - // TODO: iterate on result - List objectList = result.getRows().get(0); - - assertThat(valueObject(objectList.get(0))) - .as(numericExpression.getRightSideExpression()) - .isEqualTo(expectedResult); - } - } - } - - public QueryResponseData performQuery(String rootPath, String attributePath, String containment) { - Query> query = Query.buildNativeQuery( - new AqlExpressionBuilder(rootPath, attributePath, containment).composition(), Map.class); - - return execute(query, rootPath, attributePath); - } - - private QueryResponseData performQueryWithWhere( - String rootPath, String attributePath, String containment, String whereCondition) { - Query> query = Query.buildNativeQuery( - new AqlExpressionBuilder(rootPath, attributePath, containment).composition(whereCondition), Map.class); - - return execute(query, rootPath, attributePath); - } - - private QueryResponseData performAqlQuery(String aql, boolean shoudFail) { - Query> query = Query.buildNativeQuery(aql, Map.class); - return execute(query, aql, shoudFail); - } - - private QueryResponseData performEhrStatusQueryWithAutoWhere( - String rootPath, String attributePath, RMObject referenceNode) { - - String whereCondition = new AutoWhereCondition(rootPath, attributePath, referenceNode).condition(); - - Query> query = Query.buildNativeQuery( - new AqlExpressionBuilder(rootPath, attributePath).ehrStatus(whereCondition), Map.class); - - try { - return openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehrUUID)); - } catch (WrongStatusCodeException e) { - fail("path:" + rootPath + "/" + attributePath + ", error" + e.getMessage()); - } - return null; - } - - protected QueryResponseData execute(Query> query, String rootPath, String attributePath) { - try { - return openEhrClient - .aqlEndpoint() - .executeRaw( - query, - new ParameterValue("ehr_id", ehrUUID), - new ParameterValue("comp_uuid", compositionUUID)); - } catch (WrongStatusCodeException e) { - fail("path:" + rootPath + "/" + attributePath + ", error" + e.getMessage()); - } - return null; - } - - protected QueryResponseData execute(Query> query, String aql, boolean shouldFail) { - try { - if (compositionUUID != null) { - return openEhrClient - .aqlEndpoint() - .executeRaw( - query, - new ParameterValue("ehr_id", ehrUUID), - new ParameterValue("comp_uuid", compositionUUID)); - } else { - return openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehrUUID)); - } - } catch (WrongStatusCodeException e) { - if (!shouldFail) fail("Query is not successful, path:" + aql + ", error" + e.getMessage()); - } - return null; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryExpression.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryExpression.java deleted file mode 100644 index b6279dd5c..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryExpression.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary; - -import org.junit.jupiter.params.shadow.com.univocity.parsers.annotations.Parsed; - -public class ArbitraryExpression { - - // accept substitution f.e. $ehr_id or $composition_id - @Parsed(index = 0) - private String leftSideExpressionPath; - - @Parsed(index = 1) - private String rightSideExpression; - - // accept substitution f.e. $ehr_id or $composition_id - @Parsed(index = 2) - private String expectedResult; - - @Parsed(index = 3) - private String optionalComment; - - public String getLeftSideExpressionPath() { - return leftSideExpressionPath; - } - - public String getRightSideExpression() { - return rightSideExpression; - } - - public String getExpectedResult() { - return expectedResult; - } - - public String getOptionalComment() { - return optionalComment; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryExpressionSettings.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryExpressionSettings.java deleted file mode 100644 index 43a0ca152..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryExpressionSettings.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary; - -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.ParserSettings; -import org.junit.jupiter.params.shadow.com.univocity.parsers.common.processor.BeanListProcessor; -import org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParserSettings; - -public class ArbitraryExpressionSettings extends ParserSettings { - - private final BeanListProcessor arbitraryExpressionRow = - new BeanListProcessor<>(ArbitraryExpression.class); - - public CsvParserSettings settings() { - super.settings(); - settings.setProcessor(arbitraryExpressionRow); - return settings; - } - - public BeanListProcessor getArbitraryExpressionRow() { - return arbitraryExpressionRow; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryQuery.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryQuery.java deleted file mode 100644 index 69c6d2e6a..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/ArbitraryQuery.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary; - -import java.io.IOException; -import java.util.UUID; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.TestQueryEngine; - -public class ArbitraryQuery extends TestQueryEngine { - - public ArbitraryQuery(UUID ehrUUID, OpenEhrClient openEhrClient) { - super(ehrUUID, openEhrClient); - } - - public boolean testItemPaths(String dirPath, String csvTestSet) throws IOException { - checkArbitraryQuery(dirPath, csvTestSet); - return true; - } - - public void setCompositionUUID(UUID compositionUUID) { - this.compositionUUID = compositionUUID; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericExpression.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericExpression.java deleted file mode 100644 index 73eed55b2..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericExpression.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary; - -import org.junit.jupiter.params.shadow.com.univocity.parsers.annotations.Parsed; - -public class NumericExpression { - - // accept substitution f.e. $ehr_id or $composition_id - @Parsed(index = 0) - private String leftSideExpression; - - @Parsed(index = 1) - private String rightSideExpression; - - // accept substitution f.e. $ehr_id or $composition_id - @Parsed(index = 2) - private String expectedResult; - - @Parsed(index = 3) - private String javaType; - - @Parsed(index = 4) - private String optionalComment; - - public String getLeftSideExpression() { - return leftSideExpression; - } - - public String getRightSideExpression() { - return rightSideExpression; - } - - public String getExpectedResult() { - return expectedResult; - } - - public String getJavaType() { - return javaType; - } - - public String getOptionalComment() { - return optionalComment; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericExpressionSettings.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericExpressionSettings.java deleted file mode 100644 index 9d92f1245..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericExpressionSettings.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary; - -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.ParserSettings; -import org.junit.jupiter.params.shadow.com.univocity.parsers.common.processor.BeanListProcessor; -import org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParserSettings; - -public class NumericExpressionSettings extends ParserSettings { - - private final BeanListProcessor numericExpressionRow = - new BeanListProcessor<>(NumericExpression.class); - - public CsvParserSettings settings() { - super.settings(); - settings.setProcessor(numericExpressionRow); - return settings; - } - - public BeanListProcessor getNumericExpressionRow() { - return numericExpressionRow; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericQuery.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericQuery.java deleted file mode 100644 index 1d44c81b5..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/arbitrary/NumericQuery.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary; - -import java.io.IOException; -import java.util.UUID; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.TestQueryEngine; - -public class NumericQuery extends TestQueryEngine { - - public NumericQuery(UUID ehrUUID, OpenEhrClient openEhrClient) { - super(ehrUUID, openEhrClient); - } - - public boolean testItemPaths(String dirPath, String csvTestSet) throws IOException { - checkNumericQuery(dirPath, csvTestSet); - return true; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoEhrStatusWhereQuery.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoEhrStatusWhereQuery.java deleted file mode 100644 index 03952556b..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoEhrStatusWhereQuery.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto; - -import com.nedap.archie.rm.RMObject; -import java.io.IOException; -import java.util.UUID; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.TestQueryEngine; - -public class AutoEhrStatusWhereQuery extends TestQueryEngine { - - public AutoEhrStatusWhereQuery(UUID ehrUUID, OpenEhrClient openEhrClient) { - super(ehrUUID, openEhrClient); - } - - public boolean testItemPaths(String csvTestSet, String rootPath, RMObject referenceNode) throws IOException { - checkAutoEhrStatusWhereQuery(csvTestSet, rootPath, referenceNode); - return true; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoWhereCondition.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoWhereCondition.java deleted file mode 100644 index 0ca27673c..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoWhereCondition.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto; - -import static org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil.attributeValueAt; - -import com.nedap.archie.rm.RMObject; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.SpecialCase; - -public class AutoWhereCondition { - - private final String rootPath; - private final String attributePath; - private final RMObject referenceNode; - - public AutoWhereCondition(String rootPath, String attributePath, RMObject referenceNode) { - this.rootPath = rootPath; - this.attributePath = attributePath; - this.referenceNode = referenceNode; - } - - public String condition() { - - Object reference = attributeValueAt(referenceNode, attributePath); - - StringBuilder autoWhereCondition = new StringBuilder(); - autoWhereCondition.append(rootPath + "/" + attributePath); - autoWhereCondition.append(" = "); - Object filterObject = new SpecialCase().transform(reference); - autoWhereCondition.append(filterObject instanceof String ? "'" + filterObject + "'" : filterObject); - - return autoWhereCondition.toString(); - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoWhereQuery.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoWhereQuery.java deleted file mode 100644 index 42d55c83c..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/auto/AutoWhereQuery.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto; - -import com.nedap.archie.rm.RMObject; -import java.io.IOException; -import java.util.UUID; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.TestQueryEngine; - -public class AutoWhereQuery extends TestQueryEngine { - - public AutoWhereQuery(UUID ehrUUID, UUID compositionUUID, OpenEhrClient openEhrClient) { - super(ehrUUID, compositionUUID, openEhrClient); - } - - public boolean testItemPaths(String csvTestSet, String rootPath, String contains, RMObject referenceNode) - throws IOException { - checkAutoWhereQuery(csvTestSet, rootPath, contains, referenceNode); - return true; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/PathExpression.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/PathExpression.java deleted file mode 100644 index 4dab29c0a..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/PathExpression.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple; - -import org.junit.jupiter.params.shadow.com.univocity.parsers.annotations.Parsed; - -public class PathExpression { - - @Parsed(index = 0) - private String path; - - @Parsed(index = 1) - private String comment; - - public String getPath() { - return path; - } - - public String getComment() { - return comment; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/SimplePathExpressionSettings.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/SimplePathExpressionSettings.java deleted file mode 100644 index ab7caa295..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/SimplePathExpressionSettings.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple; - -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.ParserSettings; -import org.junit.jupiter.params.shadow.com.univocity.parsers.common.processor.BeanListProcessor; -import org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParserSettings; - -public class SimplePathExpressionSettings extends ParserSettings { - - private BeanListProcessor pathExpressionRow = new BeanListProcessor<>(PathExpression.class); - - public CsvParserSettings settings() { - super.settings(); - settings.setProcessor(pathExpressionRow); - return settings; - } - - public BeanListProcessor getPathExpressionRow() { - return pathExpressionRow; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/SimpleSelectQuery.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/SimpleSelectQuery.java deleted file mode 100644 index ead0d2420..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/compositionquery/queries/simple/SimpleSelectQuery.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.simple; - -import com.nedap.archie.rm.RMObject; -import java.io.IOException; -import java.util.UUID; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.TestQueryEngine; - -public class SimpleSelectQuery extends TestQueryEngine { - - public SimpleSelectQuery(UUID ehrUUID, UUID compositionUUID, OpenEhrClient openEhrClient) { - super(ehrUUID, compositionUUID, openEhrClient); - } - - public boolean testItemPaths(String csvTestSet, String rootPath, String contains, RMObject referenceNode) - throws IOException { - checkSimpleQuery(csvTestSet, rootPath, contains, referenceNode); - return true; - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery1IT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery1IT.java deleted file mode 100644 index 720efa67f..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery1IT.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.ehrquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.RMObject; -import com.nedap.archie.rm.datavalues.DvText; -import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime; -import com.nedap.archie.rm.ehr.EhrStatus; -import java.net.URISyntaxException; -import java.time.OffsetDateTime; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.assertj.core.api.Assertions; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestClientTestHelper; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.comparator.EhrComparator; -import org.ehrbase.openehr.sdk.generator.commons.aql.parameter.ParameterValue; -import org.ehrbase.openehr.sdk.generator.commons.aql.query.Query; -import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record1; -import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -// @Ignore -public class CanonicalEhrQuery1IT extends CanonicalUtil { - private static OpenEhrClient openEhrClient; - - private UUID ehrUUID; - private DvDateTime actualDvDateTime; - private EhrStatus referenceEhrStatus; - - @BeforeClass - public static void before() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @Before - public void setUp() { - actualDvDateTime = new DvDateTime(OffsetDateTime.now()); - ehrUUID = openEhrClient.ehrEndpoint().createEhr(); - // ehr_status - referenceEhrStatus = openEhrClient.ehrEndpoint().getEhrStatus(ehrUUID).get(); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehrUUID); - } - - /** - * create a basic ehr and check attributes - */ - @Test - public void testEhrAttributes() { - - // see issue CR #478 (cannot retrieve time_created via a get using the SDK) - // for the time being just compare date and time zone - - Query> query = - Query.buildNativeQuery("select e " + "from EHR e[ehr_id/value = $ehr_id]", Map.class); - - List> result = openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehrUUID)); - - Map valueMap = result.get(0).value1(); - - Assertions.assertThat(new EhrComparator(referenceEhrStatus, ehrUUID, actualDvDateTime).compare(valueMap)) - .isNull(); - } - - @Test - public void testEhrAttributesDrillDown1() { - - // see issue CR #... (cannot retrieve time_created via a get using the SDK) - // for the time being just compare date and time zone - - Query> query = - Query.buildNativeQuery("select e/ehr_status/name " + "from EHR e[ehr_id/value = $ehr_id]", Map.class); - - List> result = openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehrUUID)); - - Map valueMap = result.get(0).value1(); - - assertThat(compareArbitraryRmClass(valueMap, DvText.class, referenceEhrStatus.getName())) - .isNull(); - } - - @Test - public void testEhrAttributesDrillDown11() { - - // see issue CR #... (cannot retrieve time_created via a get using the SDK) - // for the time being just compare date and time zone - - Query> query = Query.buildNativeQuery( - "select e/ehr_status/archetype_node_id " + "from EHR e[ehr_id/value = $ehr_id]", Map.class); - - QueryResponseData result = openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehrUUID)); - - List objectList = result.getRows().get(0); - - assertThat(objectList.get(0)).isEqualTo(referenceEhrStatus.getArchetypeNodeId()); - } - - @Test - @Ignore("CR https://github.com/ehrbase/project_management/issues/480") - public void testEhrAttributesDrillDown2() { - Query> query = Query.buildNativeQuery( - "select e/ehr_status/name/value " + "from EHR e[ehr_id/value = $ehr_id]", Map.class); - - List> result = openEhrClient.aqlEndpoint().execute(query, new ParameterValue("ehr_id", ehrUUID)); - - assertThat(result.get(0).value(0)) - .as("e/ehr_status/name/value") - .isEqualTo(attributeValueAt(referenceEhrStatus.getName(), "value")); - } - - @Test - public void testEhrAttributesDrillDown3() { - - String rootPath = "e/ehr_status"; - RMObject referenceNode = referenceEhrStatus; - - String[] attributePaths = { - "archetype_node_id", - "archetype_details", - "archetype_details/archetype_id", - "archetype_details/archetype_id/value", - "archetype_details/template_id", - "archetype_details/template_id/value", - "archetype_details/rm_version", - "subject", - "is_queryable", - "is_modifiable" - }; - - for (String attributePath : attributePaths) { - String aqlSelect = rootPath + "/" + attributePath; - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("select "); - stringBuilder.append(aqlSelect); - stringBuilder.append(" from EHR e[ehr_id/value = $ehr_id]"); - Query> query = Query.buildNativeQuery(stringBuilder.toString(), Map.class); - - QueryResponseData result = - openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehrUUID)); - - List objectList = result.getRows().get(0); - - assertThat(valueObject(objectList.get(0))) - .as(aqlSelect) - .isEqualTo(attributeValueAt(referenceNode, attributePath)); - } - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery2IT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery2IT.java deleted file mode 100644 index bff343b3e..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery2IT.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.ehrquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.RMObject; -import com.nedap.archie.rm.ehr.EhrStatus; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestClientTestHelper; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.CanonicalUtil; -import org.ehrbase.openehr.sdk.generator.commons.aql.parameter.ParameterValue; -import org.ehrbase.openehr.sdk.generator.commons.aql.query.Query; -import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record1; -import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.ehr.EhrTestDataCanonicalJson; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -// @Ignore -public class CanonicalEhrQuery2IT extends CanonicalUtil { - private static OpenEhrClient openEhrClient; - - private UUID ehrUUID; - private EhrStatus referenceEhrStatus = null; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @Before - public void setUp() { - try { - referenceEhrStatus = new CanonicalJson() - .unmarshal( - IOUtils.toString( - EhrTestDataCanonicalJson.EHR_STATUS_SUBJECT_EXTERNAL_REF.getStream(), - StandardCharsets.UTF_8), - EhrStatus.class); - } catch (IOException e) { - e.printStackTrace(); - } - ehrUUID = openEhrClient.ehrEndpoint().createEhr(referenceEhrStatus); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehrUUID); - } - - @Test - public void testEhrAttributesDrillDown() { - - String rootPath = "e/ehr_status"; - RMObject referenceNode = referenceEhrStatus; - - String[] attributePaths = { - "archetype_node_id", - "archetype_details", - "archetype_details/archetype_id", - "archetype_details/archetype_id/value", - "archetype_details/template_id", - "archetype_details/template_id/value", - "subject", - "subject/external_ref", - "subject/external_ref/id", - "subject/external_ref/id/value", - "subject/external_ref/id/scheme", - "subject/external_ref/namespace", - "subject/external_ref/type", - "is_queryable", - "is_modifiable" - }; - - for (String attributePath : attributePaths) { - String aqlSelect = rootPath + "/" + attributePath; - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("select "); - stringBuilder.append(aqlSelect); - stringBuilder.append(" from EHR e[ehr_id/value = $ehr_id]"); - Query> query = Query.buildNativeQuery(stringBuilder.toString(), Map.class); - - QueryResponseData result = - openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehrUUID)); - - List objectList = result.getRows().get(0); - - assertThat(valueObject(objectList.get(0))) - .as(aqlSelect) - .isEqualTo(attributeValueAt(referenceNode, attributePath)); - } - } -} diff --git a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery3IT.java b/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery3IT.java deleted file mode 100644 index de086410e..000000000 --- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/systematic/ehrquery/CanonicalEhrQuery3IT.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2020 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.client.openehrclient.defaultrestclient.systematic.ehrquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.nedap.archie.rm.RMObject; -import com.nedap.archie.rm.ehr.EhrStatus; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.ehrbase.openehr.sdk.client.Integration; -import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestClientTestHelper; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.CanonicalCompoAllTypeQueryIT; -import org.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoEhrStatusWhereQuery; -import org.ehrbase.openehr.sdk.generator.commons.aql.parameter.ParameterValue; -import org.ehrbase.openehr.sdk.generator.commons.aql.query.Query; -import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record1; -import org.ehrbase.openehr.sdk.response.dto.QueryResponseData; -import org.ehrbase.openehr.sdk.serialisation.jsonencoding.CanonicalJson; -import org.ehrbase.openehr.sdk.test_data.ehr.EhrTestDataCanonicalJson; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(Integration.class) -public class CanonicalEhrQuery3IT extends CanonicalCompoAllTypeQueryIT { - private static OpenEhrClient openEhrClient; - - private UUID ehrUUID; - private EhrStatus referenceEhrStatus = null; - - @BeforeClass - public static void setup() throws URISyntaxException { - openEhrClient = DefaultRestClientTestHelper.setupDefaultRestClient(); - } - - @Before - public void setUp() { - try { - referenceEhrStatus = new CanonicalJson() - .unmarshal( - IOUtils.toString( - EhrTestDataCanonicalJson.EHR_STATUS_SUBJECT_EXTERNAL_REF_OTHER_DETAILS.getStream(), - StandardCharsets.UTF_8), - EhrStatus.class); - } catch (IOException e) { - e.printStackTrace(); - } - ehrUUID = openEhrClient.ehrEndpoint().createEhr(referenceEhrStatus); - } - - @After - public void tearDown() { - // delete the created EHR using the admin endpoint - openEhrClient.adminEhrEndpoint().delete(ehrUUID); - } - - @Test - public void testEhrAttributesDrillDown() { - - String rootPath = "e/ehr_status"; - RMObject referenceNode = referenceEhrStatus; - - String[] attributePaths = { - "archetype_node_id", - "archetype_details", - "archetype_details/archetype_id", - "archetype_details/archetype_id/value", - "archetype_details/template_id", - "archetype_details/template_id/value", - "subject", - "subject/external_ref", - "subject/external_ref/id", - "subject/external_ref/id/value", - "subject/external_ref/id/scheme", - "subject/external_ref/namespace", - "subject/external_ref/type", - "other_details", - "other_details/name", - "other_details/name/value", - "other_details/items[at0001]", - "other_details/items[at0001]/archetype_node_id", - "other_details/items[at0001]/name", - "other_details/items[at0001]/name/value", - "other_details/items[at0001]/value", - "other_details/items[at0001]/value/id", - "other_details/items[at0001]/value/type", - "other_details/items[at0001]/value/issuer", - "other_details/items[at0001]/value/assigner", - "is_queryable", - "is_modifiable" - }; - - for (String attributePath : attributePaths) { - String aqlSelect = rootPath + "/" + attributePath; - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("select "); - stringBuilder.append(aqlSelect); - stringBuilder.append(" from EHR e[ehr_id/value = $ehr_id]"); - Query> query = Query.buildNativeQuery(stringBuilder.toString(), Map.class); - - QueryResponseData result = - openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehrUUID)); - - List objectList = result.getRows().get(0); - - Object actual = valueObject(objectList.get(0)); // Mapped object(s) from JSON - - if (actual instanceof List) { - Object expected = attributeArrayValueAt(referenceNode, attributePath); // RMObject(s) - - assertThat(toRmObjectList((List) actual).toArray()) - .as(aqlSelect) - .containsExactlyInAnyOrder(((List) expected).toArray()); - } else { - assertThat(valueObject(objectList.get(0))) - .as(aqlSelect) - .isEqualTo(attributeValueAt(referenceNode, attributePath)); - } - } - } - - @Test - public void testEhrAutoWhere() throws IOException { - EhrStatus referenceEhrStatus = new CanonicalJson() - .unmarshal( - IOUtils.toString( - EhrTestDataCanonicalJson.EHR_STATUS_SUBJECT_EXTERNAL_REF_OTHER_DETAILS.getStream(), - StandardCharsets.UTF_8), - EhrStatus.class); - - String rootPath = "e/ehr_status"; - RMObject referenceNode = referenceEhrStatus; - String csvTestSet = dirPath + "/testEhrStatusWhere.csv"; - - assertThat(new AutoEhrStatusWhereQuery(ehrUUID, openEhrClient) - .testItemPaths(csvTestSet, rootPath, referenceNode)) - .isTrue(); - } -} diff --git a/generator-maven-plugin/pom.xml b/generator-maven-plugin/pom.xml index 450b124c0..3353b347d 100644 --- a/generator-maven-plugin/pom.xml +++ b/generator-maven-plugin/pom.xml @@ -14,7 +14,6 @@ true - false ../ @@ -90,7 +89,7 @@ ${project.build.directory}/local-repo verify true - ${skipTests} + true true true diff --git a/pom.xml b/pom.xml index e3a2334ae..2444545db 100644 --- a/pom.xml +++ b/pom.xml @@ -64,37 +64,10 @@ UTF-8 8f3381a37d - true - **/*Test.java - unit ./ - - - fast - - **/*Test.java - unit - - - - - slow - - **/*IT.java - integration - - - - - full - - **/* - all - - release @@ -209,37 +182,15 @@ org.apache.maven.plugins maven-surefire-plugin - true ${surefireArgLine} - - - ${test.profile} tests - test - - test - - - false - - - org.apache.maven.plugins maven-failsafe-plugin - - ${skipIntegrationTests} - - integration-test - verify - - integration-test - verify - ${failsafeArgLine} From 337b203cd47f8fd3735818f556241acc8d0afafd Mon Sep 17 00:00:00 2001 From: bot Date: Mon, 8 Apr 2024 08:09:36 +0000 Subject: [PATCH 5/5] release 2.9.0: updated version to 2.9.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 9f556b9a3..68a2c07ed 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.9.0] ### Added ### Fixed @@ -385,4 +385,4 @@ Note: version releases in the 0.x.y range may introduce breaking changes. [2.6.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.5.0...v2.6.0 [2.7.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.6.0...v2.7.0 [2.8.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.7.0...v2.8.0 -[unreleased]: https://github.com/ehrbase/openEHR_SDK/compare/v2.8.0...HEAD +[2.9.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.8.0...v2.9.0 diff --git a/aql/pom.xml b/aql/pom.xml index 661f72357..0f4ca2952 100644 --- a/aql/pom.xml +++ b/aql/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 aql diff --git a/bom/pom.xml b/bom/pom.xml index 0f8484b76..a1c8c2f0e 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -8,7 +8,7 @@ bom org.ehrbase.openehr.sdk - 2.9.0-SNAPSHOT + 2.9.0 pom openEHR SDK diff --git a/client/pom.xml b/client/pom.xml index 38a0ac511..5b0808359 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 client diff --git a/example-generator/pom.xml b/example-generator/pom.xml index 13cf3d519..78b079750 100644 --- a/example-generator/pom.xml +++ b/example-generator/pom.xml @@ -5,7 +5,7 @@ sdk-parent org.ehrbase.openehr.sdk - 2.9.0-SNAPSHOT + 2.9.0 4.0.0 diff --git a/generator-commons/pom.xml b/generator-commons/pom.xml index f5ca2cb47..fc888b582 100644 --- a/generator-commons/pom.xml +++ b/generator-commons/pom.xml @@ -6,7 +6,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 generator-commons diff --git a/generator-maven-plugin/pom.xml b/generator-maven-plugin/pom.xml index 3353b347d..1cdaf54e2 100644 --- a/generator-maven-plugin/pom.xml +++ b/generator-maven-plugin/pom.xml @@ -5,7 +5,7 @@ sdk-parent org.ehrbase.openehr.sdk - 2.9.0-SNAPSHOT + 2.9.0 4.0.0 diff --git a/generator/pom.xml b/generator/pom.xml index 22ef50c27..3848d3e5c 100644 --- a/generator/pom.xml +++ b/generator/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 generator diff --git a/opt-1.4/pom.xml b/opt-1.4/pom.xml index ce6b33b8d..27a13dd7f 100644 --- a/opt-1.4/pom.xml +++ b/opt-1.4/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 opt-1.4 diff --git a/pom.xml b/pom.xml index 2444545db..fbcf29660 100644 --- a/pom.xml +++ b/pom.xml @@ -25,13 +25,13 @@ org.ehrbase.openehr.sdk bom - 2.9.0-SNAPSHOT + 2.9.0 ./bom/pom.xml org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 pom openEHR SDK diff --git a/response-dto/pom.xml b/response-dto/pom.xml index 84ee610c6..f295f2ff0 100644 --- a/response-dto/pom.xml +++ b/response-dto/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 response-dto diff --git a/serialisation/pom.xml b/serialisation/pom.xml index cf519be01..a392de8fb 100644 --- a/serialisation/pom.xml +++ b/serialisation/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 serialisation diff --git a/serialisation_conformance_test/pom.xml b/serialisation_conformance_test/pom.xml index cad915d8f..f5f522677 100644 --- a/serialisation_conformance_test/pom.xml +++ b/serialisation_conformance_test/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 serialisation_conformance_test diff --git a/terminology/pom.xml b/terminology/pom.xml index bc16493f0..2fced7ba8 100644 --- a/terminology/pom.xml +++ b/terminology/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 terminology diff --git a/test-coverage/pom.xml b/test-coverage/pom.xml index 51bb8227d..161470b1b 100644 --- a/test-coverage/pom.xml +++ b/test-coverage/pom.xml @@ -8,7 +8,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 test-coverage diff --git a/test-data/pom.xml b/test-data/pom.xml index 779adceca..b1a3907f5 100644 --- a/test-data/pom.xml +++ b/test-data/pom.xml @@ -26,7 +26,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 test-data diff --git a/util/pom.xml b/util/pom.xml index 19aba13ec..eb777d497 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 util diff --git a/validation/pom.xml b/validation/pom.xml index 8eb605ff7..2bb05660a 100644 --- a/validation/pom.xml +++ b/validation/pom.xml @@ -24,7 +24,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 validation diff --git a/web-template/pom.xml b/web-template/pom.xml index 554661e75..efa2d4247 100644 --- a/web-template/pom.xml +++ b/web-template/pom.xml @@ -25,7 +25,7 @@ org.ehrbase.openehr.sdk sdk-parent - 2.9.0-SNAPSHOT + 2.9.0 web-template