From 962aee14a37464070a0b6ef66641f28838313571 Mon Sep 17 00:00:00 2001 From: Max Bureck Date: Tue, 7 May 2024 21:53:52 +0200 Subject: [PATCH] Added test case for CodeSystem.supplements with versioned canonical --- .../validation/ResourceValidationTests.java | 31 +++++++++++++++++-- pom.xml | 2 +- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/ResourceValidationTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/ResourceValidationTests.java index 3cf91da2e..2db355613 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/ResourceValidationTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/ResourceValidationTests.java @@ -1,5 +1,9 @@ package org.hl7.fhir.validation; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.MatcherAssert.assertThat; + import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; @@ -25,7 +29,7 @@ public class ResourceValidationTests { private static InstanceValidator val; - private void runTest(String filename) throws IOException, FileNotFoundException, Exception { + private List runTest(String filename) throws IOException, FileNotFoundException, Exception { TestingUtilities.injectCorePackageLoader(); if (val == null) { ctxt = TestingUtilities.getSharedWorkerContext(); @@ -37,6 +41,7 @@ public class ResourceValidationTests { Resource res = (Resource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", filename)); val.validate(val, errors, res); Assertions.assertNotNull(errors); + return errors; } @@ -123,4 +128,26 @@ public class ResourceValidationTests { } -} + @Test + public void testCodesystemSupplementsVersion() throws Exception { + List errors = runTest("codesystem-example-supplement-version.xml"); + assertNoErrors(errors); + } + + + private void assertNoErrors(List errors) { + List errorMessages = new ArrayList<>(); + for(ValidationMessage message : errors) { + // we will skip the message that WG citation is needed + if("VALIDATION_HL7_WG_NEEDED".equals(message.getMessageId())) { + continue; + } + if(message.getLevel().isError()) { + errorMessages.add(message.getMessage()); + } + } + assertThat("No error message expected in validation outcome.", errorMessages, is(empty())); + } + + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index f414bd97e..4c169bd7f 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 1.26.0 32.0.1-jre 6.4.1 - 1.5.6 + 1.5.7-SNAPSHOT 2.17.0 5.9.2 1.8.2