@SuppressWarnings("unchecked") @Test(expected = Hl7v3TransformerException.class) public void testTransformC32ToHl7v3PixXml_exception() throws IOException, URISyntaxException, Hl7v3TransformerException { final String c32XMLString = FileUtils .readFileToString(new File(getClass().getClassLoader() .getResource("xml/c32.xml").toURI())); when( xmlTransformer.transform(eq(c32XMLString), anyString(), any(Optional.class), any(Optional.class))).thenThrow( DS4PException.class); final String hl7v3PixXML = sut.transformToHl7v3PixXml(c32XMLString, Hl7v3Transformer.XSLT_C32_TO_PIX_ADD); assertNotNull(hl7v3PixXML); }
@Override public String transformToHl7v3PixXml(String xml, String XSLTURI) throws Hl7v3TransformerException { try { final String xslUrl = Thread.currentThread() .getContextClassLoader().getResource(XSLTURI).toString(); final String hl7v3PixXML = xmlTransformer.transform(xml, xslUrl, Optional.empty(), Optional.empty()); logger.debug("hl7v3PixXML:"); logger.debug(hl7v3PixXML); return hl7v3PixXML; } catch (final Exception e) { final String errorMessage = "Error happended when trying to transform xml to PIX xml"; logger.error(errorMessage, e); final Hl7v3TransformerException transformerException = new Hl7v3TransformerException( errorMessage, e); throw transformerException; } }
Hl7v3TransformerImpl implements Hl7v3Transformer { @Override public String transformToHl7v3PixXml(String xml, String XSLTURI) throws Hl7v3TransformerException { try { final String xslUrl = Thread.currentThread() .getContextClassLoader().getResource(XSLTURI).toString(); final String hl7v3PixXML = xmlTransformer.transform(xml, xslUrl, Optional.empty(), Optional.empty()); logger.debug("hl7v3PixXML:"); logger.debug(hl7v3PixXML); return hl7v3PixXML; } catch (final Exception e) { final String errorMessage = "Error happended when trying to transform xml to PIX xml"; logger.error(errorMessage, e); final Hl7v3TransformerException transformerException = new Hl7v3TransformerException( errorMessage, e); throw transformerException; } } }
Hl7v3TransformerImpl implements Hl7v3Transformer { @Override public String transformToHl7v3PixXml(String xml, String XSLTURI) throws Hl7v3TransformerException { try { final String xslUrl = Thread.currentThread() .getContextClassLoader().getResource(XSLTURI).toString(); final String hl7v3PixXML = xmlTransformer.transform(xml, xslUrl, Optional.empty(), Optional.empty()); logger.debug("hl7v3PixXML:"); logger.debug(hl7v3PixXML); return hl7v3PixXML; } catch (final Exception e) { final String errorMessage = "Error happended when trying to transform xml to PIX xml"; logger.error(errorMessage, e); final Hl7v3TransformerException transformerException = new Hl7v3TransformerException( errorMessage, e); throw transformerException; } } Hl7v3TransformerImpl(XmlTransformer xmlTransformer); }
Hl7v3TransformerImpl implements Hl7v3Transformer { @Override public String transformToHl7v3PixXml(String xml, String XSLTURI) throws Hl7v3TransformerException { try { final String xslUrl = Thread.currentThread() .getContextClassLoader().getResource(XSLTURI).toString(); final String hl7v3PixXML = xmlTransformer.transform(xml, xslUrl, Optional.empty(), Optional.empty()); logger.debug("hl7v3PixXML:"); logger.debug(hl7v3PixXML); return hl7v3PixXML; } catch (final Exception e) { final String errorMessage = "Error happended when trying to transform xml to PIX xml"; logger.error(errorMessage, e); final Hl7v3TransformerException transformerException = new Hl7v3TransformerException( errorMessage, e); throw transformerException; } } Hl7v3TransformerImpl(XmlTransformer xmlTransformer); @Override String getPixQueryXml(String mrn, String mrnDomain, String xsltUri); @Override String transformToHl7v3PixXml(String xml, String XSLTURI); }
Hl7v3TransformerImpl implements Hl7v3Transformer { @Override public String transformToHl7v3PixXml(String xml, String XSLTURI) throws Hl7v3TransformerException { try { final String xslUrl = Thread.currentThread() .getContextClassLoader().getResource(XSLTURI).toString(); final String hl7v3PixXML = xmlTransformer.transform(xml, xslUrl, Optional.empty(), Optional.empty()); logger.debug("hl7v3PixXML:"); logger.debug(hl7v3PixXML); return hl7v3PixXML; } catch (final Exception e) { final String errorMessage = "Error happended when trying to transform xml to PIX xml"; logger.error(errorMessage, e); final Hl7v3TransformerException transformerException = new Hl7v3TransformerException( errorMessage, e); throw transformerException; } } Hl7v3TransformerImpl(XmlTransformer xmlTransformer); @Override String getPixQueryXml(String mrn, String mrnDomain, String xsltUri); @Override String transformToHl7v3PixXml(String xml, String XSLTURI);  }