001package org.hl7.fhir.r5.test.utils;
002
003import java.io.IOException;
004import java.io.InputStream;
005import java.util.ArrayList;
006import java.util.List;
007
008import org.hl7.fhir.exceptions.FHIRException;
009import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader;
010import org.hl7.fhir.r5.formats.JsonParser;
011import org.hl7.fhir.r5.formats.XmlParser;
012import org.hl7.fhir.r5.model.Bundle;
013import org.hl7.fhir.r5.model.CodeSystem;
014import org.hl7.fhir.r5.model.Resource;
015import org.hl7.fhir.utilities.npm.NpmPackage;
016
017public class TestPackageLoader implements IContextResourceLoader {
018
019  private String[] types;
020
021  public TestPackageLoader(String[] types) {
022    this.types = types;
023  }
024
025  @Override
026  public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException {
027    return null;
028  }
029
030  @Override
031  public Resource loadResource(InputStream stream, boolean isJson) throws FHIRException, IOException {
032    return isJson ? new JsonParser().parse(stream) : new XmlParser().parse(stream);
033  }
034
035  @Override
036  public String[] getTypes() {
037    return types;
038  }
039
040  @Override
041  public String getResourcePath(Resource resource) {
042    return resource.fhirType().toLowerCase()+"-"+resource.getId()+".html";
043  }
044
045  @Override
046  public IContextResourceLoader getNewLoader(NpmPackage npm) {
047    return this;
048  }
049
050  @Override
051  public List<CodeSystem> getCodeSystems() {
052    return new ArrayList<>();
053  }
054
055}