Tests should all run now (#343)

This commit is contained in:
Mark Iantorno 2020-09-09 12:33:38 -04:00 committed by GitHub
parent 1d2e9a2be8
commit 78b61c4555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 48 deletions

View File

@ -8,7 +8,7 @@ import org.hl7.fhir.dstu3.test.support.TestingUtilities;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.junit.jupiter.api.Test;
class JsonParserTestCase {
class JsonParserTest {
@Test
void testParseJsonNull() throws FHIRFormatError, IOException {

View File

@ -5,11 +5,10 @@ import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy;
import org.hl7.fhir.r5.context.IWorkerContext.PackageVersion;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.test.CanonicalResourceManagerTester.DeferredLoadTestResource;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class CanonicalResourceManagerTester {
public class CanonicalResourceManagerTests {
public class DeferredLoadTestResource extends CanonicalResourceProxy {
private CanonicalResource resource;

View File

@ -46,7 +46,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class SnapShotGenerationTestsX {
public class SnapShotGenerationXTests {
public enum TestFetchMode {
INPUT,
@ -171,19 +171,19 @@ public class SnapShotGenerationTestsX {
}
public void load() throws FHIRFormatError, FileNotFoundException, IOException {
if (TestingUtilitiesX.findTestResource("rX", "snapshot-generation", id + "-input.json"))
source = (StructureDefinition) new JsonParser().parse(TestingUtilitiesX.loadTestResourceStream("rX", "snapshot-generation", id + "-input.json"));
if (UtilitiesXTests.findTestResource("rX", "snapshot-generation", id + "-input.json"))
source = (StructureDefinition) new JsonParser().parse(UtilitiesXTests.loadTestResourceStream("rX", "snapshot-generation", id + "-input.json"));
else
source = (StructureDefinition) new XmlParser().parse(TestingUtilitiesX.loadTestResourceStream("rX", "snapshot-generation", id + "-input.xml"));
source = (StructureDefinition) new XmlParser().parse(UtilitiesXTests.loadTestResourceStream("rX", "snapshot-generation", id + "-input.xml"));
if (!fail)
expected = (StructureDefinition) new XmlParser().parse(TestingUtilitiesX.loadTestResourceStream("rX", "snapshot-generation", id + "-expected.xml"));
expected = (StructureDefinition) new XmlParser().parse(UtilitiesXTests.loadTestResourceStream("rX", "snapshot-generation", id + "-expected.xml"));
if (!Utilities.noString(include))
included = (StructureDefinition) new XmlParser().parse(TestingUtilitiesX.loadTestResourceStream("rX", "snapshot-generation", include + ".xml"));
included = (StructureDefinition) new XmlParser().parse(UtilitiesXTests.loadTestResourceStream("rX", "snapshot-generation", include + ".xml"));
if (!Utilities.noString(register)) {
if (TestingUtilitiesX.findTestResource("rX", "snapshot-generation", register + ".xml")) {
included = (StructureDefinition) new XmlParser().parse(TestingUtilitiesX.loadTestResourceStream("rX", "snapshot-generation", register + ".xml"));
if (UtilitiesXTests.findTestResource("rX", "snapshot-generation", register + ".xml")) {
included = (StructureDefinition) new XmlParser().parse(UtilitiesXTests.loadTestResourceStream("rX", "snapshot-generation", register + ".xml"));
} else {
included = (StructureDefinition) new JsonParser().parse(TestingUtilitiesX.loadTestResourceStream("rX", "snapshot-generation", register + ".json"));
included = (StructureDefinition) new JsonParser().parse(UtilitiesXTests.loadTestResourceStream("rX", "snapshot-generation", register + ".json"));
}
}
}
@ -201,13 +201,13 @@ public class SnapShotGenerationTestsX {
@Override
public boolean isDatatype(String name) {
StructureDefinition sd = TestingUtilitiesX.context(version).fetchTypeDefinition(name);
StructureDefinition sd = UtilitiesXTests.context(version).fetchTypeDefinition(name);
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE || sd.getKind() == StructureDefinitionKind.COMPLEXTYPE);
}
@Override
public boolean isResource(String typeSimple) {
StructureDefinition sd = TestingUtilitiesX.context(version).fetchTypeDefinition(typeSimple);
StructureDefinition sd = UtilitiesXTests.context(version).fetchTypeDefinition(typeSimple);
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.RESOURCE);
}
@ -239,7 +239,7 @@ public class SnapShotGenerationTestsX {
@Override
public String getLinkForProfile(StructureDefinition profile, String url) {
StructureDefinition sd = TestingUtilitiesX.context(version).fetchResource(StructureDefinition.class, url);
StructureDefinition sd = UtilitiesXTests.context(version).fetchResource(StructureDefinition.class, url);
if (sd == null)
return url + "|" + url;
else
@ -265,15 +265,15 @@ public class SnapShotGenerationTestsX {
public Resource fetchFixture(String id) {
TestFetchMode mode = TestFetchMode.INPUT;
if (id.equals("patient"))
return TestingUtilitiesX.context(version).fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient");
return UtilitiesXTests.context(version).fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient");
if (id.equals("valueset"))
return TestingUtilitiesX.context(version).fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet");
return UtilitiesXTests.context(version).fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet");
if (id.equals("organization"))
return TestingUtilitiesX.context(version).fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Organization");
return UtilitiesXTests.context(version).fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Organization");
if (id.equals("operationoutcome"))
return TestingUtilitiesX.context(version).fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/OperationOutcome");
return UtilitiesXTests.context(version).fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/OperationOutcome");
if (id.equals("parameters"))
return TestingUtilitiesX.context(version).fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Parameters");
return UtilitiesXTests.context(version).fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Parameters");
if (id.contains("-")) {
String[] p = id.split("\\-");
@ -329,7 +329,7 @@ public class SnapShotGenerationTestsX {
@Override
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
if ("fixture".equals(functionName))
return new TypeDetails(CollectionStatus.SINGLETON, TestingUtilitiesX.context(version).getResourceNamesAsSet());
return new TypeDetails(CollectionStatus.SINGLETON, UtilitiesXTests.context(version).getResourceNamesAsSet());
return null;
}
@ -356,7 +356,7 @@ public class SnapShotGenerationTestsX {
@Override
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
IResourceValidator val = TestingUtilitiesX.context(version).newValidator();
IResourceValidator val = UtilitiesXTests.context(version).newValidator();
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
if (item instanceof Resource) {
val.validate(appContext, valerrors, (Resource) item, url);
@ -392,7 +392,7 @@ public class SnapShotGenerationTestsX {
public static Iterable<Object[]> data() throws ParserConfigurationException, IOException, FHIRFormatError, SAXException {
SnapShotGenerationTestsContext context = new SnapShotGenerationTestsContext();
Document tests = XMLUtil.parseToDom(TestingUtilitiesX.loadTestResource("rX", "snapshot-generation", "manifest.xml"));
Document tests = XMLUtil.parseToDom(UtilitiesXTests.loadTestResource("rX", "snapshot-generation", "manifest.xml"));
Element test = XMLUtil.getFirstChild(tests.getDocumentElement());
List<Object[]> objects = new ArrayList<Object[]>();
while (test != null && test.getNodeName().equals("test")) {
@ -416,7 +416,7 @@ public class SnapShotGenerationTestsX {
version = test.version;
this.context = context;
if (fp == null)
fp = new FHIRPathEngine(TestingUtilitiesX.context(version));
fp = new FHIRPathEngine(UtilitiesXTests.context(version));
fp.setHostServices(context);
messages = new ArrayList<ValidationMessage>();
@ -453,29 +453,29 @@ public class SnapShotGenerationTestsX {
private void testSort(TestDetails test) throws DefinitionException, FHIRException, IOException {
StructureDefinition base = getSD(test.getSource().getBaseDefinition());
test.setOutput(test.getSource().copy());
ProfileUtilities pu = new ProfileUtilities(TestingUtilitiesX.context(version), null, null);
ProfileUtilities pu = new ProfileUtilities(UtilitiesXTests.context(version), null, null);
pu.setIds(test.getSource(), false);
List<String> errors = new ArrayList<String>();
pu.sortDifferential(base, test.getOutput(), test.getOutput().getUrl(), errors, false);
if (!errors.isEmpty())
throw new FHIRException(errors.get(0));
IOUtils.copy(TestingUtilitiesX.loadTestResourceStream("rX", "snapshot-generation", test.getId() + "-expected.xml"), new FileOutputStream(TestingUtilitiesX.tempFile("snapshot", test.getId() + "-expected.xml")));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilitiesX.tempFile("snapshot", test.getId() + "-actual.xml")), test.getOutput());
IOUtils.copy(UtilitiesXTests.loadTestResourceStream("rX", "snapshot-generation", test.getId() + "-expected.xml"), new FileOutputStream(UtilitiesXTests.tempFile("snapshot", test.getId() + "-expected.xml")));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(UtilitiesXTests.tempFile("snapshot", test.getId() + "-actual.xml")), test.getOutput());
Assertions.assertTrue(test.expected.equalsDeep(test.output), "Output does not match expected");
}
private void testGen(boolean fail, TestDetails test) throws Exception {
if (!Utilities.noString(test.register)) {
List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
ProfileUtilities pu = new ProfileUtilities(TestingUtilitiesX.context(version), messages, null);
ProfileUtilities pu = new ProfileUtilities(UtilitiesXTests.context(version), messages, null);
pu.setNewSlicingProcessing(true);
pu.setIds(test.included, false);
StructureDefinition base = TestingUtilitiesX.context(version).fetchResource(StructureDefinition.class, test.included.getBaseDefinition());
StructureDefinition base = UtilitiesXTests.context(version).fetchResource(StructureDefinition.class, test.included.getBaseDefinition());
if (base != null) {
pu.generateSnapshot(base, test.included, test.included.getUrl(), "http://test.org/profile", test.included.getName());
}
if (!TestingUtilitiesX.context(version).hasResource(StructureDefinition.class, test.included.getUrl()))
TestingUtilitiesX.context(version).cacheResource(test.included);
if (!UtilitiesXTests.context(version).hasResource(StructureDefinition.class, test.included.getUrl()))
UtilitiesXTests.context(version).cacheResource(test.included);
int ec = 0;
for (ValidationMessage vm : messages) {
if (vm.getLevel() == IssueSeverity.ERROR) {
@ -491,7 +491,7 @@ public class SnapShotGenerationTestsX {
throw new Exception("URL mismatch on base: " + base.getUrl() + " wanting " + test.getSource().getBaseDefinition());
StructureDefinition output = test.getSource().copy();
ProfileUtilities pu = new ProfileUtilities(TestingUtilitiesX.context(version), messages, new TestPKP());
ProfileUtilities pu = new ProfileUtilities(UtilitiesXTests.context(version), messages, new TestPKP());
pu.setNewSlicingProcessing(test.isNewSliceProcessing());
pu.setThrowException(false);
pu.setDebug(test.isDebug());
@ -527,12 +527,12 @@ public class SnapShotGenerationTestsX {
}
if (!fail) {
test.output = output;
TestingUtilitiesX.context(version).cacheResource(output);
File dst = new File(TestingUtilitiesX.tempFile("snapshot", test.getId() + "-expected.xml"));
UtilitiesXTests.context(version).cacheResource(output);
File dst = new File(UtilitiesXTests.tempFile("snapshot", test.getId() + "-expected.xml"));
if (dst.exists())
dst.delete();
IOUtils.copy(TestingUtilitiesX.loadTestResourceStream("rX", "snapshot-generation", test.getId() + "-expected.xml"), new FileOutputStream(dst));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilitiesX.tempFile("snapshot", test.getId() + "-actual.xml")), output);
IOUtils.copy(UtilitiesXTests.loadTestResourceStream("rX", "snapshot-generation", test.getId() + "-expected.xml"), new FileOutputStream(dst));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(UtilitiesXTests.tempFile("snapshot", test.getId() + "-actual.xml")), output);
StructureDefinition t1 = test.expected.copy();
t1.setText(null);
StructureDefinition t2 = test.output.copy();
@ -551,10 +551,10 @@ public class SnapShotGenerationTestsX {
private StructureDefinition getSD(String url) throws DefinitionException, FHIRException, IOException {
StructureDefinition sd = context.getByUrl(url);
if (sd == null)
sd = TestingUtilitiesX.context(version).fetchResource(StructureDefinition.class, url);
sd = UtilitiesXTests.context(version).fetchResource(StructureDefinition.class, url);
if (!sd.hasSnapshot()) {
StructureDefinition base = getSD(sd.getBaseDefinition());
ProfileUtilities pu = new ProfileUtilities(TestingUtilitiesX.context(version), messages, new TestPKP());
ProfileUtilities pu = new ProfileUtilities(UtilitiesXTests.context(version), messages, new TestPKP());
pu.setNewSlicingProcessing(true);
List<String> errors = new ArrayList<String>();
pu.sortDifferential(base, sd, url, errors, false);

View File

@ -74,7 +74,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
public class TestingUtilitiesX {
public class UtilitiesXTests {
private static final boolean SHOW_DIFF = true;
static public Map<String, IWorkerContext> fcontexts;
@ -88,7 +88,7 @@ public class TestingUtilitiesX {
try {
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
IWorkerContext fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage(VersionUtilities.packageForVersion(version), version), loaderForVersion(version));
fcontext.setUcumService(new UcumEssenceService(TestingUtilitiesX.loadTestResourceStream("ucum", "ucum-essence.xml")));
fcontext.setUcumService(new UcumEssenceService(UtilitiesXTests.loadTestResourceStream("ucum", "ucum-essence.xml")));
fcontext.setExpansionProfile(new Parameters());
fcontexts.put(version, fcontext);
} catch (Exception e) {
@ -482,7 +482,7 @@ public class TestingUtilitiesX {
} else {
String classpath = ("/org/hl7/fhir/testcases/"+ Utilities.pathURL(paths));
try {
InputStream inputStream = TestingUtilitiesX.class.getResourceAsStream(classpath);
InputStream inputStream = UtilitiesXTests.class.getResourceAsStream(classpath);
return inputStream != null;
} catch (Throwable t) {
return false;
@ -504,7 +504,7 @@ public class TestingUtilitiesX {
// resolve from the package
String contents;
String classpath = ("/org/hl7/fhir/testcases/"+ Utilities.pathURL(paths));
try (InputStream inputStream = TestingUtilitiesX.class.getResourceAsStream(classpath)) {
try (InputStream inputStream = UtilitiesXTests.class.getResourceAsStream(classpath)) {
if (inputStream == null) {
throw new IOException("Can't find file on classpath: " + classpath);
}
@ -520,7 +520,7 @@ public class TestingUtilitiesX {
return new FileInputStream(n);
} else {
String classpath = ("/org/hl7/fhir/testcases/"+ Utilities.pathURL(paths));
InputStream s = TestingUtilitiesX.class.getResourceAsStream(classpath);
InputStream s = UtilitiesXTests.class.getResourceAsStream(classpath);
if (s == null) {
throw new Error("unable to find resource "+classpath);
}
@ -534,7 +534,7 @@ public class TestingUtilitiesX {
return TextFile.fileToBytes(n);
} else {
String classpath = ("/org/hl7/fhir/testcases/"+ Utilities.pathURL(paths));
InputStream s = TestingUtilitiesX.class.getResourceAsStream(classpath);
InputStream s = UtilitiesXTests.class.getResourceAsStream(classpath);
if (s == null) {
throw new Error("unable to find resource "+classpath);
}

View File

@ -7,7 +7,7 @@ import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@Disabled
public class CDAValidationTestCase {
public class CDAValidationTest {
private SimpleWorkerContext context;

View File

@ -10,7 +10,7 @@ import org.junit.Test;
import net.sf.saxon.expr.instruct.Message;
public class TestLoadIg {
public class LoadIgTests {
@Test
public void testPackage() {

View File

@ -70,7 +70,7 @@ import java.util.Map;
import java.util.Map.Entry;
@RunWith(Parameterized.class)
public class ValidationTestSuite implements IEvaluationContext, IValidatorResourceFetcher {
public class ValidationTests implements IEvaluationContext, IValidatorResourceFetcher {
public final static boolean PRINT_OUTPUT_TO_CONSOLE = true;
@ -105,7 +105,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
private static Map<String, ValidationEngine> ve = new HashMap<>();
private static ValidationEngine vCurr;
public ValidationTestSuite(String name, JsonObject content) {
public ValidationTests(String name, JsonObject content) {
this.name = name;
this.content = content;
}