From 570076813e0ee8faf56e0afbb2e19c11fab39ba7 Mon Sep 17 00:00:00 2001 From: Quentin Ligier Date: Sun, 22 Mar 2026 20:06:26 +0100 Subject: [PATCH 01/10] Split tests by tag --- .github/workflows/maven.yml | 40 ++++++++++--------- .../test/java/ch/ahdis/matchbox/TestTags.java | 11 +++++ .../matchbox/gazelle/GazelleApiR4Test.java | 5 ++- .../ahdis/matchbox/mapping/TransformTest.java | 8 ++-- .../matchbox/test/MatchboxApiR4BTest.java | 21 ++++++---- .../matchbox/test/MatchboxApiR4Test.java | 25 +++++++++--- .../matchbox/test/MatchboxApiR5Test.java | 23 ++++++----- .../matchbox/test/MatchboxApiR5onR4Test.java | 18 ++++++--- 8 files changed, 98 insertions(+), 53 deletions(-) create mode 100644 matchbox-server/src/test/java/ch/ahdis/matchbox/TestTags.java diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 6ec99de10b..50d05bbf70 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -23,26 +23,30 @@ jobs: distribution: adopt cache: maven - - name: Run the tests in Maven + - name: Run the core tests in Maven timeout-minutes: 15 # We need a timeout here env: MAVEN_OPTS: -Xmx12g - run: mvn --batch-mode --no-transfer-progress --update-snapshots verify - - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: testresults - path: | - ./matchbox-server/target/surefire-reports - ./matchbox-engine/target/surefire-reports - retention-days: 2 + run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='core' test - - name: Test Summary - uses: test-summary/action@v2 - with: - paths: | - matchbox-engine/target/surefire-reports/TEST-*.xml - matchbox-server/target/surefire-reports/TEST-*.xml - if: always() + - name: Run the validation tests in Maven + timeout-minutes: 15 + # We need a timeout here + env: + MAVEN_OPTS: -Xmx12g + run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='validation' test + + - name: Run the Gazelle API tests in Maven + timeout-minutes: 15 + # We need a timeout here + env: + MAVEN_OPTS: -Xmx12g + run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='gazelle' test + + - name: Run the mapping tests in Maven + timeout-minutes: 15 + # We need a timeout here + env: + MAVEN_OPTS: -Xmx12g + run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='mapping' test diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/TestTags.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/TestTags.java new file mode 100644 index 0000000000..8ccd7c4b67 --- /dev/null +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/TestTags.java @@ -0,0 +1,11 @@ +package ch.ahdis.matchbox; + +/** + * Some tags to split our tests into logical and moderately sized groups. + **/ +public class TestTags { + public static final String CORE = "core"; + public static final String VALIDATION = "validation"; + public static final String GAZELLE = "gazelle"; + public static final String MAPPING = "mapping"; +} diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java index 7b68dcc6a6..14c3d44cab 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java @@ -1,11 +1,13 @@ package ch.ahdis.matchbox.gazelle; import ca.uhn.fhir.jpa.starter.Application; +import ch.ahdis.matchbox.TestTags; import ch.ahdis.matchbox.validation.gazelle.models.validation.SeverityLevel; import ch.ahdis.matchbox.validation.gazelle.models.validation.ValidationReport; import ch.ahdis.matchbox.validation.gazelle.models.validation.ValidationTestResult; import ch.ahdis.matchbox.test.CompareUtil; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.boot.test.context.SpringBootTest; @@ -26,7 +28,8 @@ @ActiveProfiles("test-r4") @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class GazelleApiR4Test extends AbstractGazelleTest { +@Tag(TestTags.GAZELLE) +class GazelleApiR4Test extends AbstractGazelleTest { private final GazelleClient client = new GazelleClient("http://localhost:8081/matchboxv3/gazelle/"); diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java index 26daec481d..a5268227dc 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java @@ -1,12 +1,13 @@ package ch.ahdis.matchbox.mapping; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.starter.Application; +import ch.ahdis.matchbox.TestTags; import ch.ahdis.matchbox.test.CompareUtil; import ch.ahdis.matchbox.test.ValidationClient; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.boot.test.context.SpringBootTest; @@ -37,7 +38,8 @@ @ActiveProfiles("test-transform") @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class TransformTest { +@Tag(TestTags.MAPPING) +class TransformTest { private static final String TARGET_SERVER = "http://localhost:8086/matchboxv3"; private static final FhirContext FHIR_CONTEXT = FhirContext.forR4Cached(); @@ -94,7 +96,7 @@ void testTransformUtf8() throws Exception { assertTrue(docRef.contains("")); assertTrue(docRef.contains("")); } - + @Test void testTransformEncounterR4() throws Exception { // Test the regular $transform operation with an R4 resource diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java index 35635f2517..0fca55ff7a 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java @@ -2,16 +2,17 @@ import ca.uhn.fhir.context.BaseRuntimeChildDefinition; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.jpa.starter.Application; +import ch.ahdis.matchbox.TestTags; import org.apache.commons.io.FileUtils; import org.hl7.fhir.instance.model.api.*; import org.hl7.fhir.r4b.model.OperationOutcome; import org.hl7.fhir.r4b.model.OperationOutcome.IssueSeverity; import org.hl7.fhir.r4b.model.OperationOutcome.OperationOutcomeIssueComponent; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.boot.test.context.SpringBootTest; @@ -38,9 +39,9 @@ @ActiveProfiles("test-r4b") @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class MatchboxApiR4BTest { +class MatchboxApiR4BTest { - static public int getValidationFailures(OperationOutcome outcome) { + static int getValidationFailures(OperationOutcome outcome) { int fails = 0; if (outcome != null && outcome.getIssue() != null) { for (OperationOutcomeIssueComponent issue : outcome.getIssue()) { @@ -60,7 +61,7 @@ static public int getValidationFailures(OperationOutcome outcome) { private String targetServer = "http://localhost:8083/matchboxv3/fhir"; private final FhirContext context = FhirContext.forR4BCached(); - + @BeforeAll void waitUntilStartup() throws Exception { Thread.sleep(10000); // give the server some time to start up @@ -129,7 +130,8 @@ public String getTxServer(FhirContext ctx, IBaseOperationOutcome outcome) { } @Test - public void validatePatientRawR4B() { + @Tag(TestTags.VALIDATION) + void validatePatientRawR4B() { ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); String patient = "\n" + " \n" @@ -152,7 +154,8 @@ public void validatePatientRawR4B() { } @Test - public void verifyCachingImplementationGuides() { + @Tag(TestTags.CORE) + void verifyCachingImplementationGuides() { ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); String resource = "\n" + // @@ -178,8 +181,9 @@ public void verifyCachingImplementationGuides() { } @Test + @Tag(TestTags.VALIDATION) // https://gazelle.ihe.net/jira/browse/EHS-431 - public void validateEhs431() throws IOException { + void validateEhs431() throws IOException { // ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); @@ -195,8 +199,9 @@ public void validateEhs431() throws IOException { } @Test + @Tag(TestTags.VALIDATION) // https://gazelle.ihe.net/jira/browse/EHS-419 - public void validateEhs419() throws IOException { + void validateEhs419() throws IOException { // ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java index 82378a0b37..38c0e15fa7 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java @@ -4,6 +4,7 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.jpa.starter.Application; +import ch.ahdis.matchbox.TestTags; import ch.ahdis.matchbox.validation.gazelle.models.validation.ValidationItem; import ch.ahdis.matchbox.validation.gazelle.models.validation.ValidationReport; import ch.ahdis.matchbox.validation.gazelle.models.validation.ValidationRequest; @@ -14,10 +15,7 @@ import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity; import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent; import org.hl7.fhir.r4.model.Parameters; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.*; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.core.io.ClassPathResource; @@ -60,6 +58,7 @@ void waitUntilStartup() throws Exception { } @Test + @Tag(TestTags.VALIDATION) void validatePatientRawR4() { String patient = """ @@ -85,6 +84,7 @@ void validatePatientRawR4() { } @Test + @Tag(TestTags.CORE) void verifyCachingImplementationGuides() { String resource = """ @@ -143,6 +143,7 @@ void verifyCachingImplementationGuides() { } @Test + @Tag(TestTags.CORE) void verifyIgVersioning() { String resource = """ @@ -192,6 +193,7 @@ void verifyIgVersioning() { } @Test + @Tag(TestTags.GAZELLE) void verifyIgVersioningGazelle() throws Exception { String resource = """ @@ -233,6 +235,7 @@ void verifyIgVersioningGazelle() throws Exception { @Test + @Tag(TestTags.VALIDATION) // https://gazelle.ihe.net/jira/browse/EHS-431 void validateEhs431() throws IOException { // IBaseOperationOutcome operationOutcome = @@ -245,6 +248,7 @@ void validateEhs431() throws IOException { } @Test + @Tag(TestTags.GAZELLE) void validateEhs431Gazelle() throws Exception { ValidationReport report = this.validateWithGazelle(getContent("ehs-431.json"), profileCore("Bundle")); @@ -252,6 +256,7 @@ void validateEhs431Gazelle() throws Exception { } @Test + @Tag(TestTags.VALIDATION) // https://gazelle.ihe.net/jira/browse/EHS-419 void validateEhs419() throws IOException { IBaseOperationOutcome operationOutcome = validationClient.validate(getContent("ehs-419.json"), @@ -261,6 +266,7 @@ void validateEhs419() throws IOException { } @Test + @Tag(TestTags.VALIDATION) void validateIgnoreError() { String patient = "\r\n" + // @@ -287,6 +293,7 @@ void validateIgnoreError() { } @Test + @Tag(TestTags.VALIDATION) void validateIgnoreErrorMatchboxTest() throws Exception { String practitioner = "\n" + // " \n" + // @@ -303,7 +310,7 @@ void validateIgnoreErrorMatchboxTest() throws Exception { " \n" + // " \n" + // ""; - + IBaseOperationOutcome operationOutcome = this.validationClient.validate(practitioner,"http://matchbox.health/ig/test/r4/StructureDefinition/practitioner-identifier-required"); assertEquals(0, getValidationFailures((OperationOutcome) operationOutcome)); @@ -312,6 +319,7 @@ void validateIgnoreErrorMatchboxTest() throws Exception { } @Test + @Tag(TestTags.GAZELLE) void validateEhs419Gazelle() throws Exception { ValidationReport report = this.validateWithGazelle(getContent("ehs-419.json"), "http://hl7.org/fhir/StructureDefinition/Patient"); @@ -319,6 +327,7 @@ void validateEhs419Gazelle() throws Exception { } @Test + @Tag(TestTags.VALIDATION) void validateXVersionSlicingExtensions() throws Exception { String encounter = "\n" + // @@ -345,13 +354,14 @@ void validateXVersionSlicingExtensions() throws Exception { " \n" + // " \n" + // ""; - + IBaseOperationOutcome operationOutcome = this.validationClient.validate(encounter, "http://matchbox.health/ig/test/r4/StructureDefinition/encounter-ext-r5"); assertEquals(0, getValidationFailures((OperationOutcome) operationOutcome)); } @Test + @Tag(TestTags.VALIDATION) @Disabled("For some reason, the validation engine does not fail on unknown extensions with the default configuration, needs further investigation") void validateUnknownExtensionIsRejectedByDefault() throws Exception { final var patient = getContent("patient-dicom.json"); @@ -360,6 +370,7 @@ void validateUnknownExtensionIsRejectedByDefault() throws Exception { } @Test + @Tag(TestTags.VALIDATION) void validateUnknownExtensionIsAcceptedWithAny() throws Exception { final var patient = getContent("patient-dicom.json"); final var parameters = new Parameters(); @@ -370,6 +381,7 @@ void validateUnknownExtensionIsAcceptedWithAny() throws Exception { } @Test + @Tag(TestTags.VALIDATION) void validateUnknownExtensionIsAcceptedWithValidDomain() throws Exception { final var patient = getContent("patient-dicom.json"); final var parameters = new Parameters(); @@ -380,6 +392,7 @@ void validateUnknownExtensionIsAcceptedWithValidDomain() throws Exception { } @Test + @Tag(TestTags.VALIDATION) @Disabled("For some reason, the validation engine does not fail on unknown extensions with the default configuration, needs further investigation") void validateUnknownExtensionIsRejectedWithWrongDomain() throws Exception { final var patient = getContent("patient-dicom.json"); diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java index b240e6709b..9e918df20b 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java @@ -2,16 +2,17 @@ import ca.uhn.fhir.context.BaseRuntimeChildDefinition; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.jpa.starter.Application; +import ch.ahdis.matchbox.TestTags; import org.apache.commons.io.FileUtils; import org.hl7.fhir.instance.model.api.*; import org.hl7.fhir.r5.model.OperationOutcome; import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity; import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.boot.test.context.SpringBootTest; @@ -25,11 +26,7 @@ import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; -import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -42,9 +39,9 @@ @ActiveProfiles("test-r5") @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class MatchboxApiR5Test { +class MatchboxApiR5Test { - static public int getValidationFailures(OperationOutcome outcome) { + static int getValidationFailures(OperationOutcome outcome) { int fails = 0; if (outcome != null && outcome.getIssue() != null) { for (OperationOutcomeIssueComponent issue : outcome.getIssue()) { @@ -133,7 +130,8 @@ public String getTxServer(FhirContext ctx, IBaseOperationOutcome outcome) { } @Test - public void validatePatientRawR5() { + @Tag(TestTags.VALIDATION) + void validatePatientRawR5() { ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); String patient = "\n" + " \n" @@ -156,7 +154,8 @@ public void validatePatientRawR5() { } @Test - public void verifyCachingImplementationGuides() { + @Tag(TestTags.CORE) + void verifyCachingImplementationGuides() { ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); String resource = "\n" + // @@ -182,8 +181,9 @@ public void verifyCachingImplementationGuides() { } @Test + @Tag(TestTags.VALIDATION) // https://gazelle.ihe.net/jira/browse/EHS-431 - public void validateEhs431() throws IOException { + void validateEhs431() throws IOException { // ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); @@ -199,8 +199,9 @@ public void validateEhs431() throws IOException { } @Test + @Tag(TestTags.VALIDATION) // https://gazelle.ihe.net/jira/browse/EHS-419 - public void validateEhs419() throws IOException { + void validateEhs419() throws IOException { // ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java index 8a2990c6d9..a2e8976f42 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java @@ -5,12 +5,14 @@ import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.jpa.starter.Application; +import ch.ahdis.matchbox.TestTags; import org.apache.commons.io.FileUtils; import org.hl7.fhir.instance.model.api.*; import org.hl7.fhir.r4.model.OperationOutcome; import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity; import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.boot.test.context.SpringBootTest; @@ -33,9 +35,9 @@ @ActiveProfiles("test-r5onr4") @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class MatchboxApiR5onR4Test { +class MatchboxApiR5onR4Test { - static public int getValidationFailures(OperationOutcome outcome) { + static int getValidationFailures(OperationOutcome outcome) { int fails = 0; if (outcome != null && outcome.getIssue() != null) { for (OperationOutcomeIssueComponent issue : outcome.getIssue()) { @@ -124,7 +126,8 @@ public String getTxServer(FhirContext ctx, IBaseOperationOutcome outcome) { } @Test - public void validatePatientRawR5() { + @Tag(TestTags.VALIDATION) + void validatePatientRawR5() { ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); String patient = "\n" + " \n" @@ -147,7 +150,8 @@ public void validatePatientRawR5() { } @Test - public void verifyCachingImplementationGuides() { + @Tag(TestTags.CORE) + void verifyCachingImplementationGuides() { ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); String resource = "\n" + // @@ -173,8 +177,9 @@ public void verifyCachingImplementationGuides() { } @Test + @Tag(TestTags.VALIDATION) // https://gazelle.ihe.net/jira/browse/EHS-431 - public void validateEhs431() throws IOException { + void validateEhs431() throws IOException { // ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); @@ -190,8 +195,9 @@ public void validateEhs431() throws IOException { } @Test + @Tag(TestTags.VALIDATION) // https://gazelle.ihe.net/jira/browse/EHS-419 - public void validateEhs419() throws IOException { + void validateEhs419() throws IOException { // ValidationClient validationClient = new ValidationClient(this.context, this.targetServer); From 3ea96c39e8ab57f5b56781d89d0f5e5724a50f3a Mon Sep 17 00:00:00 2001 From: Quentin Ligier Date: Sun, 22 Mar 2026 20:18:17 +0100 Subject: [PATCH 02/10] Try disabling default metrics --- .../matchbox/gazelle/GazelleApiR4Test.java | 2 +- .../ahdis/matchbox/mapping/TransformTest.java | 2 +- .../ahdis/matchbox/test/MatchboxApiR4BTest.java | 2 +- .../ahdis/matchbox/test/MatchboxApiR4Test.java | 2 +- .../ahdis/matchbox/test/MatchboxApiR5Test.java | 2 +- .../matchbox/test/MatchboxApiR5onR4Test.java | 2 +- .../resources/application-disable-metrics.yaml | 17 +++++++++++++++++ 7 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 matchbox-server/src/test/resources/application-disable-metrics.yaml diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java index 14c3d44cab..2efda7a819 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java @@ -25,7 +25,7 @@ **/ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @ContextConfiguration(classes = { Application.class }) -@ActiveProfiles("test-r4") +@ActiveProfiles({"test-r4", "disable-metrics"}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @Tag(TestTags.GAZELLE) diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java index a5268227dc..7320c456b9 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java @@ -35,7 +35,7 @@ **/ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @ContextConfiguration(classes = {Application.class}) -@ActiveProfiles("test-transform") +@ActiveProfiles({"test-transform", "disable-metrics"}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @Tag(TestTags.MAPPING) diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java index 0fca55ff7a..9f8135dc93 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java @@ -36,7 +36,7 @@ "hapi.fhir.implementationguides.fhir_terminology.name=", "hapi.fhir.implementationguides.fhir_extensions.name="}) // Unset R4 IGs @ContextConfiguration(classes = {Application.class}) -@ActiveProfiles("test-r4b") +@ActiveProfiles({"test-r4b", "disable-metrics"}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) class MatchboxApiR4BTest { diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java index 38c0e15fa7..3a927e977b 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java @@ -38,7 +38,7 @@ @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) @ContextConfiguration(classes = {Application.class}) -@ActiveProfiles("test-r4") +@ActiveProfiles({"test-r4", "disable-metrics"}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) class MatchboxApiR4Test { diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java index 9e918df20b..e23a396200 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java @@ -36,7 +36,7 @@ "hapi.fhir.implementationguides.fhir_terminology.name=", "hapi.fhir.implementationguides.fhir_extensions.name="}) // Unset R4 IGs @ContextConfiguration(classes = {Application.class}) -@ActiveProfiles("test-r5") +@ActiveProfiles({"test-r5", "disable-metrics"}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) class MatchboxApiR5Test { diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java index a2e8976f42..ebc83f4a29 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java @@ -32,7 +32,7 @@ @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) @ContextConfiguration(classes = { Application.class }) -@ActiveProfiles("test-r5onr4") +@ActiveProfiles({"test-r5onr4", "disable-metrics"}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) class MatchboxApiR5onR4Test { diff --git a/matchbox-server/src/test/resources/application-disable-metrics.yaml b/matchbox-server/src/test/resources/application-disable-metrics.yaml new file mode 100644 index 0000000000..a73f369db8 --- /dev/null +++ b/matchbox-server/src/test/resources/application-disable-metrics.yaml @@ -0,0 +1,17 @@ +# Common configuration of all test Spring profiles. + +## Disable all metrics and the metrics endpoint +management: + metrics: + enable: + all: false + endpoint: + metrics: + enabled: false + endpoints: + web: + exposure: + exclude: "*" + jmx: + exposure: + exclude: "*" From 0e961a62362cc387075710a870e605101925c8d0 Mon Sep 17 00:00:00 2001 From: Quentin Ligier Date: Mon, 23 Mar 2026 22:47:25 +0100 Subject: [PATCH 03/10] Try disabling various features --- .../application-disable-metrics.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/matchbox-server/src/test/resources/application-disable-metrics.yaml b/matchbox-server/src/test/resources/application-disable-metrics.yaml index a73f369db8..83accb208e 100644 --- a/matchbox-server/src/test/resources/application-disable-metrics.yaml +++ b/matchbox-server/src/test/resources/application-disable-metrics.yaml @@ -8,6 +8,8 @@ management: endpoint: metrics: enabled: false + prometheus: + enabled: false endpoints: web: exposure: @@ -15,3 +17,24 @@ management: jmx: exposure: exclude: "*" + prometheus: + metrics: + export: + enabled: false +hapi: + fhir: + openapi_enabled: false + lastn_enabled: false + subscription: + resthook_enabled: false + search-coord-core-pool-size: 1 + search-coord-max-pool-size: 1 + search-coord-queue-capacity: 1 + advanced_lucene_indexing: false + search_index_full_text_enabled: false + +spring: + ai: + mcp: + server: + enabled: false From 081327313aeeca5ee4e50d323dda329e8646c1c9 Mon Sep 17 00:00:00 2001 From: Quentin Ligier Date: Tue, 24 Mar 2026 13:59:55 +0100 Subject: [PATCH 04/10] Refactor engine tests --- .github/workflows/maven.yml | 18 +- .../engine/tests/CdaToFhirTransformTests.java | 232 ++++++------------ .../tests/FhirMappingLanguageTests.java | 118 ++------- .../matchbox/engine/tests/FhirXVersTests.java | 50 ++-- .../engine/tests/R4ValidationTests.java | 2 +- .../engine/tests/R5ValidationTests.java | 7 +- .../engine/tests/SuppressedWarnInfoTests.java | 5 +- .../matchbox/gazelle/GazelleApiR4Test.java | 2 +- .../ahdis/matchbox/mapping/TransformTest.java | 2 +- .../matchbox/test/MatchboxApiR4BTest.java | 2 +- .../matchbox/test/MatchboxApiR4Test.java | 2 +- .../matchbox/test/MatchboxApiR5Test.java | 2 +- .../matchbox/test/MatchboxApiR5onR4Test.java | 2 +- 13 files changed, 128 insertions(+), 316 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 50d05bbf70..d1a890abca 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -19,34 +19,26 @@ jobs: uses: actions/setup-java@v5 # https://github.com/actions/setup-java#usage with: - java-version: 21 + java-version: 25 distribution: adopt cache: maven + - name: Run the engine tests in Maven + timeout-minutes: 15 + run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-engine test + - name: Run the core tests in Maven timeout-minutes: 15 - # We need a timeout here - env: - MAVEN_OPTS: -Xmx12g run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='core' test - name: Run the validation tests in Maven timeout-minutes: 15 - # We need a timeout here - env: - MAVEN_OPTS: -Xmx12g run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='validation' test - name: Run the Gazelle API tests in Maven timeout-minutes: 15 - # We need a timeout here - env: - MAVEN_OPTS: -Xmx12g run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='gazelle' test - name: Run the mapping tests in Maven timeout-minutes: 15 - # We need a timeout here - env: - MAVEN_OPTS: -Xmx12g run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='mapping' test diff --git a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/CdaToFhirTransformTests.java b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/CdaToFhirTransformTests.java index 94a7781817..4c45652884 100644 --- a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/CdaToFhirTransformTests.java +++ b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/CdaToFhirTransformTests.java @@ -23,148 +23,127 @@ import ch.ahdis.matchbox.engine.CdaMappingEngine; import org.apache.commons.io.IOUtils; import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.instance.model.api.IBaseOperationOutcome; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Composition; import org.hl7.fhir.r4.model.Condition; import org.hl7.fhir.r4.model.Observation; -import org.hl7.fhir.r4.model.OperationOutcome; -import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity; -import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Resource; import org.hl7.fhir.r4.model.StructureMap; -import org.hl7.fhir.r5.utils.EOperationOutcome; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; import java.io.InputStream; -import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.Calendar; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) class CdaToFhirTransformTests { - static private CdaMappingEngine engine; - static String cdaLabItaly; + private final CdaMappingEngine engine; + private final String cdaLabItaly; private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(CdaToFhirTransformTests.class); - @BeforeAll - static void setUpBeforeClass() throws Exception { + public CdaToFhirTransformTests() throws Exception { InputStream in = getResourceAsStream("cda-it.xml"); cdaLabItaly = IOUtils.toString(in, StandardCharsets.UTF_8); + engine = this.getEngine(); } - + @AfterAll - static void teardownClass() throws Exception { - engine = null; + void teardownClass() { CompareUtil.logMemory(); } - - private CdaMappingEngine getEngine() { - if (engine == null) { - try { - engine = new CdaMappingEngine.CdaMappingEngineBuilder().getCdaEngineR4(); - StructureMap sm = engine.parseMap(getFileAsStringFromResources("datatypes.map")); - assertTrue(sm != null); - engine.addCanonicalResource(sm); - sm = engine.parseMap(getFileAsStringFromResources("FullHeader.map")); - assertTrue(sm != null); - engine.addCanonicalResource(sm); - sm = engine.parseMap(getFileAsStringFromResources("LabBody.map")); - assertTrue(sm != null); - engine.addCanonicalResource(sm); - sm = getEngine().parseMap(getFileAsStringFromResources("cda-it-observation.map")); - assertTrue(sm != null); - engine.addCanonicalResource(sm); - sm = getEngine().parseMap(getFileAsStringFromResources("cda-it-observation-st-r2b.map")); - assertTrue(sm != null); - engine.addCanonicalResource(sm); - sm = getEngine().parseMap(getFileAsStringFromResources("cda-it-observation-condition.map")); - assertTrue(sm != null); - engine.addCanonicalResource(sm); - sm = getEngine().parseMap(getFileAsStringFromResources("fhir-to-cda.map")); - assertTrue(sm != null); - engine.addCanonicalResource(sm); - } catch (FHIRException | IOException | URISyntaxException e) { - e.printStackTrace(); - } - return engine; - } + private CdaMappingEngine getEngine() throws Exception { + final var engine = new CdaMappingEngine.CdaMappingEngineBuilder().getCdaEngineR4(); + StructureMap sm = engine.parseMap(getFileAsStringFromResources("datatypes.map")); + assertTrue(sm != null); + engine.addCanonicalResource(sm); + sm = engine.parseMap(getFileAsStringFromResources("FullHeader.map")); + assertTrue(sm != null); + engine.addCanonicalResource(sm); + sm = engine.parseMap(getFileAsStringFromResources("LabBody.map")); + assertTrue(sm != null); + engine.addCanonicalResource(sm); + sm = engine.parseMap(getFileAsStringFromResources("cda-it-observation.map")); + assertTrue(sm != null); + engine.addCanonicalResource(sm); + sm = engine.parseMap(getFileAsStringFromResources("cda-it-observation-st-r2b.map")); + assertTrue(sm != null); + engine.addCanonicalResource(sm); + sm = engine.parseMap(getFileAsStringFromResources("cda-it-observation-condition.map")); + assertTrue(sm != null); + engine.addCanonicalResource(sm); + sm = engine.parseMap(getFileAsStringFromResources("fhir-to-cda.map")); + assertTrue(sm != null); + engine.addCanonicalResource(sm); return engine; } - @BeforeEach - void setUp() throws Exception { - } - @Test void TestFhirPath() throws FHIRException, IOException { - - String str = getEngine().convert(cdaLabItaly, false); + + String str = this.engine.convert(cdaLabItaly, false); log.debug(str); - assertEquals("11502-2", getEngine().evaluateFhirPath(cdaLabItaly, false, "code.code")); + assertEquals("11502-2", this.engine.evaluateFhirPath(cdaLabItaly, false, "code.code")); String attributeWithCdaWhiteSpace = cdaLabItaly.replaceAll("11502-2", " 11502-2"); assertTrue(attributeWithCdaWhiteSpace.indexOf(" 11502-2") > 0); assertEquals("11502-2", - getEngine().evaluateFhirPath(attributeWithCdaWhiteSpace, false, "code.code")); + this.engine.evaluateFhirPath(attributeWithCdaWhiteSpace, false, "code.code")); assertEquals("REFERTO DI LABORATORIO", - getEngine().evaluateFhirPath(cdaLabItaly, false, "title.xmlText")); - assertEquals("IT", getEngine().evaluateFhirPath(cdaLabItaly, false, "realmCode.code")); + this.engine.evaluateFhirPath(cdaLabItaly, false, "title.xmlText")); + assertEquals("IT", this.engine.evaluateFhirPath(cdaLabItaly, false, "realmCode.code")); assertEquals("2.16.840.1.113883.1.3", - getEngine().evaluateFhirPath(cdaLabItaly, false, "typeId.root")); + this.engine.evaluateFhirPath(cdaLabItaly, false, "typeId.root")); // assertEquals("POCD_MT000040UV02", -// getEngine().evaluateFhirPath(cdaLabItaly, false, "typeId.extension")); +// this.engine.evaluateFhirPath(cdaLabItaly, false, "typeId.extension")); assertEquals("POCD_HD000040", - getEngine().evaluateFhirPath(cdaLabItaly, false, "typeId.extension")); + this.engine.evaluateFhirPath(cdaLabItaly, false, "typeId.extension")); // stdc -// assertEquals("active", getEngine().evaluateFhirPath(cdaLabItaly, false, "statusCode.code")); +// assertEquals("active", this.engine.evaluateFhirPath(cdaLabItaly, false, "statusCode.code")); // changed with core 7.3.0 - assertEquals("active", getEngine().evaluateFhirPath(cdaLabItaly, false, "sdtcStatusCode.code")); + assertEquals("active", this.engine.evaluateFhirPath(cdaLabItaly, false, "sdtcStatusCode.code")); // assertEquals("2022-03-30T11:24:26+01:00", - getEngine().evaluateFhirPath(cdaLabItaly, false, "effectiveTime.value")); + this.engine.evaluateFhirPath(cdaLabItaly, false, "effectiveTime.value")); assertEquals("1993-06-19", - getEngine().evaluateFhirPath(cdaLabItaly, + this.engine.evaluateFhirPath(cdaLabItaly, false, "recordTarget.patientRole.patient.birthTime.value")); - - + + // https://hl7.org/cda/stds/core/2.0.0-sd-snapshot1/StructureDefinition-PN.html assertEquals("Verdi", - getEngine().evaluateFhirPath(cdaLabItaly, + this.engine.evaluateFhirPath(cdaLabItaly, false, "recordTarget.patientRole.patient.name.item.family.xmlText")); assertEquals("Giuseppe", - getEngine().evaluateFhirPath(cdaLabItaly, + this.engine.evaluateFhirPath(cdaLabItaly, false, "recordTarget.patientRole.patient.name.item.given.xmlText")); // hl7 austria - assertEquals("2021-06-01", getEngine().evaluateFhirPath(cdaLabItaly, false, "terminologyDate.value")); - assertEquals("code", getEngine().evaluateFhirPath(cdaLabItaly, false, "formatCode.code")); - assertEquals("F028", getEngine().evaluateFhirPath(cdaLabItaly, false, "practiceSettingCode.code")); + assertEquals("2021-06-01", this.engine.evaluateFhirPath(cdaLabItaly, false, "terminologyDate.value")); + assertEquals("code", this.engine.evaluateFhirPath(cdaLabItaly, false, "formatCode.code")); + assertEquals("F028", this.engine.evaluateFhirPath(cdaLabItaly, false, "practiceSettingCode.code")); } @Test void TestInitial() throws FHIRException, IOException { - String result = getEngine().transform(cdaLabItaly, + String result = this.engine.transform(cdaLabItaly, false, "http://salute.gov.it/ig/cda-fhir-maps/StructureMap/RefertodilaboratorioFULLBODY", true); assertNotNull(result); - Bundle resource = (Bundle) getEngine().transformToFhir(cdaLabItaly, false,"http://salute.gov.it/ig/cda-fhir-maps/StructureMap/RefertodilaboratorioFULLBODY"); + Bundle resource = (Bundle) this.engine.transformToFhir(cdaLabItaly, false,"http://salute.gov.it/ig/cda-fhir-maps/StructureMap/RefertodilaboratorioFULLBODY"); assertNotNull(resource); Composition composition = (Composition) resource.getEntryFirstRep().getResource(); assertNotNull(composition); @@ -181,12 +160,12 @@ void TestInitial() throws FHIRException, IOException { void TestObservation() throws FHIRException, IOException { InputStream in = getResourceAsStream("cda-it-observation.xml"); - StructureMap sm = getEngine().parseMap(getFileAsStringFromResources("cda-it-observation.map")); + StructureMap sm = this.engine.parseMap(getFileAsStringFromResources("cda-it-observation.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); String cdaObservation = IOUtils.toString(in, StandardCharsets.UTF_8); - Resource resource = getEngine().transformToFhir(cdaObservation, + Resource resource = this.engine.transformToFhir(cdaObservation, false, "http://salute.gov.it/ig/cda-fhir-maps/StructureMap/TestObservation"); @@ -204,7 +183,7 @@ void TestObservationSt() throws FHIRException, IOException { InputStream in = getResourceAsStream("cda-it-observation-st.xml"); String cdaObservation = IOUtils.toString(in, StandardCharsets.UTF_8); - Resource resource = getEngine().transformToFhir(cdaObservation, + Resource resource = this.engine.transformToFhir(cdaObservation, false, "http://salute.gov.it/ig/cda-fhir-maps/StructureMap/TestObservation"); Observation obs = (Observation) resource; @@ -219,7 +198,7 @@ void TestObservationStR2b() throws FHIRException, IOException { InputStream in = getResourceAsStream("cda-it-observation-st-r2b.xml"); String cdaObservation = IOUtils.toString(in, StandardCharsets.UTF_8); - Resource resource = getEngine().transformToFhir(cdaObservation, + Resource resource = this.engine.transformToFhir(cdaObservation, false, "http://salute.gov.it/ig/cda-fhir-maps/StructureMap/TestObservationStR2b"); Observation obs = (Observation) resource; @@ -234,7 +213,7 @@ void TestObservationCs() throws FHIRException, IOException { InputStream in = getResourceAsStream("cda-it-observation-cs.xml"); String cdaObservation = IOUtils.toString(in, StandardCharsets.UTF_8); - Resource resource = getEngine().transformToFhir(cdaObservation, + Resource resource = this.engine.transformToFhir(cdaObservation, false, "http://salute.gov.it/ig/cda-fhir-maps/StructureMap/TestObservation"); Observation obs = (Observation) resource; @@ -249,7 +228,7 @@ void TestObservationCd() throws FHIRException, IOException { InputStream in = getResourceAsStream("cda-it-observation-cd.xml"); String cdaObservation = IOUtils.toString(in, StandardCharsets.UTF_8); - Resource resource = getEngine().transformToFhir(cdaObservation, + Resource resource = this.engine.transformToFhir(cdaObservation, false, "http://salute.gov.it/ig/cda-fhir-maps/StructureMap/TestObservation"); Observation obs = (Observation) resource; @@ -264,7 +243,7 @@ void TestObservationCondition() throws FHIRException, IOException { InputStream in = getResourceAsStream("cda-it-observation-condition.xml"); String cdaObservation = IOUtils.toString(in, StandardCharsets.UTF_8); - Resource resource = getEngine().transformToFhir(cdaObservation, + Resource resource = this.engine.transformToFhir(cdaObservation, false, "http://salute.gov.it/ig/cda-fhir-maps/StructureMap/TestObservationConditionCoding"); Condition condition = (Condition) resource; @@ -275,7 +254,7 @@ void TestObservationCondition() throws FHIRException, IOException { @Test void TestSecond() throws FHIRException, IOException { - String result = getEngine().transform(cdaLabItaly, + String result = this.engine.transform(cdaLabItaly, false, "http://salute.gov.it/ig/cda-fhir-maps/StructureMap/RefertodilaboratorioFULLBODY", true); @@ -315,16 +294,16 @@ void TestFhirToCda() throws FHIRException, IOException { " " + // " " + // " " + // - + ""; - String result = getEngine().transform(bundleString, + String result = this.engine.transform(bundleString, false, "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda", false); assertEquals("2.16.840.1.113883.1.3", - getEngine().evaluateFhirPath(result, false, "typeId.root")); + this.engine.evaluateFhirPath(result, false, "typeId.root")); // assertEquals("POCD_MT000040UV02", -// getEngine().evaluateFhirPath(result, false, "typeId.extension")); +// this.engine.evaluateFhirPath(result, false, "typeId.extension")); assertNotNull(result); assertTrue(result.indexOf("20120204140500+0100")>0); assertTrue(result.indexOf("6B6ED376-A7DA-44CB-92D1-E75CE1AE73B0")>0); @@ -332,12 +311,12 @@ void TestFhirToCda() throws FHIRException, IOException { assertTrue(result.indexOf("caption")>0); assertTrue(result.indexOf("Kommentar")>0); assertEquals("2012-02-04T14:05:00+01:00", - getEngine().evaluateFhirPath(result, false, "effectiveTime.value")); + this.engine.evaluateFhirPath(result, false, "effectiveTime.value")); } @Test void TestThird() throws FHIRException, IOException { - String result = getEngine().transform(cdaLabItaly, + String result = this.engine.transform(cdaLabItaly, false, "http://salute.gov.it/ig/cda-fhir-maps/StructureMap/RefertodilaboratorioFULLBODY", true); @@ -345,15 +324,14 @@ void TestThird() throws FHIRException, IOException { } @Test - void TestValidateCdaIt() throws FHIRException, IOException, EOperationOutcome, URISyntaxException { - ch.ahdis.matchbox.engine.CdaMappingEngine engine = new CdaMappingEngine.CdaMappingEngineBuilder().getCdaEngineR4(); - String fhirBundle = getEngine().transform(cdaLabItaly, + void TestValidateCdaIt() throws FHIRException, IOException { + String fhirBundle = this.engine.transform(cdaLabItaly, false, "http://salute.gov.it/ig/cda-fhir-maps/StructureMap/RefertodilaboratorioFULLBODY", false); assertNotNull(fhirBundle); log.debug(fhirBundle); - String cda = getEngine().transform(fhirBundle, + String cda = this.engine.transform(fhirBundle, false, "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda", false); @@ -364,76 +342,6 @@ void TestValidateCdaIt() throws FHIRException, IOException, EOperationOutcome, U CompareUtil.logMemory(); } - private int errors(OperationOutcome op) { - int i = 0; - for (OperationOutcomeIssueComponent vm : op.getIssue()) { - if (vm.getSeverity() == IssueSeverity.ERROR || vm.getSeverity() == IssueSeverity.FATAL) { - // eg ('tel: 390 666 0581') - if (vm.getDetails().getText().startsWith("URI values cannot have whitespace")) { - continue; - } - // https://terminology.hl7.org/5.0.0/ValueSet-v3-RoleClassAssignedEntity.json.html - // has a filter with an is-a concept to ASSIGEND and this cannot be evaluated by - // org.hl7.fhir.r5.terminologies.ValueSetCheckerSimple - if (vm.getDetails().getText().startsWith( - "The System URI could not be determined for the code 'it-IT'")) { - continue; - } - if (vm.getDetails().getText().startsWith( - "The value provided ('it-IT') was not found in the value set 'All Languages'")) { - continue; - } - if (vm.getDetails().getText().startsWith( - "The value provided ('ASSIGNED') was not found in the value set 'RoleClassAssignedEntity'")) { - continue; - } - - if (vm.getDetails().getText().startsWith( - "IntendedRecipient.classCode: minimum required = 1,")) { - continue; - } - - if (vm.getDetails().getText().startsWith( - "ServiceEvent.classCode: minimum required = 1, ")) { - continue; - } - - if (vm.getDetails().getText().startsWith( - "HealthCareFacility.classCode: minimum required = 1, ")) { - continue; - } - - if (vm.getDetails().getText().startsWith( - "PlayingEntity.classCode: minimum required = 1, ")) { - continue; - } - if (vm.getDetails().getText().startsWith( - "ObservationRange.classCode: minimum required = 1, ")) { - continue; - } - if (vm.getDetails().getText().startsWith( - "LabCriterion.classCode: minimum required = 1, ")) { - continue; - } - if (vm.getDetails().getText().startsWith( - "LabCriterion.moodCode: minimum required = 1, ")) { - continue; - } - - // id value 'ESAMI_URINE' is not valid - // id value 'ALBUMINA_URINE' is not valid - if (vm.getDetails().getText().startsWith( - "id value ")) { - continue; - } - - log.error(vm.getDetails().getText()); - ++i; - } - } - return i; - } - private static InputStream getResourceAsStream(final String filename) { return CdaToFhirTransformTests.class.getResourceAsStream("/cda/" + filename); } diff --git a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java index acadfe7ebb..0aaf21e332 100644 --- a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java +++ b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java @@ -43,34 +43,27 @@ import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.model.Composition; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import ch.ahdis.matchbox.engine.MatchboxEngine; import ch.ahdis.matchbox.engine.MatchboxEngine.MatchboxEngineBuilder; +import org.junit.jupiter.api.TestInstance; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) class FhirMappingLanguageTests { + private final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(FhirMappingLanguageTests.class); - static private MatchboxEngine engine; + private final MatchboxEngine engine; - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(FhirMappingLanguageTests.class); - - @BeforeAll - static void setUpBeforeClass() throws Exception { + public FhirMappingLanguageTests() { engine = new MatchboxEngineBuilder().getEngineR4(); } @AfterAll - static void teardownClass() throws Exception { - engine = null; + static void teardownClass() { CompareUtil.logMemory(); } - @BeforeEach - void setUp() throws Exception { - } - public String getFileAsStringFromResources(String file) throws IOException { InputStream in = FhirMappingLanguageTests.class.getResourceAsStream("/mapping-language" + file); return IOUtils.toString(in, StandardCharsets.UTF_8); @@ -82,7 +75,6 @@ public InputStream getFileAsInputStream(String file) throws IOException { @Test void testQr2Patient() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/qr2patgender.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -96,7 +88,6 @@ void testQr2Patient() throws FHIRException, IOException { @Test void testMemberOf() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/memberof.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -110,7 +101,6 @@ void testMemberOf() throws FHIRException, IOException { @Test void testNarrative() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/narrative.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -124,7 +114,6 @@ void testNarrative() throws FHIRException, IOException { @Test void testConformsTo() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/conformsto.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -138,7 +127,6 @@ void testConformsTo() throws FHIRException, IOException { @Test void testMatchboxEngine() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/conformstoneg.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -159,7 +147,6 @@ void testMatchboxEngine() throws FHIRException, IOException { @Test void testConformsToNeg() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/conformstoneg.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -173,7 +160,6 @@ void testConformsToNeg() throws FHIRException, IOException { @Test void testQty() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/quantity.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -195,7 +181,6 @@ void testQty() throws FHIRException, IOException { @Test void testStringToCoding() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/stringtocoding.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -210,7 +195,6 @@ void testStringToCoding() throws FHIRException, IOException { @Test void testStringToCodingWithCC() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/stringtocodingwithcc.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -226,7 +210,6 @@ void testStringToCodingWithCC() throws FHIRException, IOException { @Test void testTranslateCoding() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/translatecoding.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -247,7 +230,6 @@ void testTranslateCoding() throws FHIRException, IOException { @Test void testCast() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/cast.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -259,7 +241,6 @@ void testCast() throws FHIRException, IOException { @Test void testBundleTimestamp() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/bundlets.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -273,7 +254,6 @@ void testBundleTimestamp() throws FHIRException, IOException { @Test void testWhereClause() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/whereclause.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -286,7 +266,6 @@ void testWhereClause() throws FHIRException, IOException { @Test void testDateManipulation() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/qr2patfordates.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -307,7 +286,6 @@ private org.hl7.fhir.r5.model.CanonicalResource getCanonicalResourceFromJson(Str @Test void testTutorialStep1Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step1/map/step1.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -324,7 +302,6 @@ void testTutorialStep1Xml() throws FHIRException, IOException { @Test void testTutorialStep1Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step1/map/step1.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -346,7 +323,6 @@ void testTutorialStep1bJson() throws FHIRException, IOException { // from rule 'rule_a_short' // 1b org.hl7.fhir.exceptions.FHIRException: No matches found for rule for // 'string to string' from http://hl7.org/fhir/StructureMap/tutorial-step1b, - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step1/map/step1b.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -365,7 +341,6 @@ void testTutorialStep1bJson() throws FHIRException, IOException { @Test void testTutorialStep2Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step2/map/step2.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -382,7 +357,6 @@ void testTutorialStep2Xml() throws FHIRException, IOException { @Test void testTutorialStep2Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step2/map/step2.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -401,7 +375,6 @@ void testTutorialStep2Json() throws FHIRException, IOException { @Test void testTutorialStep3aXml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step3/map/step3a.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -423,7 +396,6 @@ void testTutorialStep3aXml() throws FHIRException, IOException { @Test void testTutorialStep3aJson() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step3/map/step3a.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -447,7 +419,6 @@ void testTutorialStep3aJson() throws FHIRException, IOException { @Test void testTutorialStep3bXml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step3/map/step3b.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -469,7 +440,6 @@ void testTutorialStep3bXml() throws FHIRException, IOException { @Test void testTutorialStep3bJson() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step3/map/step3b.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -494,7 +464,6 @@ void testTutorialStep3bJson() throws FHIRException, IOException { @Test void testTutorialStep3cXml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step3/map/step3c.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -521,7 +490,6 @@ void testTutorialStep3cXml() throws FHIRException, IOException { @Test void testTutorialStep3cJson() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step3/map/step3c.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -550,7 +518,6 @@ void testTutorialStep3cJson() throws FHIRException, IOException { @Test void testTutorialStep4aXml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step4/map/step4a.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -574,7 +541,6 @@ void testTutorialStep4aXml() throws FHIRException, IOException { @Test void testTutorialStep4aJson() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step4/map/step4a.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -601,7 +567,6 @@ void testTutorialStep4aJson() throws FHIRException, IOException { @Test void testTutorialStep4b2Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step4/map/step4b2.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -623,7 +588,6 @@ void testTutorialStep4b2Xml() throws FHIRException, IOException { @Test void testTutorialStep4b2Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step4/map/step4b2.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -647,7 +611,6 @@ void testTutorialStep4b2Json() throws FHIRException, IOException { @Test void testTutorialStep4b3Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step4/map/step4b3.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -669,7 +632,6 @@ void testTutorialStep4b3Xml() throws FHIRException, IOException { @Test void testTutorialStep4b3Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step4/map/step4b3.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -693,7 +655,6 @@ void testTutorialStep4b3Json() throws FHIRException, IOException { @Test void testTutorialStep4cXml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step4/map/step4c.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -715,7 +676,6 @@ void testTutorialStep4cXml() throws FHIRException, IOException { @Test void testTutorialStep4cJson() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step4/map/step4c.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -739,7 +699,6 @@ void testTutorialStep4cJson() throws FHIRException, IOException { @Test void testTutorialStep5Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step5/map/step5.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -761,7 +720,6 @@ void testTutorialStep5Xml() throws FHIRException, IOException { @Test void testTutorialStep5Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step5/map/step5.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -785,7 +743,6 @@ void testTutorialStep5Json() throws FHIRException, IOException { @Test void testTutorialStep6aXml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step6/map/step6a.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -807,7 +764,6 @@ void testTutorialStep6aXml() throws FHIRException, IOException { @Test void testTutorialStep6aJson() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step6/map/step6a.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -831,7 +787,6 @@ void testTutorialStep6aJson() throws FHIRException, IOException { @Test void testTutorialStep6bXml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step6/map/step6b.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -851,12 +806,11 @@ void testTutorialStep6bXml() throws FHIRException, IOException { assertTrue(false, "API-0389: Failed to call access method: org.hl7.fhir.exceptions.FHIRException: Rule "rule_a23b": Check condition failed: the collection has more than one item"); } catch (FHIRException e) { - } + } } @Test void testTutorialStep6bJson() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step6/map/step6b.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -878,12 +832,11 @@ void testTutorialStep6bJson() throws FHIRException, IOException { assertTrue(false, "API-0389: Failed to call access method: org.hl7.fhir.exceptions.FHIRException: Rule "rule_a23b": Check condition failed: the collection has more than one item"); } catch (FHIRException e) { - } + } } @Test void testTutorialStep6cXml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step6/map/step6c.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -905,7 +858,6 @@ void testTutorialStep6cXml() throws FHIRException, IOException { @Test void testTutorialStep6cJson() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step6/map/step6c.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -929,7 +881,6 @@ void testTutorialStep6cJson() throws FHIRException, IOException { @Test void testTutorialStep6dXml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step6/map/step6d.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -951,7 +902,6 @@ void testTutorialStep6dXml() throws FHIRException, IOException { @Test void testTutorialStep6dJson() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step6/map/step6d.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -975,7 +925,6 @@ void testTutorialStep6dJson() throws FHIRException, IOException { @Test void testTutorialStep7Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step7/map/step7.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1002,7 +951,6 @@ void testTutorialStep7Xml() throws FHIRException, IOException { @Test void testTutorialStep7Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step7/map/step7.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1029,7 +977,6 @@ void testTutorialStep7Json() throws FHIRException, IOException { @Test void testTutorialStep8Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step8/map/step8.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1046,7 +993,6 @@ void testTutorialStep8Xml() throws FHIRException, IOException { @Test void testTutorialStep8Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step8/map/step8.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1065,7 +1011,6 @@ void testTutorialStep8Json() throws FHIRException, IOException { @Test void testTutorialStep9Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step9/map/step9.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1087,7 +1032,6 @@ void testTutorialStep9Xml() throws FHIRException, IOException { @Test void testTutorialStep9Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step9/map/step9.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1111,7 +1055,6 @@ void testTutorialStep9Json() throws FHIRException, IOException { @Test void testTutorialStep10Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step10/map/step10.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1132,7 +1075,6 @@ void testTutorialStep10Xml() throws FHIRException, IOException { @Test void testTutorialStep10Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step10/map/step10.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1157,7 +1099,6 @@ void testTutorialStep10Json() throws FHIRException, IOException { @Test void testTutorialStep11Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step11/map/step11.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1174,7 +1115,6 @@ void testTutorialStep11Xml() throws FHIRException, IOException { @Test void testTutorialStep11Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step11/map/step11.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1193,7 +1133,6 @@ void testTutorialStep11Json() throws FHIRException, IOException { @Test void testTutorialStep12Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step12/map/step12.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1210,7 +1149,6 @@ void testTutorialStep12Xml() throws FHIRException, IOException { @Test void testTutorialStep12Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step12/map/step12.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1229,7 +1167,6 @@ void testTutorialStep12Json() throws FHIRException, IOException { @Test void testTutorialStep13Xml() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step13/map/step13.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1246,7 +1183,6 @@ void testTutorialStep13Xml() throws FHIRException, IOException { @Test void testTutorialStep13Json() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/tutorial/step13/map/step13.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1275,22 +1211,22 @@ void testBundleJson() throws FHIRException, IOException { if (i>0) { bundleBuilder.append(","); } - bundleBuilder.append(" {\n" + - " \"resource\": {\n" + - " \"resourceType\": \"Observation\",\n" + - " \"id\": \""+i+"\"\n" + - " \"component\": [\n" + - " {\n" + - " \"code\": {\n" + - " \"coding\": [\n" + - " {\n" + - " \"system\": \"http://loinc.org\",\n" + - " \"code\": \"8480-6\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"valueQuantity\": {\n" + - " \"value\": " +i +"\n" + + bundleBuilder.append(" {\n" + + " \"resource\": {\n" + + " \"resourceType\": \"Observation\",\n" + + " \"id\": \""+i+"\"\n" + + " \"component\": [\n" + + " {\n" + + " \"code\": {\n" + + " \"coding\": [\n" + + " {\n" + + " \"system\": \"http://loinc.org\",\n" + + " \"code\": \"8480-6\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"valueQuantity\": {\n" + + " \"value\": " +i +"\n" + " }\n" + // " },\n" + // " {\n" + // @@ -1311,7 +1247,7 @@ void testBundleJson() throws FHIRException, IOException { " }"); } bundleBuilder.append("]\n}"); - String bundle = bundleBuilder.toString(); + String bundle = bundleBuilder.toString(); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/bundleobs.map")); assertTrue(sm != null); @@ -1323,10 +1259,9 @@ void testBundleJson() throws FHIRException, IOException { CompareUtil.logMemory(); } - + @Test void testBundleResolveJson() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); StructureMap sm = engine.parseMap(getFileAsStringFromResources("/bundle-resolve.map")); assertTrue(sm != null); engine.addCanonicalResource(sm); @@ -1340,7 +1275,6 @@ void testBundleResolveJson() throws FHIRException, IOException { @Test void testParseFailWithError() throws FHIRException, IOException { - MatchboxEngine engine = new MatchboxEngine(FhirMappingLanguageTests.engine); try { StructureMap sm = engine.parseMap(getFileAsStringFromResources("/map-with-error.map")); assertTrue(sm == null); diff --git a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirXVersTests.java b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirXVersTests.java index afa2ad1748..3ddcdcd3b8 100644 --- a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirXVersTests.java +++ b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirXVersTests.java @@ -29,15 +29,13 @@ import org.apache.commons.io.IOUtils; import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.r4.model.StructureDefinition; import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import ch.ahdis.matchbox.engine.MatchboxEngine; import ch.ahdis.matchbox.engine.MatchboxEngine.MatchboxEngineBuilder; +import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; /** @@ -45,15 +43,14 @@ * Uses more then 4GB on the ci-build */ @DisabledIfEnvironmentVariable(named = "GITHUB_ACTIONS", matches = "true") +@TestInstance(TestInstance.Lifecycle.PER_CLASS) class FhirXVersTests { + private final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(FhirXVersTests.class); -// static private MatchboxEngine engineR4B; - static private MatchboxEngine engineR4, engineR5; + private final MatchboxEngine engineR4, engineR5; - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(FhirMappingLanguageTests.class); - @BeforeAll - static void setUpBeforeClass() throws Exception { + public FhirXVersTests() throws Exception { log.info("Setup"); CompareUtil.logMemory(); engineR4 = new MatchboxEngineBuilder().withXVersion(true).getEngineR4(); @@ -75,34 +72,20 @@ static void setUpBeforeClass() throws Exception { @AfterAll static void teardownClass() throws Exception { - engineR4 = null; - engineR5 = null; -// engineR4B = null; - log.info("Teardown"); CompareUtil.logMemory(); } - @BeforeEach - void setUp() throws Exception { - } - public String getFileAsStringFromResources(String file) throws IOException { InputStream in = FhirXVersTests.class.getResourceAsStream("/xvers" + file); return IOUtils.toString(in, StandardCharsets.UTF_8); } - public StructureDefinition getStructureDefinitionFromFile(String file) throws IOException { - return (StructureDefinition) new org.hl7.fhir.r4.formats.XmlParser() - .parse(FhirMappingLanguageTests.class.getResourceAsStream(file)); - } - @Test void testMedication5to4inR4() throws FHIRException, IOException { log.info("testMedication5to4inR4"); - MatchboxEngine engine = FhirXVersTests.engineR4; - assertEquals("4.0.1", engine.getVersion()); - assertEquals("4.0.1", engine.getContext().getVersion()); - SimpleWorkerContext context = engine.getContext(); + assertEquals("4.0.1", engineR4.getVersion()); + assertEquals("4.0.1", engineR4.getContext().getVersion()); + SimpleWorkerContext context = engineR4.getContext(); assertNotNull(context.fetchResource(org.hl7.fhir.r5.model.Resource.class, "http://hl7.org/fhir/StructureDefinition/Patient")); assertNotNull(context.fetchResource(org.hl7.fhir.r5.model.Resource.class, @@ -110,7 +93,7 @@ void testMedication5to4inR4() throws FHIRException, IOException { assertNotNull(context.fetchResource(org.hl7.fhir.r5.model.Resource.class, "http://hl7.org/fhir/uv/xver/StructureMap/Medication4to5")); - String result = engine.transform(getFileAsStringFromResources("/medication-r5-med0301.json"), true, + String result = engineR4.transform(getFileAsStringFromResources("/medication-r5-med0301.json"), true, "http://hl7.org/fhir/uv/xver/StructureMap/Medication5to4", true); log.info(result); CompareUtil.compare(getFileAsStringFromResources("/medication-r4-med0301.json"), result, false); @@ -145,16 +128,15 @@ void testMedication5to4inR4() throws FHIRException, IOException { @Test void testMedication5to4inR5() throws FHIRException, IOException { log.info("testMedication5to4inR5"); - MatchboxEngine engine = FhirXVersTests.engineR5; - SimpleWorkerContext context = engine.getContext(); + SimpleWorkerContext context = engineR5.getContext(); log.info("finished TestEngineR5"); - assertEquals("5.0.0", engine.getVersion()); - assertEquals("5.0.0", engine.getContext().getVersion()); + assertEquals("5.0.0", engineR5.getVersion()); + assertEquals("5.0.0", engineR5.getContext().getVersion()); assertNotNull(context.fetchResource(org.hl7.fhir.r5.model.Resource.class, "http://hl7.org/fhir/StructureDefinition/Patient")); assertNotNull(context.fetchResource(org.hl7.fhir.r5.model.Resource.class, "http://hl7.org/fhir/uv/xver/StructureMap/Medication5to4")); - String result = engine.transform(getFileAsStringFromResources("/medication-r5-med0301.json"), true, + String result = engineR5.transform(getFileAsStringFromResources("/medication-r5-med0301.json"), true, "http://hl7.org/fhir/uv/xver/StructureMap/Medication5to4", true); log.info(result); CompareUtil.compare(getFileAsStringFromResources("/medication-r4-med0301.json"), result, false); @@ -175,8 +157,7 @@ void testMedication5to4inR5() throws FHIRException, IOException { @Test void testMedication4to5inR4() throws FHIRException, IOException { log.info("testMedication4to5inR4"); - MatchboxEngine engine = FhirXVersTests.engineR4; - String result = engine.transform(getFileAsStringFromResources("/medication-r4-med0301.json"), true, + String result = engineR4.transform(getFileAsStringFromResources("/medication-r4-med0301.json"), true, "http://hl7.org/fhir/uv/xver/StructureMap/Medication4to5", true); log.info(result); CompareUtil.compare(getFileAsStringFromResources("/medication-r5-med0301.json"), result, false); @@ -206,8 +187,7 @@ void testMedication4to5inR4() throws FHIRException, IOException { @Test void testMedication4to5inR5() throws FHIRException, IOException { log.info("testMedication4to5inR5"); - MatchboxEngine engine = FhirXVersTests.engineR5; - String result = engine.transform(getFileAsStringFromResources("/medication-r4-med0301.json"), true, + String result = engineR5.transform(getFileAsStringFromResources("/medication-r4-med0301.json"), true, "http://hl7.org/fhir/uv/xver/StructureMap/Medication4to5", true); log.info(result); CompareUtil.compare(getFileAsStringFromResources("/medication-r5-med0301.json"), result, false); diff --git a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/R4ValidationTests.java b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/R4ValidationTests.java index ee69048800..acb85db5da 100644 --- a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/R4ValidationTests.java +++ b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/R4ValidationTests.java @@ -29,7 +29,7 @@ **/ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class R4ValidationTests { - private static final Logger log = LoggerFactory.getLogger(R4ValidationTests.class); + private final Logger log = LoggerFactory.getLogger(R4ValidationTests.class); private final MatchboxEngine engine; private final String careplanRaw; private final String measureRaw; diff --git a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/R5ValidationTests.java b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/R5ValidationTests.java index 3675dd630c..420de60d3e 100644 --- a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/R5ValidationTests.java +++ b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/R5ValidationTests.java @@ -12,7 +12,6 @@ import java.io.ByteArrayInputStream; import java.io.IOException; -import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.stream.Collectors; @@ -26,12 +25,12 @@ **/ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class R5ValidationTests { - private static final Logger log = LoggerFactory.getLogger(R5ValidationTests.class); + private final Logger log = LoggerFactory.getLogger(R5ValidationTests.class); private final MatchboxEngine engine; private final String careplanRaw; private final String measureRaw; - public R5ValidationTests() throws IOException, URISyntaxException { + public R5ValidationTests() throws IOException { this.engine = this.getEngine(); //this.engine.setTerminologyServer("http://tx.fhir.org", null, FhirPublication.R4); this.careplanRaw = this.loadSample("careplan.xml"); @@ -72,7 +71,7 @@ void testValueSetWithAllFromCodeSystem() throws Exception { assertEquals(2, errors.size()); assertTrue(errors.get(0).getDetails().getText().startsWith("The value provided ('non-existent-code') was not found in the value set 'PublicationStatus'") || errors.get(1).getDetails().getText().startsWith("The value provided ('non-existent-code') was not found in the value set 'PublicationStatus'")); } - + /** * Test the validation of a code from a value set that expands urn:ietf:bcp:13. * diff --git a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/SuppressedWarnInfoTests.java b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/SuppressedWarnInfoTests.java index 7dc5b2f4b3..51c079742d 100644 --- a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/SuppressedWarnInfoTests.java +++ b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/SuppressedWarnInfoTests.java @@ -22,8 +22,8 @@ class SuppressedWarnInfoTests { private final MatchboxEngine engine; private final byte[] resource; - private final static String WARN1 = "A measure should contain at least one group"; - private final static String WARN_DOM6 = "Constraint failed: dom-6: 'A resource should have narrative for robust " + + private static final String WARN1 = "A measure should contain at least one group"; + private static final String WARN_DOM6 = "Constraint failed: dom-6: 'A resource should have narrative for robust " + "management' (defined in http://hl7.org/fhir/StructureDefinition/DomainResource) (Best Practice Recommendation)"; public SuppressedWarnInfoTests() throws IOException { @@ -98,7 +98,6 @@ private MatchboxEngine getEngine() { return new MatchboxEngine.MatchboxEngineBuilder().getEngineR4(); } - private String loadSample(final String filename) throws IOException { return new String( R4ValidationTests.class.getResourceAsStream("/r4-samples/" + filename).readAllBytes() diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java index 2efda7a819..091c05fbb6 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/gazelle/GazelleApiR4Test.java @@ -29,7 +29,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @Tag(TestTags.GAZELLE) -class GazelleApiR4Test extends AbstractGazelleTest { +public class GazelleApiR4Test extends AbstractGazelleTest { private final GazelleClient client = new GazelleClient("http://localhost:8081/matchboxv3/gazelle/"); diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java index 7320c456b9..71e2342a0c 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/mapping/TransformTest.java @@ -39,7 +39,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @Tag(TestTags.MAPPING) -class TransformTest { +public class TransformTest { private static final String TARGET_SERVER = "http://localhost:8086/matchboxv3"; private static final FhirContext FHIR_CONTEXT = FhirContext.forR4Cached(); diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java index 9f8135dc93..50cd2d1331 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4BTest.java @@ -39,7 +39,7 @@ @ActiveProfiles({"test-r4b", "disable-metrics"}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -class MatchboxApiR4BTest { +public class MatchboxApiR4BTest { static int getValidationFailures(OperationOutcome outcome) { int fails = 0; diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java index 3a927e977b..e170902434 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR4Test.java @@ -41,7 +41,7 @@ @ActiveProfiles({"test-r4", "disable-metrics"}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -class MatchboxApiR4Test { +public class MatchboxApiR4Test { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(MatchboxApiR4Test.class); private static final String TARGET_SERVER = "http://localhost:8081/matchboxv3"; private static final FhirContext FHIR_CONTEXT = FhirContext.forR4Cached(); diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java index e23a396200..1c5e99884a 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5Test.java @@ -39,7 +39,7 @@ @ActiveProfiles({"test-r5", "disable-metrics"}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -class MatchboxApiR5Test { +public class MatchboxApiR5Test { static int getValidationFailures(OperationOutcome outcome) { int fails = 0; diff --git a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java index ebc83f4a29..4cf4f5747d 100644 --- a/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java +++ b/matchbox-server/src/test/java/ch/ahdis/matchbox/test/MatchboxApiR5onR4Test.java @@ -35,7 +35,7 @@ @ActiveProfiles({"test-r5onr4", "disable-metrics"}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -class MatchboxApiR5onR4Test { +public class MatchboxApiR5onR4Test { static int getValidationFailures(OperationOutcome outcome) { int fails = 0; From b2d0c26ceabe4a8f92bd5b0c2ef2d635956f56fc Mon Sep 17 00:00:00 2001 From: Quentin Ligier Date: Tue, 24 Mar 2026 14:09:13 +0100 Subject: [PATCH 05/10] Back to Java 21 --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index d1a890abca..b01f31deb1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -19,7 +19,7 @@ jobs: uses: actions/setup-java@v5 # https://github.com/actions/setup-java#usage with: - java-version: 25 + java-version: 21 distribution: adopt cache: maven From 7307c5c8d60be9d5539aec93c87382290aa47c83 Mon Sep 17 00:00:00 2001 From: Quentin Ligier Date: Tue, 24 Mar 2026 14:24:28 +0100 Subject: [PATCH 06/10] Clear context cache between FhirMappingLanguageTests tests --- .../matchbox/engine/tests/FhirMappingLanguageTests.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java index 0aaf21e332..7f37596201 100644 --- a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java +++ b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java @@ -43,6 +43,7 @@ import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.model.Composition; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import ch.ahdis.matchbox.engine.MatchboxEngine; @@ -64,6 +65,12 @@ static void teardownClass() { CompareUtil.logMemory(); } + @BeforeEach + void clean() { + this.engine.getContext().dropResource("StructureDefinition", "TLeft"); + this.engine.getContext().dropResource("StructureDefinition", "TRight"); + } + public String getFileAsStringFromResources(String file) throws IOException { InputStream in = FhirMappingLanguageTests.class.getResourceAsStream("/mapping-language" + file); return IOUtils.toString(in, StandardCharsets.UTF_8); From c0e110045d4980acb306b23b0e9c8521471502a0 Mon Sep 17 00:00:00 2001 From: Quentin Ligier Date: Tue, 24 Mar 2026 14:41:10 +0100 Subject: [PATCH 07/10] Split test differently --- .github/workflows/maven.yml | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index b01f31deb1..93fb2abe41 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -27,18 +27,31 @@ jobs: timeout-minutes: 15 run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-engine test - - name: Run the core tests in Maven + - name: Run the GazelleApiR4Test tests in Maven timeout-minutes: 15 - run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='core' test + run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-server -Dtest=GazelleApiR4Test test - - name: Run the validation tests in Maven + + - name: Run the TransformTest tests in Maven timeout-minutes: 15 - run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='validation' test + run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-server -Dtest=TransformTest test + + + - name: Run the MatchboxApiR4Test tests in Maven + timeout-minutes: 15 + run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-server -Dtest=MatchboxApiR4Test test + - - name: Run the Gazelle API tests in Maven + - name: Run the MatchboxApiR4BTest tests in Maven timeout-minutes: 15 - run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='gazelle' test + run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-server -Dtest=MatchboxApiR4BTest test + + + - name: Run the MatchboxApiR5Test tests in Maven + timeout-minutes: 15 + run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-server -Dtest=MatchboxApiR5Test test + - - name: Run the mapping tests in Maven + - name: Run the MatchboxApiR5onR4Test tests in Maven timeout-minutes: 15 - run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dgroups='mapping' test + run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-server -Dtest=MatchboxApiR5onR4Test test From 1ce21a1ff06b3c0e67cd884138543a82e28484e9 Mon Sep 17 00:00:00 2001 From: Quentin Ligier Date: Tue, 24 Mar 2026 14:53:00 +0100 Subject: [PATCH 08/10] Try different runner images --- .github/workflows/maven.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 93fb2abe41..6fd84186bb 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -10,7 +10,10 @@ on: jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ ubuntu-latest, ubuntu-slim, macos-latest, windows-latest ] + runs-on: ${{ matrix.os }} steps: - name: Checkout the project uses: actions/checkout@v5 From 3a46f607b98461c806261049effb59215acbd936 Mon Sep 17 00:00:00 2001 From: Quentin Ligier Date: Tue, 24 Mar 2026 15:01:20 +0100 Subject: [PATCH 09/10] Try different runner images --- .github/workflows/maven.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 6fd84186bb..2ed6895948 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -11,6 +11,7 @@ on: jobs: build: strategy: + fail-fast: false matrix: os: [ ubuntu-latest, ubuntu-slim, macos-latest, windows-latest ] runs-on: ${{ matrix.os }} @@ -26,6 +27,10 @@ jobs: distribution: adopt cache: maven + - name: Install maven (ubuntu-slim) + if: matrix.os == 'ubuntu-slim' + run: sudo apt-get update && sudo apt-get install -y maven + - name: Run the engine tests in Maven timeout-minutes: 15 run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-engine test From 1c76eb2040932197ab5e3886b6a0def0e063d91a Mon Sep 17 00:00:00 2001 From: Quentin Ligier Date: Tue, 24 Mar 2026 17:05:12 +0100 Subject: [PATCH 10/10] Test disabling scheduler --- .github/workflows/maven.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 2ed6895948..496122abd6 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -10,11 +10,7 @@ on: jobs: build: - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest, ubuntu-slim, macos-latest, windows-latest ] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - name: Checkout the project uses: actions/checkout@v5 @@ -47,7 +43,7 @@ jobs: - name: Run the MatchboxApiR4Test tests in Maven timeout-minutes: 15 - run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-server -Dtest=MatchboxApiR4Test test + run: mvn --batch-mode --no-transfer-progress --update-snapshots -pl matchbox-server -Dscheduling_disabled=true -Dtest=MatchboxApiR4Test test - name: Run the MatchboxApiR4BTest tests in Maven