diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxServiceTestHelper.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxServiceTestHelper.java index ae074748f..4fedcb7c6 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxServiceTestHelper.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxServiceTestHelper.java @@ -17,6 +17,7 @@ import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.json.model.JsonObject; import org.hl7.fhir.utilities.validation.ValidationOptions; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.*; @@ -176,8 +177,12 @@ public class TxServiceTestHelper { TxTesterScrubbers.scrubParams(res); String actualResponse = new JsonParser().setOutputStyle(IParser.OutputStyle.PRETTY).composeString(res); + + + String diff = CompareUtilities.checkJsonSrcIsSame(expectedResponse, actualResponse, externals); if (diff != null) { + dumparoo("/Users/david.otasek/IN/2024-02-05-hapi-core-bump-6-2.16/core-test", name, expectedResponse, actualResponse); Utilities.createDirectory(Utilities.getDirectoryForFile(fp)); TextFile.stringToFile(actualResponse, fp); System.out.println("Test "+name+"failed: "+diff); @@ -185,4 +190,15 @@ public class TxServiceTestHelper { return diff; } } + + public static void dumparoo(String rootDirectory, String testName, String expected, String actual) throws IOException { + String fullDirectory = rootDirectory + "/" + testName; + File directory = new File(fullDirectory); + if (!directory.exists()) { + directory.mkdirs(); + } +TextFile.stringToFile(expected, fullDirectory + "/expected.json"); + TextFile.stringToFile(actual, fullDirectory + "/actual.json"); + + } } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxTestData.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxTestData.java index e8652f3db..a012a3138 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxTestData.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxTestData.java @@ -18,13 +18,19 @@ public class TxTestData { @Getter private final List testData; - public TxTestData() throws IOException { + private TxTestData(List testData, JsonObject manifest, JsonObject externals) throws IOException { + this.testData = testData; + this.manifest = manifest; + this.externals = externals; + } + + public static TxTestData loadTestDataFromDefaultClassPath() throws IOException { String contents = TestingUtilities.loadTestResource("tx", "test-cases.json"); String externalSource = TestingUtilities.loadTestResource("tx", "messages-tx.fhir.org.json"); - externals = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(externalSource); + JsonObject externals = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(externalSource); Map examples = new HashMap(); - manifest = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(contents); + JsonObject manifest = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(contents); for (JsonObject suite : manifest.getJsonObjects("suites")) { if (!"tx.fhir.org".equals(suite.asString("mode"))) { String sn = suite.asString("name"); @@ -39,9 +45,11 @@ public class TxTestData { names.addAll(examples.keySet()); Collections.sort(names); - testData = new ArrayList(examples.size()); + List testData = new ArrayList(examples.size()); for (String id : names) { testData.add(new Object[]{id, examples.get(id)}); } + + return new TxTestData(testData, manifest, externals); } } diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/TerminologyServiceTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/TerminologyServiceTests.java index d16544e43..4704f72cb 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/TerminologyServiceTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/TerminologyServiceTests.java @@ -59,7 +59,7 @@ private static TxTestData testData; @Parameters(name = "{index}: id {0}") public static Iterable data() throws IOException { - testData = new TxTestData(); + testData = TxTestData.loadTestDataFromDefaultClassPath(); return testData.getTestData(); }