SequenceAwareXslTransformer { public byte[] transform(final InputStream xslInputStream, final InputStream requestInputStream, final InputStream templateInputStream, final Map<String, String> nameToXml) throws SaxonApiException, SAXException { Processor processor = processorFactory.createProcessor(); XMLReader xmlReader = createXMLReader(); XsltExecutable xsltExecutable = xslCompiler.compileXsl(xslInputStream, processor); XsltTransformer xsltTransformer = xsltExecutable.load(); ByteArrayOutputStream output = xslOutputProvider.getOutput(xsltTransformer); setRequest(requestInputStream, processor, xsltTransformer); setSessionEntities(nameToXml, processor, xsltTransformer); setTemplate(templateInputStream, processor, xmlReader, xsltTransformer); xsltTransformer.transform(); return output.toByteArray(); }  byte[] transform(final InputStream xslInputStream, final InputStream requestInputStream, final InputStream templateInputStream,
            final Map<String, String> nameToXml);  }
@Test public void testTransformShouldSetTemplateAsInitialContextNode() throws SaxonApiException, SAXException { given(xslCompiler.compileXsl(xslInputStream, processor)).willReturn(xsltExecutable); given(xsltExecutable.load()).willReturn(xsltTransformer); given(xslOutputProvider.getOutput(xsltTransformer)).willReturn(outputStream); givenParameter("request", requestName); setTemplateMocks(); underTest.transform(xslInputStream, requestInputStream, templateInputStream, nameToXml); verify(xsltTransformer).setInitialContextNode(templateNode); }
@Test public void testTransformShouldDoTransform() throws SaxonApiException, SAXException { given(xslCompiler.compileXsl(xslInputStream, processor)).willReturn(xsltExecutable); given(xsltExecutable.load()).willReturn(xsltTransformer); given(xslOutputProvider.getOutput(xsltTransformer)).willReturn(outputStream); givenParameter("request", requestName); setTemplateMocks(); underTest.transform(xslInputStream, requestInputStream, templateInputStream, nameToXml); verify(xsltTransformer).transform(); }
@Test public void testTransformShouldReturnOutput() throws SaxonApiException, SAXException { given(xslCompiler.compileXsl(xslInputStream, processor)).willReturn(xsltExecutable); given(xsltExecutable.load()).willReturn(xsltTransformer); given(xslOutputProvider.getOutput(xsltTransformer)).willReturn(outputStream); givenParameter("request", requestName); setTemplateMocks(); byte[] actual = underTest.transform(xslInputStream, requestInputStream, templateInputStream, nameToXml); assertEquals(actual, outputStream.toByteArray()); }