From 4aa8e086817b861da4bc80e9af28b4db9c8d6fe9 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 10 Aug 2020 21:24:04 +1000 Subject: [PATCH 1/2] Add test case for Json resource parsing --- .../fhir/dstu3/test/JsonParserTestCase.java | 20 +++++++++++++++++++ .../org/hl7/fhir/dstu3/test/SingleTest.java | 2 +- .../dstu3/test/support/TestingUtilities.java | 3 ++- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/JsonParserTestCase.java diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/JsonParserTestCase.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/JsonParserTestCase.java new file mode 100644 index 000000000..16595c430 --- /dev/null +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/JsonParserTestCase.java @@ -0,0 +1,20 @@ +package org.hl7.fhir.dstu3.test; + +import static org.junit.jupiter.api.Assertions.*; + +import java.io.IOException; + +import org.hl7.fhir.dstu3.formats.JsonParser; +import org.hl7.fhir.dstu3.model.Resource; +import org.hl7.fhir.dstu3.test.support.TestingUtilities; +import org.hl7.fhir.exceptions.FHIRFormatError; +import org.junit.jupiter.api.Test; + +class JsonParserTestCase { + + @Test + void test() throws FHIRFormatError, IOException { + Resource r = new JsonParser().parse(TestingUtilities.loadTestResourceStream("r3", "ActivityDefinition-referralPrimaryCareMentalHealth.json")); + } + +} diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/SingleTest.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/SingleTest.java index 09a402679..3657f2ed2 100644 --- a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/SingleTest.java +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/SingleTest.java @@ -41,7 +41,7 @@ public class SingleTest { public static void main(String[] args) { try { ResourceTest r = new ResourceTest(); - r.setSource(new File("C:\\work\\org.hl7.fhir\\build\\publish\\patient-example.xml")); + r.setSource(new File("C:\\work\\org.hl7.fhir\\fhir-test-cases\\r3\\ActivityDefinition-referralPrimaryCareMentalHealth.json")); r.test(); System.out.println("Completed OK"); } catch (Exception e) { diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/support/TestingUtilities.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/support/TestingUtilities.java index ee11e59b8..73bb242c5 100644 --- a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/support/TestingUtilities.java +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/support/TestingUtilities.java @@ -17,6 +17,7 @@ import org.hl7.fhir.dstu3.context.IWorkerContext; import org.hl7.fhir.utilities.CSFile; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.tests.BaseTestingUtilities; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -29,7 +30,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSyntaxException; -public class TestingUtilities { +public class TestingUtilities extends BaseTestingUtilities { private static final boolean SHOW_DIFF = true; static public IWorkerContext context; From 5fba875d8b7bd2b5db478ee9f7a1a5b8823ff357 Mon Sep 17 00:00:00 2001 From: markiantorno Date: Mon, 10 Aug 2020 21:57:55 -0400 Subject: [PATCH 2/2] Fix for failing ActivityDefinition-referralPrimaryCareMentalHealth.json test --- org.hl7.fhir.dstu3/pom.xml | 6 ++++++ .../java/org/hl7/fhir/dstu3/test/JsonParserTestCase.java | 2 +- .../hl7/fhir/utilities/tests/BaseTestingUtilities.java | 9 +++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 1e6813eee..c8ee0651e 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -116,6 +116,12 @@ ${junit_jupiter_version} test + + org.hl7.fhir.testcases + fhir-test-cases + ${validator_test_case_version} + test + diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/JsonParserTestCase.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/JsonParserTestCase.java index 16595c430..d640303ad 100644 --- a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/JsonParserTestCase.java +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/test/JsonParserTestCase.java @@ -14,7 +14,7 @@ class JsonParserTestCase { @Test void test() throws FHIRFormatError, IOException { - Resource r = new JsonParser().parse(TestingUtilities.loadTestResourceStream("r3", "ActivityDefinition-referralPrimaryCareMentalHealth.json")); + Resource r = new JsonParser().parse(TestingUtilities.loadTestResourceStream("r3", "activitydefinition-referralprimarycarementalhealth.json")); } } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/tests/BaseTestingUtilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/tests/BaseTestingUtilities.java index 3467c71eb..1637c326e 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/tests/BaseTestingUtilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/tests/BaseTestingUtilities.java @@ -4,10 +4,9 @@ import org.apache.commons.io.IOUtils; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; +import java.util.ArrayList; +import java.util.List; public class BaseTestingUtilities { @@ -87,6 +86,4 @@ public class BaseTestingUtilities { } } } - - } \ No newline at end of file