Search in sources :

Example 6 with CachingPackageClient

use of org.hl7.fhir.utilities.npm.CachingPackageClient in project org.hl7.fhir.core by hapifhir.

the class CachingPackageClientTests method testSearchNoMatches.

@Test
public void testSearchNoMatches() throws IOException {
    CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1);
    List<PackageInfo> matches = client.search("corezxxx", null, null, false);
    Assertions.assertTrue(matches.size() == 0);
}
Also used : PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) Test(org.junit.jupiter.api.Test)

Example 7 with CachingPackageClient

use of org.hl7.fhir.utilities.npm.CachingPackageClient in project org.hl7.fhir.core by hapifhir.

the class CachingPackageClientTests method testSearch2.

@Test
public void testSearch2() throws IOException {
    CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2);
    List<PackageInfo> matches = client.search("core", null, null, false);
    for (PackageInfo pi : matches) {
        System.out.println(pi.toString());
    }
    Assertions.assertTrue(matches.size() > 0);
}
Also used : PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) Test(org.junit.jupiter.api.Test)

Example 8 with CachingPackageClient

use of org.hl7.fhir.utilities.npm.CachingPackageClient in project org.hl7.fhir.core by hapifhir.

the class CachingPackageClientTests method testVersionsNone2.

@Test
public void testVersionsNone2() throws IOException {
    CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2);
    List<PackageInfo> matches = client.getVersions("Simplifier.Core.STU3X");
    Assertions.assertTrue(matches.size() == 0);
}
Also used : PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) Test(org.junit.jupiter.api.Test)

Example 9 with CachingPackageClient

use of org.hl7.fhir.utilities.npm.CachingPackageClient in project org.hl7.fhir.core by hapifhir.

the class PackageValidator method execute.

private void execute() throws IOException {
    FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
    CachingPackageClient pc = new CachingPackageClient(PackageClient.PRIMARY_SERVER);
    for (PackageInfo t : pc.search(null, null, null, false)) {
        System.out.println("Check Package " + t.getId());
        List<PackageInfo> vl = pc.getVersions(t.getId());
        PackageInfo v = vl.get(vl.size() - 1);
        System.out.println(" v" + v.getVersion());
        try {
            NpmPackage pi = pcm.loadPackage(v.getId(), v.getVersion());
            if (VersionUtilities.isR4Ver(pi.fhirVersion()) || VersionUtilities.isR3Ver(pi.fhirVersion()) || VersionUtilities.isR2Ver(pi.fhirVersion())) {
                for (String n : pi.list("package")) {
                    if (n.endsWith(".json") && !n.equals("ig-r4.json")) {
                        InputStream s = pi.load("package", n);
                        try {
                            parseResource(s, pi.fhirVersion());
                        } catch (Exception e) {
                            System.out.println("  error parsing " + n + " for " + pi.fhirVersion() + ": " + e.getMessage());
                        }
                    }
                }
            } else {
                System.out.println("  Unsupported FHIR version " + pi.fhirVersion());
            }
        } catch (Exception e) {
            System.out.println("  Error - no FHIR version");
        }
    }
}
Also used : FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager) NpmPackage(org.hl7.fhir.utilities.npm.NpmPackage) PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) InputStream(java.io.InputStream) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 10 with CachingPackageClient

use of org.hl7.fhir.utilities.npm.CachingPackageClient in project org.hl7.fhir.core by hapifhir.

the class CachingPackageClientTests method testVersionsNone.

@Test
public void testVersionsNone() throws IOException {
    CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1);
    List<PackageInfo> matches = client.getVersions("Simplifier.Core.STU3X");
    Assertions.assertTrue(matches.size() == 0);
}
Also used : PackageInfo(org.hl7.fhir.utilities.npm.PackageInfo) CachingPackageClient(org.hl7.fhir.utilities.npm.CachingPackageClient) Test(org.junit.jupiter.api.Test)

Aggregations

CachingPackageClient (org.hl7.fhir.utilities.npm.CachingPackageClient)14 Test (org.junit.jupiter.api.Test)13 PackageInfo (org.hl7.fhir.utilities.npm.PackageInfo)11 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 FHIRException (org.hl7.fhir.exceptions.FHIRException)1 FilesystemPackageCacheManager (org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager)1 NpmPackage (org.hl7.fhir.utilities.npm.NpmPackage)1