@Test public void includeResourcesInPatient() throws Exception { Path patient = FileSystems.getDefault().getPath("target/classes/META-INF/syndesis/schemas/dstu3/patient.json"); String inspection; try (InputStream fileIn = Files.newInputStream(patient)) { inspection = IOUtils.toString(fileIn, StandardCharsets.UTF_8); } String inspectionWithResources = FhirMetadataRetrieval.includeResources(inspection, "person", "account"); ObjectMapper mapper = io.atlasmap.v2.Json.mapper(); XmlDocument xmlDocument = mapper.readValue(inspectionWithResources, XmlDocument.class); XmlComplexType resource = (XmlComplexType) xmlDocument.getFields().getField().get(0); Assertions.assertThat(resource.getName()).isEqualTo("tns:Patient"); assertCorrectPath(resource, "tns:Patient", "tns:contained", "tns:Person"); assertCorrectPath(resource, "tns:Patient", "tns:contained", "tns:Person", "tns:contained", "tns:Person"); assertCorrectPath(resource, "tns:Patient", "tns:contained", "tns:Person", "tns:contained", "tns:Account"); assertCorrectPath(resource, "tns:Patient", "tns:contained", "tns:Account"); assertCorrectPath(resource, "tns:Patient", "tns:contained", "tns:Account", "tns:contained", "tns:Person"); assertCorrectPath(resource, "tns:Patient", "tns:contained", "tns:Account", "tns:contained", "tns:Account"); }
static String includeResources(String specification, String... resourceTypes) throws IOException { if (resourceTypes != null && resourceTypes.length != 0) { XmlDocument document = MAPPER.readValue(specification, XmlDocument.class); includeResources(null, document, resourceTypes); return MAPPER.writer((PrettyPrinter) null).writeValueAsString(document); } return specification; }
FhirMetadataRetrieval extends ComponentMetadataRetrieval { static String includeResources(String specification, String... resourceTypes) throws IOException { if (resourceTypes != null && resourceTypes.length != 0) { XmlDocument document = MAPPER.readValue(specification, XmlDocument.class); includeResources(null, document, resourceTypes); return MAPPER.writer((PrettyPrinter) null).writeValueAsString(document); } return specification; } }
FhirMetadataRetrieval extends ComponentMetadataRetrieval { static String includeResources(String specification, String... resourceTypes) throws IOException { if (resourceTypes != null && resourceTypes.length != 0) { XmlDocument document = MAPPER.readValue(specification, XmlDocument.class); includeResources(null, document, resourceTypes); return MAPPER.writer((PrettyPrinter) null).writeValueAsString(document); } return specification; }  }
FhirMetadataRetrieval extends ComponentMetadataRetrieval { static String includeResources(String specification, String... resourceTypes) throws IOException { if (resourceTypes != null && resourceTypes.length != 0) { XmlDocument document = MAPPER.readValue(specification, XmlDocument.class); includeResources(null, document, resourceTypes); return MAPPER.writer((PrettyPrinter) null).writeValueAsString(document); } return specification; }   }
FhirMetadataRetrieval extends ComponentMetadataRetrieval { static String includeResources(String specification, String... resourceTypes) throws IOException { if (resourceTypes != null && resourceTypes.length != 0) { XmlDocument document = MAPPER.readValue(specification, XmlDocument.class); includeResources(null, document, resourceTypes); return MAPPER.writer((PrettyPrinter) null).writeValueAsString(document); } return specification; }   static final String FHIR; static final String RESOURCE_TYPE; }