More cacheing for tests + allow cacheing for error responses

WORK IN PROGRESS; cacheErrors is set to TRUE always at this stage.
This commit is contained in:
dotasek 2021-12-10 16:45:30 -05:00
parent 394452b747
commit 3b58aef820
14 changed files with 131 additions and 63 deletions

View File

@ -114,6 +114,13 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok_version}</version>
<scope>provided</scope>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>

View File

@ -45,6 +45,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.fhir.ucum.UcumService;
import org.hl7.fhir.exceptions.DefinitionException;
@ -203,6 +204,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
protected ILoggingService logger;
protected Parameters expParameters;
private TranslationServices translator = new NullTranslator();
@Getter
protected TerminologyCache txCache;
protected TimeTracker clock;
private boolean tlogging = true;
@ -945,14 +948,14 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
if (options.isGuessSystem()) {
pIn.addParameter().setName("implySystem").setValue(new BooleanType(true));
}
setTerminologyOptions(options, pIn);
res = validateOnServer(vs, pIn, options);
setTerminologyOptions(options, pIn);res = validateOnServer(vs, pIn, options);
} catch (Exception e) {
res = new ValidationResult(IssueSeverity.ERROR, e.getMessage() == null ? e.getClass().getName() : e.getMessage()).setTxLink(txLog == null ? null : txLog.getLastId()).setErrorClass(TerminologyServiceErrorClass.SERVER_ERROR);
}
if (res.getErrorClass() == TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED && !code.hasVersion()) {
unsupportedCodeSystems.add(codeKey);
} else if (txCache != null) { // we never cache unsuppoted code systems - we always keep trying (but only once per run)
}
if (txCache != null) { // we never cache unsuppoted code systems - we always keep trying (but only once per run)
txCache.cacheValidation(cacheToken, res, TerminologyCache.PERMANENT);
}
return res;
@ -2068,10 +2071,6 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
return this;
}
public String getTxCache() {
return txCache.getFolder();
}
public TerminologyClient getTxClient() {
return txClient;
}

View File

@ -36,11 +36,10 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext.ValidationResult;
@ -84,10 +83,19 @@ public class TerminologyCache {
private static final String ENTRY_MARKER = "-------------------------------------------------------------------------------------";
private static final String BREAK = "####";
@Getter
private int requestCount;
@Getter
private int hitCount;
@Getter
private int networkCount;
public class CacheToken {
private String name;
private String key;
private String request;
private boolean hasVersion;
public void setName(String n) {
if (name == null)
name = n;
@ -114,12 +122,21 @@ public class TerminologyCache {
private String folder;
private Map<String, NamedCache> caches = new HashMap<String, NamedCache>();
private static boolean noCaching;
private static boolean cacheErrors;
static {
String cacheErrorsProperty = System.getProperty("cacheErrors");
cacheErrors = true;//cacheErrorsProperty != null ? "TRUE".equals(cacheErrorsProperty.toUpperCase(Locale.ROOT)) : false;
}
// use lock from the context
public TerminologyCache(Object lock, String folder) throws FileNotFoundException, IOException, FHIRException {
super();
this.lock = lock;
this.folder = folder;
requestCount = 0;
hitCount = 0;
networkCount = 0;
if (folder != null)
load();
}
@ -133,6 +150,7 @@ public class TerminologyCache {
ct.name = getNameForSystem(code.getSystem());
else
ct.name = NAME_FOR_NO_SYSTEM;
ct.hasVersion = code.hasVersion();
JsonParser json = new JsonParser();
json.setOutputStyle(OutputStyle.PRETTY);
ValueSet vsc = getVSEssense(vs);
@ -145,15 +163,16 @@ public class TerminologyCache {
return ct;
}
private String getValueSetHash(ValueSet vsc) {
final String expansionKey = vsc.getExpansion().getContains().stream().map(x -> x.getCode()).collect(Collectors.joining(","));
final String composeKey = vsc.getCompose().getIncludeFirstRep().getConcept().stream().map(x -> x.getCode()).collect(Collectors.joining(","));
return Integer.toString((expansionKey + "\t" + composeKey).hashCode());
}
public String extracted(JsonParser json, ValueSet vsc) throws IOException {
String s = null;
if (vsc.getExpansion().getContains().size() > 1000 || vsc.getCompose().getIncludeFirstRep().getConcept().size() > 1000) {
int hashCode = (vsc.getExpansion().getContains().toString() + vsc.getCompose().getIncludeFirstRep().getConcept().toString()).hashCode();
StringBuilder sb = new StringBuilder();
for (ValueSet.ConceptReferenceComponent c : vsc.getCompose().getIncludeFirstRep().getConcept()) {
sb.append(c.getCode());
}
s = Integer.toString((vsc.getExpansion().getContains().toString() + sb.toString()).hashCode()); // turn caching off - hack efficiency optimisation
s = getValueSetHash(vsc); // save a hash representation instead of a complete valueset
} else {
s = json.composeString(vsc);
}
@ -165,7 +184,9 @@ public class TerminologyCache {
for (Coding c : code.getCoding()) {
if (c.hasSystem())
ct.setName(getNameForSystem(c.getSystem()));
ct.hasVersion = c.hasVersion();
}
JsonParser json = new JsonParser();
json.setOutputStyle(OutputStyle.PRETTY);
ValueSet vsc = getVSEssense(vs);
@ -194,14 +215,20 @@ public class TerminologyCache {
CacheToken ct = new CacheToken();
ValueSet vsc = getVSEssense(vs);
for (ConceptSetComponent inc : vs.getCompose().getInclude())
if (inc.hasSystem())
if (inc.hasSystem()) {
ct.setName(getNameForSystem(inc.getSystem()));
ct.hasVersion = inc.hasVersion();
}
for (ConceptSetComponent inc : vs.getCompose().getExclude())
if (inc.hasSystem())
if (inc.hasSystem()) {
ct.setName(getNameForSystem(inc.getSystem()));
ct.hasVersion = inc.hasVersion();
}
for (ValueSetExpansionContainsComponent inc : vs.getExpansion().getContains())
if (inc.hasSystem())
if (inc.hasSystem()) {
ct.setName(getNameForSystem(inc.getSystem()));
ct.hasVersion = inc.hasVersion();
}
JsonParser json = new JsonParser();
json.setOutputStyle(OutputStyle.PRETTY);
try {
@ -277,6 +304,15 @@ public class TerminologyCache {
if (noCaching) {
return;
}
if ( !cacheErrors &&
( e.v!= null
&& e.v.getErrorClass() == TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED
&& !cacheToken.hasVersion)) {
return;
}
boolean n = nc.map.containsKey(cacheToken.key);
nc.map.put(cacheToken.key, e);
if (persistent) {
@ -293,16 +329,22 @@ public class TerminologyCache {
}
public ValidationResult getValidation(CacheToken cacheToken) {
if (cacheToken.key == null) {
return null;
}
synchronized (lock) {
requestCount++;
NamedCache nc = getNamedCache(cacheToken);
CacheEntry e = nc.map.get(cacheToken.key);
if (e == null)
if (e == null) {
networkCount++;
return null;
else
} else {
hitCount++;
return e.v;
}
}
}

View File

@ -0,0 +1,5 @@
package org.hl7.fhir.r5.test.utils;
public class TestConstants {
public static final java.lang.String TX_CACHE = "/Users/david.otasek/org.hl7.fhir.core-cache";
}

View File

@ -23,6 +23,8 @@ import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.IPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.npm.ToolsVersion;
import org.hl7.fhir.utilities.tests.BaseTestingUtilities;
import org.w3c.dom.Document;
@ -89,7 +91,7 @@ public class TestingUtilities extends BaseTestingUtilities {
FilesystemPackageCacheManager pcm;
try {
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
IWorkerContext fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage(VersionUtilities.packageForVersion(version), version));
IWorkerContext fcontext = getWorkerContext(pcm.loadPackage(VersionUtilities.packageForVersion(version), version));
fcontext.setUcumService(new UcumEssenceService(TestingUtilities.loadTestResourceStream("ucum", "ucum-essence.xml")));
fcontext.setExpansionProfile(new Parameters());
// ((SimpleWorkerContext) fcontext).connectToTSServer(new TerminologyClientR5("http://tx.fhir.org/r4"), null);
@ -102,6 +104,21 @@ public class TestingUtilities extends BaseTestingUtilities {
return fcontexts.get(v);
}
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage) throws Exception {
SimpleWorkerContext swc = SimpleWorkerContext.fromPackage(npmPackage);
swc.initTS(TestConstants.TX_CACHE+ "/" + swc.getVersion());
swc.setUserAgent("fhir/r5-test-cases");
return swc;
}
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage, IWorkerContext.IContextResourceLoader loader) throws Exception {
SimpleWorkerContext swc = SimpleWorkerContext.fromPackage(npmPackage, loader);
swc.initTS(TestConstants.TX_CACHE+ "/" + swc.getVersion());
swc.setUserAgent("fhir/r5-test-cases");
return swc;
}
static public String fixedpath;
static public String contentpath;

View File

@ -5,6 +5,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.elementmodel.Manager;
@ -27,7 +28,7 @@ public class CDARoundTripTests {
@BeforeAll
public static void setUp() throws Exception {
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
context = TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
fp = new FHIRPathEngine(context);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "any.xml"), "any.xml", null);

View File

@ -25,7 +25,7 @@ public class StructureMapUtilitiesTest implements ITransformerServices {
@BeforeAll
static public void setUp() throws Exception {
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
context = TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
}
@Test

View File

@ -25,7 +25,8 @@ public class XmlParserTests {
@BeforeAll
public static void setUp() throws Exception {
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
context = TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
fp = new FHIRPathEngine(context);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "any.xml"), "any.xml", null);

View File

@ -1,21 +0,0 @@
package org.hl7.fhir;
import org.hl7.fhir.r5.model.FhirPublication;
import org.hl7.fhir.validation.ValidationEngine;
public class TestingUtilities {
public static final ValidationEngine getValidationEngine(java.lang.String src, java.lang.String txsrvr, java.lang.String txLog, FhirPublication version, boolean canRunWithoutTerminologyServer, java.lang.String vString, java.lang.String userAgent) throws Exception {
txLog = TestConstants.TX_CACHE + "/tx.log.html";
final ValidationEngine validationEngine = new ValidationEngine(src, txsrvr, txLog, version, canRunWithoutTerminologyServer, vString, userAgent);
validationEngine.getContext().initTS(TestConstants.TX_CACHE + "/" + version.toString());
validationEngine.getContext().setUserAgent("fhir/test-cases");
return validationEngine;
}
public static ValidationEngine getValidationEngine(java.lang.String src, java.lang.String txsrvr, java.lang.String txLog, FhirPublication version, java.lang.String vString, java.lang.String userAgent) throws Exception {
final ValidationEngine validationEngine = new ValidationEngine(src, txsrvr, txLog, version, vString, userAgent);
validationEngine.getContext().initTS(TestConstants.TX_CACHE + "/" + version.toString());
validationEngine.getContext().setUserAgent("fhir/test-cases");
return validationEngine;
}
}

View File

@ -55,6 +55,7 @@ import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader;
import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.model.Parameters;
import org.hl7.fhir.r5.test.utils.TestingUtilities;
import org.hl7.fhir.utilities.CSFile;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
@ -86,7 +87,7 @@ public class UtilitiesXTests {
FilesystemPackageCacheManager pcm;
try {
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
IWorkerContext fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage(VersionUtilities.packageForVersion(version), version), loaderForVersion(version));
IWorkerContext fcontext = TestingUtilities.getWorkerContext(pcm.loadPackage(VersionUtilities.packageForVersion(version), version), loaderForVersion(version));
fcontext.setUcumService(new UcumEssenceService(UtilitiesXTests.loadTestResourceStream("ucum", "ucum-essence.xml")));
fcontext.setExpansionProfile(new Parameters());
fcontexts.put(version, fcontext);

View File

@ -3,7 +3,7 @@ package org.hl7.fhir.validation.tests;
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.TestConstants;
import org.hl7.fhir.validation.tests.utilities.TestConstants;
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
import org.hl7.fhir.r5.model.FhirPublication;
import org.hl7.fhir.r5.model.OperationOutcome;
@ -27,7 +27,7 @@ public class ValidationEngineTests {
public void testCurrentXml() throws Exception {
if (!TestUtilities.silent)
System.out.println("TestCurrentXml: Validate patient-example.xml in Current version");
ValidationEngine ve = org.hl7.fhir.TestingUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", DEF_TX, null, FhirPublication.R4, "4.0.1", "fhir/test-cases");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", DEF_TX, null, FhirPublication.R4, "4.0.1", "fhir/test-cases");
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "patient-example.xml"), null);
int e = errors(op);
@ -48,7 +48,7 @@ public class ValidationEngineTests {
public void testCurrentJson() throws Exception {
if (!TestUtilities.silent)
System.out.println("TestCurrentJson: Validate patient-example.json in Current version");
ValidationEngine ve = org.hl7.fhir.TestingUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", DEF_TX, null, FhirPublication.R4, "4.0.1", "fhir/test-cases");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", DEF_TX, null, FhirPublication.R4, "4.0.1", "fhir/test-cases");
OperationOutcome op = ve.validate(FhirFormat.JSON, TestingUtilities.loadTestResourceStream("validator", "patient-example.json"), null);
int e = errors(op);
@ -69,7 +69,7 @@ public class ValidationEngineTests {
}
if (!TestUtilities.silent)
System.out.println("Test140: Validate patient-example.xml in v1.4.0 version");
ValidationEngine ve = org.hl7.fhir.TestingUtilities.getValidationEngine("hl7.fhir.r2b.core#1.4.0", DEF_TX, null, FhirPublication.DSTU2016May, "1.4.0", "fhir/test-cases");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r2b.core#1.4.0", DEF_TX, null, FhirPublication.DSTU2016May, "1.4.0", "fhir/test-cases");
ve.getContext().initTS(TestConstants.TX_CACHE);
ve.getContext().setUserAgent("fhir/test-cases");
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "patient140.xml"), null);
@ -95,7 +95,7 @@ public class ValidationEngineTests {
}
if (!org.hl7.fhir.validation.tests.utilities.TestUtilities.silent)
System.out.println("Test102: Validate patient-example.xml in v1.0.2 version");
ValidationEngine ve = org.hl7.fhir.TestingUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", DEF_TX, null, FhirPublication.DSTU2, "1.0.2", "fhir/test-cases");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", DEF_TX, null, FhirPublication.DSTU2, "1.0.2", "fhir/test-cases");
ve.setNoInvariantChecks(true);
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "patient102.xml"), null);
@ -121,7 +121,7 @@ public class ValidationEngineTests {
}
if (!TestUtilities.silent)
System.out.println("TestObs102: Validate patient-example.xml in v1.0.2 version");
ValidationEngine ve = org.hl7.fhir.TestingUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", DEF_TX, null, FhirPublication.DSTU2, "1.0.2", "fhir/test-cases");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", DEF_TX, null, FhirPublication.DSTU2, "1.0.2", "fhir/test-cases");
ve.setNoInvariantChecks(true);
OperationOutcome op = ve.validate(FhirFormat.JSON, TestingUtilities.loadTestResourceStream("validator", "observation102.json"), null);
@ -144,7 +144,7 @@ public class ValidationEngineTests {
public void test301() throws Exception {
if (!TestUtilities.silent)
System.out.println("Test301: Validate observation301.xml against Core");
ValidationEngine ve = org.hl7.fhir.TestingUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", DEF_TX, null, FhirPublication.STU3, "3.0.2", "fhir/test-cases");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", DEF_TX, null, FhirPublication.STU3, "3.0.2", "fhir/test-cases");
if (!TestUtilities.silent)
System.out.println(" .. load USCore");
@ -164,7 +164,7 @@ public class ValidationEngineTests {
public void test301USCore() throws Exception {
if (!TestUtilities.silent)
System.out.println("Test301USCore: Validate patient300.xml against US-Core");
ValidationEngine ve = org.hl7.fhir.TestingUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", DEF_TX, null, FhirPublication.STU3, "3.0.2", "fhir/test-cases");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", DEF_TX, null, FhirPublication.STU3, "3.0.2", "fhir/test-cases");
IgLoader igLoader = new IgLoader(ve.getPcm(), ve.getContext(), ve.getVersion(), true);
if (!TestUtilities.silent)

View File

@ -15,7 +15,7 @@ import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.NotImplementedException;
import org.hl7.fhir.TestingUtilities;
import org.hl7.fhir.validation.tests.utilities.TestUtilities;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
@ -144,15 +144,15 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
version = VersionUtilities.getMajMin(version);
if (!ve.containsKey(version)) {
if (version.startsWith("5.0"))
ve.put(version, TestingUtilities.getValidationEngine("hl7.fhir.r5.core#4.5.0", ValidationEngineTests.DEF_TX, txLog, FhirPublication.R5, true, "4.5.0", "fhir/test-cases"));
ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r5.core#4.5.0", ValidationEngineTests.DEF_TX, txLog, FhirPublication.R5, true, "4.5.0", "fhir/test-cases"));
else if (version.startsWith("3.0"))
ve.put(version, TestingUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", ValidationEngineTests.DEF_TX, txLog, FhirPublication.STU3, true, "3.0.2", "fhir/test-cases"));
ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", ValidationEngineTests.DEF_TX, txLog, FhirPublication.STU3, true, "3.0.2", "fhir/test-cases"));
else if (version.startsWith("4.0"))
ve.put(version, TestingUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", ValidationEngineTests.DEF_TX, txLog, FhirPublication.R4, true, "4.0.1", "fhir/test-cases"));
ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", ValidationEngineTests.DEF_TX, txLog, FhirPublication.R4, true, "4.0.1", "fhir/test-cases"));
else if (version.startsWith("1.0"))
ve.put(version, TestingUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", ValidationEngineTests.DEF_TX, txLog, FhirPublication.DSTU2, true, "1.0.2", "fhir/test-cases"));
ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", ValidationEngineTests.DEF_TX, txLog, FhirPublication.DSTU2, true, "1.0.2", "fhir/test-cases"));
else if (version.startsWith("1.4"))
ve.put(version, TestingUtilities.getValidationEngine("hl7.fhir.r2b.core#1.4.0", ValidationEngineTests.DEF_TX, txLog, FhirPublication.DSTU2016May, true, "1.4.0", "fhir/test-cases"));
ve.put(version, TestUtilities.getValidationEngine("hl7.fhir.r2b.core#1.4.0", ValidationEngineTests.DEF_TX, txLog, FhirPublication.DSTU2016May, true, "1.4.0", "fhir/test-cases"));
else
throw new Exception("unknown version " + version);
}

View File

@ -1,4 +1,4 @@
package org.hl7.fhir;
package org.hl7.fhir.validation.tests.utilities;
public class TestConstants {
public static final java.lang.String TX_CACHE = "/Users/david.otasek/org.hl7.fhir.core-cache";

View File

@ -1,5 +1,8 @@
package org.hl7.fhir.validation.tests.utilities;
import org.hl7.fhir.r5.model.FhirPublication;
import org.hl7.fhir.validation.ValidationEngine;
public class TestUtilities {
public static boolean silent = false;
@ -7,5 +10,18 @@ public class TestUtilities {
// public static String resourceNameToFile(String name) throws IOException {
// return org.hl7.fhir.utilities.Utilities.path(System.getProperty("user.dir"), "src", "test", "resources", name);
// }
public static final ValidationEngine getValidationEngine(java.lang.String src, java.lang.String txsrvr, java.lang.String txLog, FhirPublication version, boolean canRunWithoutTerminologyServer, java.lang.String vString, java.lang.String userAgent) throws Exception {
txLog = TestConstants.TX_CACHE + "/tx.log.html";
final ValidationEngine validationEngine = new ValidationEngine(src, txsrvr, txLog, version, canRunWithoutTerminologyServer, vString, userAgent);
validationEngine.getContext().initTS(TestConstants.TX_CACHE + "/" + vString);
validationEngine.getContext().setUserAgent("fhir/test-cases");
return validationEngine;
}
public static ValidationEngine getValidationEngine(java.lang.String src, java.lang.String txsrvr, java.lang.String txLog, FhirPublication version, java.lang.String vString, java.lang.String userAgent) throws Exception {
final ValidationEngine validationEngine = new ValidationEngine(src, txsrvr, txLog, version, vString, userAgent);
validationEngine.getContext().initTS(TestConstants.TX_CACHE + "/" + vString);
validationEngine.getContext().setUserAgent("fhir/test-cases");
return validationEngine;
}
}