use of org.hl7.fhir.validation.ValidationEngine in project org.hl7.fhir.core by hapifhir.
the class ValidationEngineTests method testCurrentJson.
@Test
public void testCurrentJson() throws Exception {
if (!TestUtilities.silent)
System.out.println("TestCurrentJson: Validate patient-example.json in Current version");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", DEF_TX, FhirPublication.R4, "4.0.1");
CacheVerificationLogger logger = new CacheVerificationLogger();
ve.getContext().getTxClient().setLogger(logger);
OperationOutcome op = ve.validate(FhirFormat.JSON, TestingUtilities.loadTestResourceStream("validator", "patient-example.json"), null);
int e = errors(op);
int w = warnings(op);
int h = hints(op);
Assertions.assertEquals(0, e);
Assertions.assertEquals(0, w);
Assertions.assertEquals(1, h);
assertTrue(logger.verifyHasNoRequests(), "Unexpected request to TX server");
if (!TestUtilities.silent)
System.out.println(" .. done: " + Integer.toString(e) + " errors, " + Integer.toString(w) + " warnings, " + Integer.toString(h) + " information messages");
}
use of org.hl7.fhir.validation.ValidationEngine in project org.hl7.fhir.core by hapifhir.
the class ValidationEngineTests method test301USCore.
@Test
public void test301USCore() throws Exception {
if (!TestUtilities.silent)
System.out.println("Test301USCore: Validate patient300.xml against US-Core");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", DEF_TX, FhirPublication.STU3, "3.0.2");
CacheVerificationLogger logger = new CacheVerificationLogger();
ve.getContext().getTxClient().setLogger(logger);
IgLoader igLoader = new IgLoader(ve.getPcm(), ve.getContext(), ve.getVersion(), true);
if (!TestUtilities.silent)
System.out.println(" .. load USCore");
igLoader.loadIg(ve.getIgs(), ve.getBinaries(), "hl7.fhir.us.core#1.0.1", false);
List<String> profiles = new ArrayList<>();
profiles.add("http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient");
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "patient301.xml"), profiles);
if (!TestUtilities.silent)
for (OperationOutcomeIssueComponent issue : op.getIssue()) System.out.println(" - " + issue.getDetails().getText());
int e = errors(op);
int w = warnings(op);
int h = hints(op);
Assertions.assertEquals(1, e);
Assertions.assertEquals(0, w);
Assertions.assertEquals(0, h);
assertTrue(logger.verifyHasNoRequests(), "Unexpected request to TX server");
if (!TestUtilities.silent)
System.out.println(" .. done: " + Integer.toString(e) + " errors, " + Integer.toString(w) + " warnings, " + Integer.toString(h) + " information messages");
}
use of org.hl7.fhir.validation.ValidationEngine in project org.hl7.fhir.core by hapifhir.
the class ValidationEngineTests method test301.
@Test
public void test301() throws Exception {
if (!TestUtilities.silent)
System.out.println("Test301: Validate observation301.xml against Core");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", DEF_TX, FhirPublication.STU3, "3.0.2");
CacheVerificationLogger logger = new CacheVerificationLogger();
ve.getContext().getTxClient().setLogger(logger);
if (!TestUtilities.silent)
System.out.println(" .. load USCore");
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "observation301.xml"), null);
if (!TestUtilities.silent)
for (OperationOutcomeIssueComponent issue : op.getIssue()) System.out.println(" - " + issue.getDetails().getText());
int e = errors(op);
int w = warnings(op);
int h = hints(op);
Assertions.assertEquals(0, e);
assertTrue(logger.verifyHasNoRequests(), "Unexpected request to TX server");
if (!TestUtilities.silent)
System.out.println(" .. done: " + Integer.toString(e) + " errors, " + Integer.toString(w) + " warnings, " + Integer.toString(h) + " information messages");
}
use of org.hl7.fhir.validation.ValidationEngine in project org.hl7.fhir.core by hapifhir.
the class ValidationEngineTests method testObs102.
@Test
public void testObs102() throws Exception {
if (inbuild) {
Assertions.assertTrue(true);
return;
}
if (!TestUtilities.silent)
System.out.println("TestObs102: Validate patient-example.xml in v1.0.2 version");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", DEF_TX, FhirPublication.DSTU2, "1.0.2");
ve.setNoInvariantChecks(true);
CacheVerificationLogger logger = new CacheVerificationLogger();
ve.getContext().getTxClient().setLogger(logger);
OperationOutcome op = ve.validate(FhirFormat.JSON, TestingUtilities.loadTestResourceStream("validator", "observation102.json"), null);
if (!TestUtilities.silent)
for (OperationOutcomeIssueComponent iss : op.getIssue()) {
System.out.println(" " + iss.getDetails().getText());
}
int e = errors(op);
int w = warnings(op);
int h = hints(op);
Assertions.assertEquals(1, e);
Assertions.assertEquals(0, w);
Assertions.assertEquals(1, h);
assertTrue(logger.verifyHasNoRequests(), "Unexpected request to TX server");
if (!TestUtilities.silent)
System.out.println(" .. done: " + Integer.toString(e) + " errors, " + Integer.toString(w) + " warnings, " + Integer.toString(h) + " information messages");
}
use of org.hl7.fhir.validation.ValidationEngine in project org.hl7.fhir.core by hapifhir.
the class ValidationEngineTests method testCurrentXml.
@Test
public void testCurrentXml() throws Exception {
if (!TestUtilities.silent)
System.out.println("TestCurrentXml: Validate patient-example.xml in Current version");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", DEF_TX, FhirPublication.R4, "4.0.1");
CacheVerificationLogger logger = new CacheVerificationLogger();
ve.getContext().getTxClient().setLogger(logger);
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "patient-example.xml"), null);
int e = errors(op);
int w = warnings(op);
int h = hints(op);
if (!TestUtilities.silent) {
System.out.println(" .. done: " + Integer.toString(e) + " errors, " + Integer.toString(w) + " warnings, " + Integer.toString(h) + " information messages");
for (OperationOutcomeIssueComponent iss : op.getIssue()) {
System.out.println(" " + iss.getDetails().getText());
}
}
Assertions.assertEquals(0, e);
Assertions.assertEquals(0, w);
Assertions.assertEquals(1, h);
assertTrue(logger.verifyHasNoRequests(), "Unexpected request to TX server");
}
Aggregations