diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 97179f204..60dc160a8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -26,8 +26,11 @@ jobs:
java-version: '17'
cache: 'maven'
- - name: Maven - Verify, Jacoco and Package
- run: mvn --batch-mode -U verify test jacoco:report-aggregate package
+ - name: Jacoco - Unit Tests
+ run: mvn --batch-mode clean jacoco:prepare-agent package jacoco:report
+
+ - name: Jacoco - Integration Tests
+ run: mvn --batch-mode jacoco:prepare-agent-integration failsafe:integration-test failsafe:verify verify jacoco:report
- name: Sonar - Analyze
# Dependabot has no access to the SONAR_TOKEN secret, so we need to skip sonar.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4ac2b2094..89bd2b79d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,11 @@ Note: version releases in the 0.x.y range may introduce breaking changes.
## [unreleased]
### Added
+ ### Changed
+- Removed OpenEhrClient::getFolder (use directoryCrudEndpoint()::getFolder instead) ([#588](https://github.com/ehrbase/openEHR_SDK/pull/588))
### Fixed
+- Migrated test to run against EHRbase v2 ([#588](https://github.com/ehrbase/openEHR_SDK/pull/588))
+- ContributionBuilder: set VERSION.lifecycle_state to 'complete'" ([#588](https://github.com/ehrbase/openEHR_SDK/pull/588))
## [2.9.1]
### Added
diff --git a/client/pom.xml b/client/pom.xml
index 0dc14c268..852ca02a1 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -35,22 +35,6 @@
../
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 3.2.5
-
- com.github.better-care:web-template-tests
-
- ${include.tests}
-
-
-
-
-
-
javax.cache
diff --git a/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/OpenEhrClient.java b/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/OpenEhrClient.java
index ab3eb9921..11fb3521a 100644
--- a/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/OpenEhrClient.java
+++ b/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/OpenEhrClient.java
@@ -46,8 +46,6 @@ public interface OpenEhrClient {
DirectoryCrudEndpoint directoryCrudEndpoint(UUID ehrId);
- FolderDAO folder(UUID ehrId, String path);
-
/**
* Get the {@link TemplateEndpoint}
*
diff --git a/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/builder/ContributionBuilder.java b/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/builder/ContributionBuilder.java
index 91511dc32..40aacbeab 100644
--- a/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/builder/ContributionBuilder.java
+++ b/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/builder/ContributionBuilder.java
@@ -23,9 +23,12 @@
import com.nedap.archie.rm.archetyped.Locatable;
import com.nedap.archie.rm.changecontrol.OriginalVersion;
import com.nedap.archie.rm.composition.Composition;
+import com.nedap.archie.rm.datatypes.CodePhrase;
+import com.nedap.archie.rm.datavalues.DvCodedText;
import com.nedap.archie.rm.directory.Folder;
import com.nedap.archie.rm.generic.AuditDetails;
import com.nedap.archie.rm.support.identification.ObjectVersionId;
+import com.nedap.archie.rm.support.identification.TerminologyId;
import com.nedap.archie.rm.support.identification.UIDBasedId;
import javax.annotation.Nullable;
import org.ehrbase.openehr.sdk.client.openehrclient.ContributionChangeType;
@@ -192,6 +195,8 @@ private void updateContribution(
updateMetadataById(precedingVersionUid, originalVersion, compositionAudit);
originalVersion.setCommitAudit(compositionAudit);
+ originalVersion.setLifecycleState(
+ new DvCodedText("complete", new CodePhrase(new TerminologyId("openehr"), "532")));
this.contributionCreateDto.getVersions().add(originalVersion);
}
diff --git a/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestClient.java b/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestClient.java
index e109746c7..814fc6cfa 100644
--- a/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestClient.java
+++ b/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestClient.java
@@ -59,7 +59,6 @@
import org.ehrbase.openehr.sdk.client.openehrclient.CompositionEndpoint;
import org.ehrbase.openehr.sdk.client.openehrclient.ContributionEndpoint;
import org.ehrbase.openehr.sdk.client.openehrclient.DirectoryCrudEndpoint;
-import org.ehrbase.openehr.sdk.client.openehrclient.FolderDAO;
import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClient;
import org.ehrbase.openehr.sdk.client.openehrclient.OpenEhrClientConfig;
import org.ehrbase.openehr.sdk.client.openehrclient.TemplateEndpoint;
@@ -330,11 +329,6 @@ public DirectoryCrudEndpoint directoryCrudEndpoint(UUID ehrId) {
return new DefaultCrudEndpoint(this, ehrId);
}
- @Override
- public FolderDAO folder(UUID ehrId, String path) {
- return new DefaultRestDirectoryEndpoint(this, ehrId).getFolder(path);
- }
-
@Override
public TemplateEndpoint templateEndpoint() {
return new DefaultRestTemplateEndpoint(this);
diff --git a/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestDirectoryEndpoint.java b/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestDirectoryEndpoint.java
deleted file mode 100644
index 4ed4e7dce..000000000
--- a/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestDirectoryEndpoint.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2019 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.ehrbase.openehr.sdk.client.openehrclient.defaultrestclient.DefaultRestEhrEndpoint.EHR_PATH;
-
-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.URI;
-import java.util.ArrayList;
-import java.util.Optional;
-import java.util.UUID;
-import org.apache.commons.lang3.StringUtils;
-import org.ehrbase.openehr.sdk.client.openehrclient.CompositionEndpoint;
-import org.ehrbase.openehr.sdk.client.openehrclient.FolderDAO;
-import org.ehrbase.openehr.sdk.response.dto.DirectoryResponseData;
-import org.ehrbase.openehr.sdk.util.exception.WrongStatusCodeException;
-
-public class DefaultRestDirectoryEndpoint {
-
- static final String FOLDER_DIVIDER = "/";
- private static final String DIRECTORY_PATH = "/directory/";
- private final DefaultRestClient defaultRestClient;
- private final UUID ehrId;
- private ObjectVersionId rootVersion;
- private Folder root;
-
- DefaultRestDirectoryEndpoint(DefaultRestClient defaultRestClient, UUID ehrId) {
- this.defaultRestClient = defaultRestClient;
- this.ehrId = ehrId;
- syncFromDb();
- }
-
- public FolderDAO getFolder(String path) {
- DefaultRestFolderDAO folderDAO = new DefaultRestFolderDAO(this, path);
- folderDAO.sync();
- return folderDAO;
- }
-
- synchronized void syncFromDb() {
- try {
- retrieveRootFolder();
- } catch (WrongStatusCodeException e) {
- createRootFolder();
- }
- }
-
- synchronized void saveToDb() {
- rootVersion = defaultRestClient.httpPut(resolve(""), root, rootVersion);
- syncFromDb();
- }
-
- synchronized Folder find(String path) {
- if (StringUtils.isBlank(path)) {
- return root;
- }
- String[] split = path.split(FOLDER_DIVIDER);
- Folder current = root;
- for (String folderName : split) {
- Folder newFolder = Optional.of(current)
- .map(Folder::getFolders)
- .flatMap(l -> l.stream()
- .filter(f -> folderName.equals(f.getName().getValue()))
- .findAny())
- .orElse(null);
- if (newFolder == null) {
- newFolder = new Folder();
- newFolder.setArchetypeNodeId("openEHR-EHR-FOLDER.generic.v1");
- newFolder.setName(new DvText(folderName));
- if (current.getFolders() == null) {
- current.setFolders(new ArrayList<>());
- }
- current.addFolder(newFolder);
- }
- current = newFolder;
- }
-
- return current;
- }
-
- CompositionEndpoint getCompositionEndpoint() {
- return defaultRestClient.compositionEndpoint(ehrId);
- }
-
- DefaultRestClient getDefaultRestClient() {
- return defaultRestClient;
- }
-
- UUID getEhrId() {
- return ehrId;
- }
-
- private void copyToFolder(Folder folder, DirectoryResponseData responseData) {
- folder.setUid(responseData.getUid());
- folder.setName(responseData.getName());
- folder.setDetails(responseData.getDetails());
- folder.setFolders(responseData.getFolders());
- folder.setItems(responseData.getItems());
- }
-
- private void retrieveRootFolder() throws WrongStatusCodeException {
- Optional directoryResponseData =
- defaultRestClient.httpGet(resolve(StringUtils.EMPTY), DirectoryResponseData.class);
- if (root == null) {
- root = initRootFolder();
- }
- copyToFolder(
- root, directoryResponseData.orElseThrow(() -> new WrongStatusCodeException("Not Found", 404, 200)));
- rootVersion = new ObjectVersionId(root.getUid().toString());
- }
-
- private void createRootFolder() {
- root = initRootFolder();
- rootVersion = defaultRestClient.httpPost(resolve(""), root);
- }
-
- private Folder initRootFolder() {
- var folder = new Folder();
- folder.setName(new DvText("root"));
- folder.setArchetypeNodeId("openEHR-EHR-FOLDER.generic.v1");
- return folder;
- }
-
- private URI resolve(String subPath) {
- if (StringUtils.isBlank(subPath)) {
- return defaultRestClient.getConfig().getBaseUri().resolve(EHR_PATH + ehrId.toString() + DIRECTORY_PATH);
- } else {
- return defaultRestClient
- .getConfig()
- .getBaseUri()
- .resolve(EHR_PATH + ehrId.toString() + DIRECTORY_PATH + subPath);
- }
- }
-}
diff --git a/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestFolderDAO.java b/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestFolderDAO.java
deleted file mode 100644
index adb38b438..000000000
--- a/client/src/main/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestFolderDAO.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2019 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 com.nedap.archie.rm.composition.Composition;
-import com.nedap.archie.rm.datavalues.DvText;
-import com.nedap.archie.rm.directory.Folder;
-import com.nedap.archie.rm.support.identification.ObjectId;
-import com.nedap.archie.rm.support.identification.ObjectRef;
-import com.nedap.archie.rm.support.identification.ObjectVersionId;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.commons.lang3.StringUtils;
-import org.ehrbase.openehr.sdk.client.openehrclient.FolderDAO;
-import org.ehrbase.openehr.sdk.generator.commons.annotations.Template;
-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.query.EntityQuery;
-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.util.exception.ClientException;
-
-public class DefaultRestFolderDAO implements FolderDAO {
-
- private final DefaultRestDirectoryEndpoint directoryEndpoint;
- private final String path;
-
- public DefaultRestFolderDAO(DefaultRestDirectoryEndpoint directoryEndpoint, String path) {
- this.directoryEndpoint = directoryEndpoint;
- this.path = path;
- }
-
- @Override
- public String getName() {
- directoryEndpoint.syncFromDb();
- return getRmFolder().getName().getValue();
- }
-
- @Override
- public void setName(String name) {
- directoryEndpoint.syncFromDb();
- getRmFolder().setName(new DvText(name));
- directoryEndpoint.saveToDb();
- }
-
- @Override
- public Set listSubFolderNames() {
- directoryEndpoint.syncFromDb();
- return Optional.of(getRmFolder()).stream()
- .map(Folder::getFolders)
- .filter(Objects::nonNull)
- .flatMap(List::stream)
- .map(Folder::getName)
- .map(DvText::getValue)
- .collect(Collectors.toSet());
- }
-
- @Override
- public Folder getRmFolder() {
- return directoryEndpoint.find(path);
- }
-
- @Override
- public FolderDAO getSubFolder(String path) {
- DefaultRestFolderDAO folderDAO = new DefaultRestFolderDAO(
- directoryEndpoint,
- Stream.of(this.path, path).filter(StringUtils::isNotBlank).collect(Collectors.joining("//")));
- folderDAO.sync();
- return folderDAO;
- }
-
- @Override
- public T addCompositionEntity(T entity) {
- T updatedEntity = directoryEndpoint.getCompositionEndpoint().mergeCompositionEntity(entity);
- var versionId = DefaultRestCompositionEndpoint.extractVersionUid(updatedEntity)
- .orElseThrow(() -> new ClientException(String.format("No Id Element for %s", entity.getClass())));
- addToFolder(versionId);
- return updatedEntity;
- }
-
- @Override
- public ObjectVersionId addRaw(Composition composition) {
- ObjectVersionId versionId = directoryEndpoint.getCompositionEndpoint().mergeRaw(composition);
- addToFolder(versionId);
- return versionId;
- }
-
- @Override
- public List find(Class clazz) {
-
- Containment compositionContainment = new Containment("COMPOSITION");
-
- EntityQuery> query = Query.buildEntityQuery(
- compositionContainment, new NativeSelectAqlField<>(compositionContainment, "", clazz));
-
- query.where(Condition.equal(EhrFields.EHR_ID(), directoryEndpoint.getEhrId())
- .and(Condition.equal(
- new NativeSelectAqlField<>(compositionContainment, "/template_id", String.class),
- extractTemplateId(clazz)))
- .and(Condition.matches(
- new NativeSelectAqlField<>(compositionContainment, "/uid/value", String.class),
- getRmFolder().getItems().stream()
- .map(ObjectRef::getId)
- .map(Object::toString)
- .toArray(String[]::new))));
-
- List> execute =
- directoryEndpoint.getDefaultRestClient().aqlEndpoint().execute(query);
-
- return execute.stream().map(Record1::value1).collect(Collectors.toList());
- }
-
- /**
- * Returns the items stored in the current folder
- * @return The items of the current folder.
- */
- @Override
- public List> getItems() {
- return getRmFolder().getItems();
- }
-
- void sync() {
- getRmFolder();
- directoryEndpoint.saveToDb();
- }
-
- private String extractTemplateId(Class clazz) {
- Template annotation = (Template) clazz.getAnnotation(Template.class);
- return annotation.value();
- }
-
- private void addToFolder(ObjectVersionId versionId) {
- addItemToFolder(versionId);
- }
-
- private void addItemToFolder(ObjectVersionId versionId) {
- Folder folder = getRmFolder();
- if (folder.getItems() == null) {
- folder.setItems(new ArrayList<>());
- }
- folder.getItems()
- .add(new ObjectRef<>(
- new ObjectVersionId(versionId.getObjectId().getValue()),
- versionId.getCreatingSystemId().getValue(),
- "VERSIONED_COMPOSITION"));
- directoryEndpoint.saveToDb();
- }
-
- @Override
- public void addItemToRmFolder(ObjectVersionId versionId) {
- addItemToFolder(versionId);
- }
-}
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 4ef47f077..84bd53cc6 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
@@ -39,7 +39,6 @@
import org.ehrbase.openehr.sdk.generator.commons.aql.record.Record1;
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.top.TopExpresion;
import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.BloodPressureTrainingSampleObservationProxy;
import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.TestData;
import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition;
@@ -61,7 +60,7 @@ void testExecute() {
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0());
Query> query = Query.buildNativeQuery(
- "select a/template_id, a/context/start_time from EHR e[ehr_id/value = $ehr_id] contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1]",
+ "select a/archetype_details/template_id/value, a/context/start_time from EHR e[ehr_id/value = $ehr_id] contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1]",
String.class,
DvDateTime.class);
@@ -79,7 +78,7 @@ void testExecuteProxy() {
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0());
Query> query = Query.buildNativeQuery(
- "select a/template_id, o from EHR e[ehr_id/value = $ehr_id] contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains OBSERVATION o ",
+ "select a/archetype_details/template_id/value, o from EHR e[ehr_id/value = $ehr_id] contains COMPOSITION a [openEHR-EHR-COMPOSITION.sample_encounter.v1] contains OBSERVATION o ",
String.class,
BloodPressureTrainingSampleObservationProxy.class);
@@ -245,12 +244,6 @@ class TestCase {
UUID.fromString(comp1.getVersionUid().getObjectId().getValue()),
UUID.fromString(comp2.getVersionUid().getObjectId().getValue())));
- testCases.add(new TestCase(
- 3,
- Condition.exists(containmentObservation.DEVICE).not(),
- UUID.fromString(comp1.getVersionUid().getObjectId().getValue()),
- UUID.fromString(comp2.getVersionUid().getObjectId().getValue())));
-
testCases.forEach(t -> {
EntityQuery> entityQuery = Query.buildEntityQuery(
containmentComposition, containmentComposition.EHRBASE_BLOOD_PRESSURE_SIMPLE_DE_V0_COMPOSITION);
@@ -351,104 +344,19 @@ class TestCase {
UUID.fromString(comp3.getVersionUid().getObjectId().getValue())));
testCases.forEach(t -> {
- EntityQuery> entityQuery = Query.buildEntityQuery(
- containmentComposition, containmentComposition.EHRBASE_BLOOD_PRESSURE_SIMPLE_DE_V0_COMPOSITION);
+ EntityQuery> entityQuery =
+ Query.buildEntityQuery(
+ containmentComposition,
+ containmentComposition.EHRBASE_BLOOD_PRESSURE_SIMPLE_DE_V0_COMPOSITION,
+ containmentObservation.SYSTOLIC_MAGNITUDE,
+ containmentObservation.DIASTOLIC_MAGNITUDE);
Parameter ehrIdParameter = entityQuery.buildParameter();
Condition where = Condition.equal(EhrFields.EHR_ID(), ehrIdParameter);
entityQuery.where(where).orderBy(t.orderBy);
assertThat(openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr)))
- .extracting(Record1::value1)
- .extracting(EhrbaseBloodPressureSimpleDeV0Composition::getVersionUid)
- .extracting(ObjectVersionId::getObjectId)
- .extracting(UID::getValue)
- .extracting(UUID::fromString)
- .as("TestCase %s", t.id)
- .containsExactly(t.uuids);
- });
- }
-
- @Test
- void testExecuteEntityTOP() {
-
- ehr = openEhrClient.ehrEndpoint().createEhr();
-
- EhrbaseBloodPressureSimpleDeV0Composition comp1 = openEhrClient
- .compositionEndpoint(ehr)
- .mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0());
-
- EhrbaseBloodPressureSimpleDeV0Composition ehrbaseBloodPressureSimpleDeV0Composition =
- TestData.buildEhrbaseBloodPressureSimpleDeV0();
- ehrbaseBloodPressureSimpleDeV0Composition
- .getBloodPressureTrainingSample()
- .get(0)
- .setSystolicMagnitude(44d);
- EhrbaseBloodPressureSimpleDeV0Composition comp2 = openEhrClient
- .compositionEndpoint(ehr)
- .mergeCompositionEntity(ehrbaseBloodPressureSimpleDeV0Composition);
-
- EhrbaseBloodPressureSimpleDeV0Composition ehrbaseBloodPressureSimpleDeV0Composition2 =
- TestData.buildEhrbaseBloodPressureSimpleDeV0();
- ehrbaseBloodPressureSimpleDeV0Composition2
- .getBloodPressureTrainingSample()
- .get(0)
- .setSystolicMagnitude(44d);
- ehrbaseBloodPressureSimpleDeV0Composition2
- .getBloodPressureTrainingSample()
- .get(0)
- .setDiastolicMagnitude(44d);
- EhrbaseBloodPressureSimpleDeV0Composition comp3 = openEhrClient
- .compositionEndpoint(ehr)
- .mergeCompositionEntity(ehrbaseBloodPressureSimpleDeV0Composition2);
-
- EhrbaseBloodPressureSimpleDeV0CompositionContainment containmentComposition =
- EhrbaseBloodPressureSimpleDeV0CompositionContainment.getInstance();
-
- BloodPressureTrainingSampleObservationContainment containmentObservation =
- BloodPressureTrainingSampleObservationContainment.getInstance();
-
- containmentComposition.setContains(containmentObservation);
-
- class TestCase {
- int id;
- TopExpresion topExpresion;
- UUID[] uuids;
-
- TestCase(int id, TopExpresion topExpresion, UUID... uuids) {
- this.id = id;
- this.topExpresion = topExpresion;
- this.uuids = uuids;
- }
- }
-
- List testCases = new ArrayList<>();
-
- testCases.add(new TestCase(
- 1,
- TopExpresion.forward(1),
- UUID.fromString(comp3.getVersionUid().getObjectId().getValue())));
-
- /* TODO: Direction is ignored in ehrbase. See https://github.com/ehrbase/ehrbase/issues/265
- testCases.add(new TestCase(2,
- TopExpresion.backward(1),
- (UUID.fromString(comp1.getVersionUid().getObjectId().getValue())));
- */
- testCases.forEach(t -> {
- EntityQuery> entityQuery = Query.buildEntityQuery(
- containmentComposition, containmentComposition.EHRBASE_BLOOD_PRESSURE_SIMPLE_DE_V0_COMPOSITION);
-
- Parameter ehrIdParameter = entityQuery.buildParameter();
-
- Condition where = Condition.equal(EhrFields.EHR_ID(), ehrIdParameter);
- entityQuery
- .top(t.topExpresion)
- .where(where)
- .orderBy(OrderByExpression.descending(containmentObservation.SYSTOLIC_MAGNITUDE)
- .andThenDescending(containmentObservation.DIASTOLIC_MAGNITUDE));
-
- assertThat(openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr)))
- .extracting(Record1::value1)
+ .extracting(Record3::value1)
.extracting(EhrbaseBloodPressureSimpleDeV0Composition::getVersionUid)
.extracting(ObjectVersionId::getObjectId)
.extracting(UID::getValue)
@@ -495,12 +403,12 @@ void testQueryCount() {
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0());
Query> query = Query.buildNativeQuery(
- "select count(e/ehr_id/value) from EHR e contains composition c", Integer.class);
+ "select count(e/ehr_id/value) from EHR e contains COMPOSITION c", Integer.class);
List> result = openEhrClient.aqlEndpoint().execute(query);
assertThat(result).isNotNull();
- query = Query.buildNativeQuery("select count(c/uid/value) from EHR e contains composition c", Integer.class);
+ query = Query.buildNativeQuery("select count(c/uid/value) from EHR e contains COMPOSITION c", Integer.class);
result = openEhrClient.aqlEndpoint().execute(query);
assertThat(result).isNotNull().hasSize(1);
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 2a6f60d25..bf0e32d98 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
@@ -25,17 +25,21 @@
import com.nedap.archie.rm.changecontrol.Contribution;
import com.nedap.archie.rm.composition.Composition;
+import com.nedap.archie.rm.datatypes.CodePhrase;
+import com.nedap.archie.rm.datavalues.DvCodedText;
import com.nedap.archie.rm.datavalues.DvText;
import com.nedap.archie.rm.directory.Folder;
import com.nedap.archie.rm.generic.AuditDetails;
+import com.nedap.archie.rm.generic.PartyIdentified;
+import com.nedap.archie.rm.support.identification.ObjectRef;
import com.nedap.archie.rm.support.identification.ObjectVersionId;
+import com.nedap.archie.rm.support.identification.TerminologyId;
import java.io.IOException;
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.openehrclient.ContributionEndpoint;
-import org.ehrbase.openehr.sdk.client.openehrclient.FolderDAO;
import org.ehrbase.openehr.sdk.client.openehrclient.builder.ContributionBuilder;
import org.ehrbase.openehr.sdk.client.templateprovider.TestDataTemplateProvider;
import org.ehrbase.openehr.sdk.generator.commons.test_data.dto.ProxyEhrbaseBloodPressureSimpleDeV0Composition;
@@ -58,6 +62,13 @@ public void testSaveAndGetContribution() throws IOException {
ContributionCreateDto contributionDto =
new CanonicalJson().unmarshal(contribution, ContributionCreateDto.class);
+ contributionDto.setUid(null);
+ contributionDto.getAudit().setTimeCommitted(null);
+ contributionDto.getVersions().stream().forEach(v -> {
+ v.getCommitAudit().setTimeCommitted(null);
+ v.setContribution(null);
+ });
+
UUID contributionEntity = openEhrClient.contributionEndpoint(ehr).saveContribution(contributionDto);
Optional remoteContribution =
@@ -440,9 +451,11 @@ public void testSaveContributionWithFolderCreationModification() throws IOExcept
public void testSaveContributionWithFolderModification() throws IOException {
ehr = openEhrClient.ehrEndpoint().createEhr();
+ Folder rootFolder = new Folder();
// Create root folder
- FolderDAO folder = openEhrClient.folder(ehr, "");
- Folder rootFolder = folder.getRmFolder();
+ ObjectVersionId directory = openEhrClient.directoryCrudEndpoint(ehr).createDirectory(rootFolder);
+
+ rootFolder.setUid(directory);
// Prepare first composition
GeneratedDtoToRmConverter generatedDtoToRmConverter =
@@ -454,7 +467,10 @@ public void testSaveContributionWithFolderModification() throws IOException {
(Composition) generatedDtoToRmConverter.toRMObject(mergeMinimalEvaluationEnV1Composition());
// Add first composition to folder
- folder.addItemToRmFolder(new ObjectVersionId((compositionWithId.getUid().toString())));
+ rootFolder
+ .getItems()
+ .add(new ObjectRef<>(
+ new ObjectVersionId((compositionWithId.getUid().toString())), "local", "Composition"));
// Prepare second composition
GeneratedDtoToRmConverter cut = new GeneratedDtoToRmConverter(new TestDataTemplateProvider());
@@ -462,11 +478,14 @@ public void testSaveContributionWithFolderModification() throws IOException {
ProxyEhrbaseBloodPressureSimpleDeV0Composition proxyComposition =
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(proxyDto);
Composition unflattenSecondComposition = (Composition) cut.toRMObject(proxyComposition);
- unflattenSecondComposition.setUid(null);
+ unflattenSecondComposition.setUid(new ObjectVersionId(UUID.randomUUID().toString(), "local.ehrbase.org", "1"));
- // Add second composition to new folder
- FolderDAO subFolder = folder.getSubFolder("test/contribution");
- subFolder.addItemToRmFolder(proxyComposition.getVersionUid());
+ // Add second composition
+
+ rootFolder
+ .getItems()
+ .add(new ObjectRef<>(
+ new ObjectVersionId((unflattenSecondComposition.getUid().toString())), "local", "Composition"));
// Create contribution
ContributionCreateDto contribution = ContributionBuilder.builder(createAuditDetails())
@@ -495,11 +514,8 @@ public void testSaveContributionWithFolderModification() throws IOException {
expectedCompositionsCreatedTimes,
countNumberOfChangedLocatableObjectByVersion(remoteContribution.get(), "1"));
assertEquals(
- expectedCompositionsModifiedTimes,
+ expectedCompositionsModifiedTimes + expectedFolderModifiedTimes,
countNumberOfChangedLocatableObjectByVersion(remoteContribution.get(), "2"));
- assertEquals(
- expectedFolderModifiedTimes,
- countNumberOfChangedLocatableObjectByVersion(remoteContribution.get(), "6"));
}
private static String getCompositionVersion(Contribution remoteContribution) {
@@ -514,13 +530,14 @@ private static UUID getCompositionUuid(Composition composition) {
return UUID.fromString(compositionId.substring(0, compositionId.indexOf("::")));
}
- private static AuditDetails createAuditDetails() throws IOException {
- String contributionModificationJson =
- IOUtils.toString(ONE_ENTRY_COMPOSITION_MODIFICATION_LATEST.getStream(), StandardCharsets.UTF_8);
- ContributionCreateDto contributionDto =
- new CanonicalJson().unmarshal(contributionModificationJson, ContributionCreateDto.class);
+ private static AuditDetails createAuditDetails() {
- return contributionDto.getVersions().get(0).getCommitAudit();
+ AuditDetails auditDetails = new AuditDetails();
+ auditDetails.setChangeType(
+ new DvCodedText("modification", new CodePhrase(new TerminologyId("openehr"), "251")));
+ auditDetails.setCommitter(new PartyIdentified(null, "Dr. Yamamoto", null));
+ auditDetails.setSystemId("ehrbase");
+ return auditDetails;
}
private MinimalEvaluationEnV1Composition mergeMinimalEvaluationEnV1Composition() throws IOException {
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
deleted file mode 100644
index e04b021cb..000000000
--- a/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultRestDirectoryEndpointIT.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2019 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 java.net.URISyntaxException;
-import java.util.List;
-import org.ehrbase.openehr.sdk.client.openehrclient.FolderDAO;
-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.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
-public class DefaultRestDirectoryEndpointIT extends SdkClientTestIT {
-
- private static DefaultRestClient defaultRestClient;
-
- @BeforeAll
- public static void setup() throws URISyntaxException {
-
- SdkClientTestIT.setup();
- defaultRestClient = SdkClientTestIT.setupRestClientWithDefaultTemplateProvider();
- }
-
- @Test
- void testSetName() {
- ehr = openEhrClient.ehrEndpoint().createEhr();
- FolderDAO root = openEhrClient.folder(ehr, "");
- assertThat(root.getName()).isEqualTo("root");
- root.setName("case1");
- assertThat(root.getName()).isEqualTo("case1");
- }
-
- @Test
- void testGetSubFolder() {
- ehr = openEhrClient.ehrEndpoint().createEhr();
- FolderDAO root = openEhrClient.folder(ehr, "");
- FolderDAO visit = root.getSubFolder("case1/visit1");
- assertThat(visit.getName()).isEqualTo("visit1");
- }
-
- @Test
- void testSaveEntity() {
- ehr = openEhrClient.ehrEndpoint().createEhr();
-
- FolderDAO root = openEhrClient.folder(ehr, "");
-
- FolderDAO visit = root.getSubFolder("case1/visit1");
-
- EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV01 =
- TestData.buildEhrbaseBloodPressureSimpleDeV0();
- visit.addCompositionEntity(bloodPressureSimpleDeV01);
-
- EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV02 =
- TestData.buildEhrbaseBloodPressureSimpleDeV0();
- visit.addCompositionEntity(bloodPressureSimpleDeV02);
-
- EhrbaseMultiOccurrenceDeV1Composition ehrbaseMultiOccurrenceDeV1 = TestData.buildEhrbaseMultiOccurrenceDeV1();
- visit.addCompositionEntity(ehrbaseMultiOccurrenceDeV1);
-
- List actual =
- visit.find(EhrbaseBloodPressureSimpleDeV0Composition.class);
- assertThat(actual).size().isEqualTo(2);
-
- List actual2 = visit.find(EhrbaseMultiOccurrenceDeV1Composition.class);
- assertThat(actual2).size().isEqualTo(1);
- }
-
- @Test
- void testSaveRaw() {
- ehr = openEhrClient.ehrEndpoint().createEhr();
-
- FolderDAO root = openEhrClient.folder(ehr, "");
-
- FolderDAO visit = root.getSubFolder("case1/visit1");
-
- Composition composition = (Composition) new GeneratedDtoToRmConverter(
- defaultRestClient.getTemplateProvider(), defaultRestClient.getDefaultValuesProvider())
- .toRMObject(TestData.buildEhrbaseBloodPressureSimpleDeV0());
- visit.addRaw(composition);
-
- List actual =
- visit.find(EhrbaseBloodPressureSimpleDeV0Composition.class);
- assertThat(actual).size().isEqualTo(1);
- }
-
- @Test
- void testListSubFolderNames() {
- ehr = openEhrClient.ehrEndpoint().createEhr();
-
- FolderDAO root = openEhrClient.folder(ehr, "");
- root.getSubFolder("case1");
- root.getSubFolder("case2");
- root.getSubFolder("case3/visit1");
- root.getSubFolder("case3/visit2");
-
- assertThat(root.listSubFolderNames()).containsExactlyInAnyOrder("case1", "case2", "case3");
-
- assertThat(root.getSubFolder("case3").listSubFolderNames()).containsExactlyInAnyOrder("visit1", "visit2");
- }
-}
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 01499f27f..ac65601cb 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
@@ -60,7 +60,7 @@ void testCreateEhrWithStatus() {
HierObjectId subjectId = new HierObjectId(UUID.randomUUID().toString());
ehrStatus.setSubject(new PartySelf(new PartyRef(subjectId, "default", "PERSON")));
- ehrStatus.setArchetypeNodeId("just-a-status");
+ ehrStatus.setArchetypeNodeId("openEHR-EHR-EHR_STATUS.generic.v1");
ehrStatus.setName(new DvText("Status"));
ehr = openEhrClient.ehrEndpoint().createEhr(ehrStatus);
@@ -83,7 +83,7 @@ void testUpdateEhrStatus() throws IOException {
String value = IOUtils.toString(ItemStruktureTestDataCanonicalJson.SIMPLE_EHR_OTHER_Details.getStream(), UTF_8);
ehrStatus.setOtherDetails(new CanonicalJson().unmarshal(value, ItemTree.class));
- ehrStatus.getOtherDetails().setArchetypeNodeId("other-details-test");
+ ehrStatus.getOtherDetails().setArchetypeNodeId("openEHR-EHR-EHR_STATUS.generic.v1");
ehrStatus.getOtherDetails().setName(new DvText("test"));
openEhrClient.ehrEndpoint().updateEhrStatus(ehr, ehrStatus);
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
index 60894082b..148ae4908 100644
--- 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
@@ -45,7 +45,7 @@ public class EHRbaseContainer extends GenericContainer {
protected static final String EHRBASE_PASSWORD = "ehrbase_restricted";
- private static final String IMAGE = "ehrbase/ehrbase:0.32.0";
+ private static final String IMAGE = "ehrbase/ehrbase:2.0.0";
private final Logger log = LoggerFactory.getLogger(this.getClass());
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
index 2d0abe120..8ec623f8e 100644
--- 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
@@ -35,7 +35,7 @@ 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 IMAGE = "ehrbase/ehrbase-v2-postgres:16.2";
private static final String POSTGRES_MAPPING_USER = "postgres";
private static final String POSTGRES_MAPPING_PW = "postgres";
diff --git a/pom.xml b/pom.xml
index 7f3c93da6..cd1e2213d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -183,7 +183,11 @@
maven-surefire-plugin
+ com.github.better-care:web-template-tests
${surefireArgLine}
+
+ **/*Test.java
+
diff --git a/test-data/src/main/resources/item_structure/canonical_json/ehr_other_details.json b/test-data/src/main/resources/item_structure/canonical_json/ehr_other_details.json
index 6a1c99b69..4f4a191fa 100644
--- a/test-data/src/main/resources/item_structure/canonical_json/ehr_other_details.json
+++ b/test-data/src/main/resources/item_structure/canonical_json/ehr_other_details.json
@@ -11,11 +11,11 @@
"_type": "ARCHETYPED",
"archetype_id": {
"_type": "ARCHETYPE_ID",
- "value": "openEHR-DEMOGRAPHIC-CLUSTER.person_death_data_iso.v0"
+ "value": "openEHR-EHR-CLUSTER.person_death_data_iso.v0"
},
"rm_version": "1.0.2"
},
- "archetype_node_id": "openEHR-DEMOGRAPHIC-CLUSTER.person_death_data_iso.v0",
+ "archetype_node_id": "openEHR-EHR-CLUSTER.person_death_data_iso.v0",
"items": [
{
"_type": "ELEMENT",
@@ -41,11 +41,11 @@
"_type": "ARCHETYPED",
"archetype_id": {
"_type": "ARCHETYPE_ID",
- "value": "openEHR-DEMOGRAPHIC-CLUSTER.person_birth_data_iso.v0"
+ "value": "openEHR-EHR-CLUSTER.person_birth_data_iso.v0"
},
"rm_version": "1.0.2"
},
- "archetype_node_id": "openEHR-DEMOGRAPHIC-CLUSTER.person_birth_data_iso.v0",
+ "archetype_node_id": "openEHR-EHR-CLUSTER.person_birth_data_iso.v0",
"items": [
{
"_type": "ELEMENT",