use of org.hl7.fhir.validation.ValidationEngine in project org.hl7.fhir.core by hapifhir.
the class ValidationEngineTests method test140.
@Test
public void test140() throws Exception {
if (inbuild) {
Assertions.assertTrue(true);
return;
}
if (!TestUtilities.silent)
System.out.println("Test140: Validate patient-example.xml in v1.4.0 version");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r2b.core#1.4.0", DEF_TX, FhirPublication.DSTU2016May, "1.4.0");
CacheVerificationLogger logger = new CacheVerificationLogger();
ve.getContext().getTxClient().setLogger(logger);
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "patient140.xml"), 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(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 TestUtilities method getValidationEngine.
public static ValidationEngine getValidationEngine(java.lang.String src, java.lang.String txServer, String txLog, FhirPublication version, boolean canRunWithoutTerminologyServer, java.lang.String vString) throws Exception {
final ValidationEngine validationEngine = new ValidationEngine.ValidationEngineBuilder().withCanRunWithoutTerminologyServer(canRunWithoutTerminologyServer).withVersion(vString).withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(Paths.get(TestConstants.TX_CACHE, vString).toString()).withTxServer(txServer, txLog, version).fromSource(src);
TerminologyCache.setCacheErrors(true);
return validationEngine;
}
use of org.hl7.fhir.validation.ValidationEngine in project org.hl7.fhir.core by hapifhir.
the class TestUtilities method getValidationEngine.
public static ValidationEngine getValidationEngine(java.lang.String src, java.lang.String txServer, FhirPublication version, java.lang.String vString) throws Exception {
final ValidationEngine validationEngine = new ValidationEngine.ValidationEngineBuilder().withVersion(vString).withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(Paths.get(TestConstants.TX_CACHE, vString).toString()).withTxServer(txServer, TestConstants.TX_CACHE_LOG, version).fromSource(src);
TerminologyCache.setCacheErrors(true);
return validationEngine;
}
use of org.hl7.fhir.validation.ValidationEngine in project org.hl7.fhir.core by hapifhir.
the class SessionCacheTest method expiredSession.
@Test
@DisplayName("test session expiration works")
void expiredSession() throws IOException, InterruptedException {
final long EXPIRE_TIME = 5L;
SessionCache cache = new SessionCache(EXPIRE_TIME, TimeUnit.SECONDS);
ValidationEngine testEngine = new ValidationEngine.ValidationEngineBuilder().fromNothing();
String sessionId = cache.cacheSession(testEngine);
TimeUnit.SECONDS.sleep(EXPIRE_TIME + 1L);
Assertions.assertNull(cache.fetchSessionValidatorEngine(sessionId));
}
use of org.hl7.fhir.validation.ValidationEngine in project org.hl7.fhir.core by hapifhir.
the class SessionCacheTest method cachedSession.
@Test
@DisplayName("test session caching works")
void cachedSession() throws IOException {
final long EXPIRE_TIME = 5L;
SessionCache cache = new SessionCache(EXPIRE_TIME, TimeUnit.SECONDS);
ValidationEngine testEngine = new ValidationEngine.ValidationEngineBuilder().fromNothing();
String sessionId = cache.cacheSession(testEngine);
Assertions.assertEquals(testEngine, cache.fetchSessionValidatorEngine(sessionId));
}
Aggregations