Break out helper classes
This commit is contained in:
parent
890776604d
commit
4793e574b1
|
@ -24,57 +24,6 @@ import java.util.*;
|
||||||
public class TxServiceTestHelper {
|
public class TxServiceTestHelper {
|
||||||
|
|
||||||
|
|
||||||
public static class TestSetup {
|
|
||||||
public TestSetup(JsonObject suite, JsonObject test) {
|
|
||||||
this.suite = suite;
|
|
||||||
this.test = test;
|
|
||||||
}
|
|
||||||
@Getter
|
|
||||||
private JsonObject suite;
|
|
||||||
@Getter
|
|
||||||
private JsonObject test;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TestData {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final JsonObject manifest;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final JsonObject externals;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final List<Object[]> testData;
|
|
||||||
|
|
||||||
public TestData() 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);
|
|
||||||
|
|
||||||
Map<String, TestSetup> examples = new HashMap<String, TestSetup>();
|
|
||||||
manifest = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(contents);
|
|
||||||
for (org.hl7.fhir.utilities.json.model.JsonObject suite : manifest.getJsonObjects("suites")) {
|
|
||||||
if (!"tx.fhir.org".equals(suite.asString("mode"))) {
|
|
||||||
String sn = suite.asString("name");
|
|
||||||
for (org.hl7.fhir.utilities.json.model.JsonObject test : suite.getJsonObjects("tests")) {
|
|
||||||
String tn = test.asString("name");
|
|
||||||
examples.put(sn+"."+tn, new TestSetup(suite, test));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> names = new ArrayList<String>(examples.size());
|
|
||||||
names.addAll(examples.keySet());
|
|
||||||
Collections.sort(names);
|
|
||||||
|
|
||||||
testData = new ArrayList<Object[]>(examples.size());
|
|
||||||
for (String id : names) {
|
|
||||||
testData.add(new Object[]{id, examples.get(id)});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDiffForValidation(IWorkerContext context, String name, Resource requestParameters, String expectedResponse, String lang, String fp, JsonObject externals, boolean isCodeSystem) throws JsonSyntaxException, FileNotFoundException, IOException {
|
public static String getDiffForValidation(IWorkerContext context, String name, Resource requestParameters, String expectedResponse, String lang, String fp, JsonObject externals, boolean isCodeSystem) throws JsonSyntaxException, FileNotFoundException, IOException {
|
||||||
org.hl7.fhir.r5.model.Parameters p = (org.hl7.fhir.r5.model.Parameters) requestParameters;
|
org.hl7.fhir.r5.model.Parameters p = (org.hl7.fhir.r5.model.Parameters) requestParameters;
|
||||||
ValueSet vs = null;
|
ValueSet vs = null;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.hl7.fhir.validation.special;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||||
|
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class TxTestData {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final JsonObject manifest;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final JsonObject externals;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final List<Object[]> testData;
|
||||||
|
|
||||||
|
public TxTestData() 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);
|
||||||
|
|
||||||
|
Map<String, TxTestSetup> examples = new HashMap<String, TxTestSetup>();
|
||||||
|
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");
|
||||||
|
for (JsonObject test : suite.getJsonObjects("tests")) {
|
||||||
|
String tn = test.asString("name");
|
||||||
|
examples.put(sn + "." + tn, new TxTestSetup(suite, test));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> names = new ArrayList<String>(examples.size());
|
||||||
|
names.addAll(examples.keySet());
|
||||||
|
Collections.sort(names);
|
||||||
|
|
||||||
|
testData = new ArrayList<Object[]>(examples.size());
|
||||||
|
for (String id : names) {
|
||||||
|
testData.add(new Object[]{id, examples.get(id)});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.hl7.fhir.validation.special;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||||
|
|
||||||
|
public class TxTestSetup {
|
||||||
|
public TxTestSetup(JsonObject suite, JsonObject test) {
|
||||||
|
this.suite = suite;
|
||||||
|
this.test = test;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private JsonObject suite;
|
||||||
|
@Getter
|
||||||
|
private JsonObject test;
|
||||||
|
|
||||||
|
}
|
|
@ -4,11 +4,6 @@ import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
|
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
|
||||||
|
@ -21,35 +16,26 @@ import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||||
import org.hl7.fhir.r5.formats.JsonParser;
|
import org.hl7.fhir.r5.formats.JsonParser;
|
||||||
import org.hl7.fhir.r5.formats.XmlParser;
|
import org.hl7.fhir.r5.formats.XmlParser;
|
||||||
import org.hl7.fhir.r5.model.CanonicalType;
|
|
||||||
import org.hl7.fhir.r5.model.CodeType;
|
import org.hl7.fhir.r5.model.CodeType;
|
||||||
import org.hl7.fhir.r5.model.StringType;
|
|
||||||
import org.hl7.fhir.r5.model.CodeableConcept;
|
|
||||||
import org.hl7.fhir.r5.model.Coding;
|
|
||||||
import org.hl7.fhir.r5.model.Constants;
|
import org.hl7.fhir.r5.model.Constants;
|
||||||
import org.hl7.fhir.r5.model.OperationOutcome;
|
import org.hl7.fhir.r5.model.OperationOutcome;
|
||||||
import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity;
|
import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity;
|
||||||
import org.hl7.fhir.r5.model.OperationOutcome.IssueType;
|
import org.hl7.fhir.r5.model.OperationOutcome.IssueType;
|
||||||
import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent;
|
import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent;
|
||||||
import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent;
|
|
||||||
import org.hl7.fhir.r5.model.Resource;
|
import org.hl7.fhir.r5.model.Resource;
|
||||||
import org.hl7.fhir.r5.model.UriType;
|
|
||||||
import org.hl7.fhir.r5.model.ValueSet;
|
import org.hl7.fhir.r5.model.ValueSet;
|
||||||
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent;
|
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent;
|
||||||
import org.hl7.fhir.r5.terminologies.expansion.ValueSetExpansionOutcome;
|
import org.hl7.fhir.r5.terminologies.expansion.ValueSetExpansionOutcome;
|
||||||
import org.hl7.fhir.r5.terminologies.utilities.TerminologyServiceErrorClass;
|
|
||||||
import org.hl7.fhir.r5.terminologies.utilities.ValidationResult;
|
|
||||||
import org.hl7.fhir.r5.test.utils.CompareUtilities;
|
import org.hl7.fhir.r5.test.utils.CompareUtilities;
|
||||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||||
import org.hl7.fhir.utilities.FhirPublication;
|
import org.hl7.fhir.utilities.FhirPublication;
|
||||||
import org.hl7.fhir.utilities.TextFile;
|
import org.hl7.fhir.utilities.TextFile;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
|
||||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
|
||||||
import org.hl7.fhir.validation.ValidationEngine;
|
import org.hl7.fhir.validation.ValidationEngine;
|
||||||
import org.hl7.fhir.validation.special.TxServiceTestHelper;
|
import org.hl7.fhir.validation.special.TxServiceTestHelper;
|
||||||
import org.hl7.fhir.validation.special.TxServiceTestHelper.TestSetup;
|
import org.hl7.fhir.validation.special.TxTestSetup;
|
||||||
|
import org.hl7.fhir.validation.special.TxTestData;
|
||||||
import org.hl7.fhir.validation.special.TxTesterScrubbers;
|
import org.hl7.fhir.validation.special.TxTesterScrubbers;
|
||||||
import org.hl7.fhir.validation.special.TxTesterSorters;
|
import org.hl7.fhir.validation.special.TxTesterSorters;
|
||||||
import org.hl7.fhir.validation.tests.utilities.TestUtilities;
|
import org.hl7.fhir.validation.tests.utilities.TestUtilities;
|
||||||
|
@ -61,9 +47,6 @@ import org.junit.runners.Parameterized;
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
import org.junit.runners.Parameterized.Parameters;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.gson.JsonSyntaxException;
|
|
||||||
|
|
||||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
|
@ -72,22 +55,22 @@ import static org.junit.Assert.assertNull;
|
||||||
public class TerminologyServiceTests {
|
public class TerminologyServiceTests {
|
||||||
|
|
||||||
|
|
||||||
private static TxServiceTestHelper.TestData testData;
|
private static TxTestData testData;
|
||||||
|
|
||||||
@Parameters(name = "{index}: id {0}")
|
@Parameters(name = "{index}: id {0}")
|
||||||
public static Iterable<Object[]> data() throws IOException {
|
public static Iterable<Object[]> data() throws IOException {
|
||||||
testData = new TxServiceTestHelper.TestData();
|
testData = new TxTestData();
|
||||||
return testData.getTestData();
|
return testData.getTestData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final TestSetup setup;
|
private final TxTestSetup setup;
|
||||||
private final String version;
|
private final String version;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|
||||||
private static ValidationEngine baseEngine;
|
private static ValidationEngine baseEngine;
|
||||||
|
|
||||||
public TerminologyServiceTests(String name, TestSetup setup) {
|
public TerminologyServiceTests(String name, TxTestSetup setup) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.setup = setup;
|
this.setup = setup;
|
||||||
version = "5.0.0";
|
version = "5.0.0";
|
||||||
|
|
Loading…
Reference in New Issue