@Test public void testTransformC32ToGreenCcd_Given_Valid_C32Xml_Succeeds_IT() throws Throwable { ReflectionTestUtils.setField(sut, "xmlTransformer", createXmlTransformer()); final String c32FileUri = "c32.xml"; final String c32Xml = ResourceFileReader .getStringFromResourceFile(c32FileUri); final String greenCcd = sut.TransformC32ToGreenCcd(c32Xml); final String greenCcdFileUri = "green_ccd_transformed_from_c32.xml"; final String expectedGreenCcd = ResourceFileReader .getStringFromResourceFile(greenCcdFileUri); XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalizeWhitespace(true); assertXMLEqual("", expectedGreenCcd, greenCcd); }
@Override public String TransformC32ToGreenCcd(String c32xml) throws C32ToGreenCcdTransformerException { Assert.hasText(c32xml); try { final String xslUrl = Thread.currentThread() .getContextClassLoader().getResource(XSLTURI).toString(); final Optional<URIResolver> uriResolver = Optional .of(new UriResolverImpl()); final String greenCcd = xmlTransformer.transform(c32xml, xslUrl, Optional.empty(), uriResolver); logger.debug("greenCcd:"); logger.debug(greenCcd); return greenCcd; } catch (final Exception e) { final String errorMessage = "Error happended when trying to transform C32 to Green CCD"; logger.error(errorMessage, e); final C32ToGreenCcdTransformerException transformerException = new C32ToGreenCcdTransformerException( errorMessage, e); throw transformerException; } }
C32ToGreenCcdTransformerImpl implements C32ToGreenCcdTransformer { @Override public String TransformC32ToGreenCcd(String c32xml) throws C32ToGreenCcdTransformerException { Assert.hasText(c32xml); try { final String xslUrl = Thread.currentThread() .getContextClassLoader().getResource(XSLTURI).toString(); final Optional<URIResolver> uriResolver = Optional .of(new UriResolverImpl()); final String greenCcd = xmlTransformer.transform(c32xml, xslUrl, Optional.empty(), uriResolver); logger.debug("greenCcd:"); logger.debug(greenCcd); return greenCcd; } catch (final Exception e) { final String errorMessage = "Error happended when trying to transform C32 to Green CCD"; logger.error(errorMessage, e); final C32ToGreenCcdTransformerException transformerException = new C32ToGreenCcdTransformerException( errorMessage, e); throw transformerException; } } }
C32ToGreenCcdTransformerImpl implements C32ToGreenCcdTransformer { @Override public String TransformC32ToGreenCcd(String c32xml) throws C32ToGreenCcdTransformerException { Assert.hasText(c32xml); try { final String xslUrl = Thread.currentThread() .getContextClassLoader().getResource(XSLTURI).toString(); final Optional<URIResolver> uriResolver = Optional .of(new UriResolverImpl()); final String greenCcd = xmlTransformer.transform(c32xml, xslUrl, Optional.empty(), uriResolver); logger.debug("greenCcd:"); logger.debug(greenCcd); return greenCcd; } catch (final Exception e) { final String errorMessage = "Error happended when trying to transform C32 to Green CCD"; logger.error(errorMessage, e); final C32ToGreenCcdTransformerException transformerException = new C32ToGreenCcdTransformerException( errorMessage, e); throw transformerException; } } C32ToGreenCcdTransformerImpl(XmlTransformer xmlTransformer); }
C32ToGreenCcdTransformerImpl implements C32ToGreenCcdTransformer { @Override public String TransformC32ToGreenCcd(String c32xml) throws C32ToGreenCcdTransformerException { Assert.hasText(c32xml); try { final String xslUrl = Thread.currentThread() .getContextClassLoader().getResource(XSLTURI).toString(); final Optional<URIResolver> uriResolver = Optional .of(new UriResolverImpl()); final String greenCcd = xmlTransformer.transform(c32xml, xslUrl, Optional.empty(), uriResolver); logger.debug("greenCcd:"); logger.debug(greenCcd); return greenCcd; } catch (final Exception e) { final String errorMessage = "Error happended when trying to transform C32 to Green CCD"; logger.error(errorMessage, e); final C32ToGreenCcdTransformerException transformerException = new C32ToGreenCcdTransformerException( errorMessage, e); throw transformerException; } } C32ToGreenCcdTransformerImpl(XmlTransformer xmlTransformer); @Override String TransformC32ToGreenCcd(String c32xml); }
C32ToGreenCcdTransformerImpl implements C32ToGreenCcdTransformer { @Override public String TransformC32ToGreenCcd(String c32xml) throws C32ToGreenCcdTransformerException { Assert.hasText(c32xml); try { final String xslUrl = Thread.currentThread() .getContextClassLoader().getResource(XSLTURI).toString(); final Optional<URIResolver> uriResolver = Optional .of(new UriResolverImpl()); final String greenCcd = xmlTransformer.transform(c32xml, xslUrl, Optional.empty(), uriResolver); logger.debug("greenCcd:"); logger.debug(greenCcd); return greenCcd; } catch (final Exception e) { final String errorMessage = "Error happended when trying to transform C32 to Green CCD"; logger.error(errorMessage, e); final C32ToGreenCcdTransformerException transformerException = new C32ToGreenCcdTransformerException( errorMessage, e); throw transformerException; } } C32ToGreenCcdTransformerImpl(XmlTransformer xmlTransformer); @Override String TransformC32ToGreenCcd(String c32xml);  }