MetadataGeneratorImpl implements MetadataGenerator { @Override public String generateMetadataXml(String document, String executionResponseContainer, String homeCommunityId, String senderEmailAddress, String recipientEmailAddress) { final Params params = ParamsBuilder .withParam(PARAM_NAME_HOME_COMMUNITY_ID, homeCommunityId) .and(PARAM_NAME_AUTHOR_TELECOMMUNICATION, senderEmailAddress) .and(PARAM_NAME_INTENDED_RECIPIENT, recipientEmailAddress); final String xslUrl = Thread.currentThread().getContextClassLoader() .getResource(METADATA_XSL).toString(); executionResponseContainer = executionResponseContainer.replace( "<ruleExecutionContainer>", "<ruleExecutionContainer xmlns=\"urn:hl7-org:v3\">"); final Optional<URIResolver> uriResolver = Optional .of(new StringURIResolver().put( URI_RESOLVER_HREF_RULE_EXECUTION_RESPONSE_CONTAINER, executionResponseContainer)); final String metadataXml = xmlTransformer.transform(document, xslUrl, Optional.of(params), uriResolver); logger.debug("Metadata:"); logger.debug(metadataXml); return metadataXml; } MetadataGeneratorImpl(XmlTransformer xmlTransformer); @Override String generateMetadataXml(String document,
			String executionResponseContainer, String homeCommunityId,
			String senderEmailAddress, String recipientEmailAddress);  }
@Test public void testGenerateMetadataXml() throws Exception { final String metadata = metadataGenerator.generateMetadataXml(c32, executionResponseContainer, homeCommunityId, senderEmailAddress, recipientEmailAddress); logger.debug(metadata); assertTrue(metadata .contains("<Value>PatientID^^^&amp;2.16.840.1.113883.3.467&amp;ISO</Value>")); assertTrue(metadata .contains("<Value>^^Internet^leo.smith@direct.obhita-stage.org</Value>")); assertTrue(metadata .contains("<Value>^^Internet^Duane_Decouteau@direct.healthvault-stage.com</Value>")); assertTrue(metadata.contains("<Value>TREAT</Value>")); assertTrue(metadata .contains("<Value observationId=\"d11275e7-67ae-11db-bd13-0800200c9a66\">ENCRYPT</Value>")); assertTrue(metadata .contains("<Value observationId=\"d11275e7-67ae-11db-bd13-0800200c9a66\">NORDSLCD</Value>")); assertTrue(metadata .contains("<Value observationId=\"d11275e7-67ae-11db-bd13-0800200c9a66\">HIV</Value>")); assertTrue(metadata .contains("<Value observationId=\"d11275e7-67ae-11db-bd13-0800200c9a66\">42CFRPart2</Value>")); assertTrue(metadata .contains("<Value>100010020002^^^&amp;2.16.840.1.113883.3.467&amp;ISO</Value>")); }
@Test(expected = DS4PException.class) public void testGenerateMetadataXml_Throws_DS4PException() { @SuppressWarnings("unused") final String metadata = metadataGenerator.generateMetadataXml("", executionResponseContainer, homeCommunityId, senderEmailAddress, recipientEmailAddress); }