use of org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager in project org.hl7.fhir.core by hapifhir.
the class UtilitiesXTests method context.
public static IWorkerContext context(String version) {
if (fcontexts == null) {
fcontexts = new HashMap<>();
}
if (!fcontexts.containsKey(version)) {
FilesystemPackageCacheManager pcm;
try {
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_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);
} catch (Exception e) {
throw new Error(e);
}
}
return fcontexts.get(version);
}
use of org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager in project org.hl7.fhir.core by hapifhir.
the class IgLoaderTests method testFailIfInvalidFHIRVersion.
@Test
public void testFailIfInvalidFHIRVersion() throws IOException {
IgLoader igLoader = Mockito.spy(new IgLoader(filesystemPackageCacheManager, simpleWorkerContext, "4.0.1"));
Exception exception = assertThrows(FHIRException.class, () -> {
List<ImplementationGuide> igs = Collections.emptyList();
igLoader.loadIg(igs, Collections.emptyMap(), "[0.1.2]" + DUMMY_PATH, false);
});
assertLinesMatch(Arrays.asList(".*Unsupported FHIR Version.*"), Arrays.asList(exception.getMessage()));
}
use of org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager in project org.hl7.fhir.core by hapifhir.
the class TestingUtilities method context.
public static IWorkerContext context(String version) {
if ("4.5.0".equals(version)) {
// temporary work around
version = "4.4.0";
}
String v = VersionUtilities.getMajMin(version);
if (fcontexts == null) {
fcontexts = new HashMap<>();
}
if (!fcontexts.containsKey(v)) {
FilesystemPackageCacheManager pcm;
try {
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
IWorkerContext fcontext = SimpleWorkerContext.fromPackage(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);
fcontexts.put(v, fcontext);
} catch (Exception e) {
e.printStackTrace();
throw new Error(e);
}
}
return fcontexts.get(v);
}
use of org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager in project org.hl7.fhir.core by hapifhir.
the class CDARoundTripTests method setUp.
@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"));
fp = new FHIRPathEngine(context);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "any.xml"), "any.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "ii.xml"), "ii.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "cd.xml"), "cd.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "ce.xml"), "ce.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "ed.xml"), "ed.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "st.xml"), "st.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "cda.xml"), "cda.xml", null);
for (StructureDefinition sd : context.getStructures()) {
if (!sd.hasSnapshot()) {
// System.out.println("generate snapshot for " + sd.getUrl());
context.generateSnapshot(sd, true);
}
}
}
use of org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager in project org.hl7.fhir.core by hapifhir.
the class PackageCacheTests method testPatchWildCard.
@Test
public void testPatchWildCard() throws IOException {
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
cache.clear();
Assertions.assertEquals(cache.loadPackage("hl7.fhir.us.core", "3.1.0").version(), "3.1.0");
Assertions.assertEquals(cache.loadPackage("hl7.fhir.us.core", "3.1.1").version(), "3.1.1");
Assertions.assertEquals(cache.loadPackage("hl7.fhir.us.core", "3.1.x").version(), "3.1.1");
Assertions.assertEquals(cache.loadPackage("hl7.fhir.us.core", "3.0.x").version(), "3.0.1");
}
Aggregations