@Test public void test() { context.checking(new Expectations() { { oneOf(getThemeXmlUrlByUuidDbMapper).execute("uuid"); will(returnValue("src/test/resources/themes/vegas.xml")); } }); String result = sut.execute("uuid"); assertTrue(result.contains("div.banner-container")); context.assertIsSatisfied(); }
@Override public String execute(final String inRequest) { InputStream xsltInputStream = null; InputStream xmlInputStream = null; try { String themeUrl = getThemeXmlUrlByUuidDbMapper.execute(inRequest.toLowerCase()); xsltInputStream = getClass().getResourceAsStream(xsltPath); Source xsltSource = new StreamSource(xsltInputStream); TransformerFactory transFactory = TransformerFactory.newInstance(); javax.xml.transform.Transformer transformer = transFactory.newTransformer(xsltSource); StreamResult cssResult = new StreamResult(new StringWriter()); xmlInputStream = xmlFetcher.getInputStream(themeUrl); transformer.transform(new StreamSource(xmlInputStream), cssResult); return cssResult.getWriter().toString(); } catch (Exception e) { throw new RuntimeException("Unable to retrieve theme css", e); } finally { try { if (xsltInputStream != null) { xsltInputStream.close(); } if (xmlInputStream != null) { xmlInputStream.close(); } } catch (Exception e) { throw new RuntimeException("Unable to close streams", e); } } }
ThemeCssDbMapper implements DomainMapper<String, String> { @Override public String execute(final String inRequest) { InputStream xsltInputStream = null; InputStream xmlInputStream = null; try { String themeUrl = getThemeXmlUrlByUuidDbMapper.execute(inRequest.toLowerCase()); xsltInputStream = getClass().getResourceAsStream(xsltPath); Source xsltSource = new StreamSource(xsltInputStream); TransformerFactory transFactory = TransformerFactory.newInstance(); javax.xml.transform.Transformer transformer = transFactory.newTransformer(xsltSource); StreamResult cssResult = new StreamResult(new StringWriter()); xmlInputStream = xmlFetcher.getInputStream(themeUrl); transformer.transform(new StreamSource(xmlInputStream), cssResult); return cssResult.getWriter().toString(); } catch (Exception e) { throw new RuntimeException("Unable to retrieve theme css", e); } finally { try { if (xsltInputStream != null) { xsltInputStream.close(); } if (xmlInputStream != null) { xmlInputStream.close(); } } catch (Exception e) { throw new RuntimeException("Unable to close streams", e); } } } }
ThemeCssDbMapper implements DomainMapper<String, String> { @Override public String execute(final String inRequest) { InputStream xsltInputStream = null; InputStream xmlInputStream = null; try { String themeUrl = getThemeXmlUrlByUuidDbMapper.execute(inRequest.toLowerCase()); xsltInputStream = getClass().getResourceAsStream(xsltPath); Source xsltSource = new StreamSource(xsltInputStream); TransformerFactory transFactory = TransformerFactory.newInstance(); javax.xml.transform.Transformer transformer = transFactory.newTransformer(xsltSource); StreamResult cssResult = new StreamResult(new StringWriter()); xmlInputStream = xmlFetcher.getInputStream(themeUrl); transformer.transform(new StreamSource(xmlInputStream), cssResult); return cssResult.getWriter().toString(); } catch (Exception e) { throw new RuntimeException("Unable to retrieve theme css", e); } finally { try { if (xsltInputStream != null) { xsltInputStream.close(); } if (xmlInputStream != null) { xmlInputStream.close(); } } catch (Exception e) { throw new RuntimeException("Unable to close streams", e); } } } ThemeCssDbMapper(final String inXsltPath, final DomainMapper<String, String> inGetThemeXmlUrlByUuidDbMapper,
            final ResourceFetcher inXmlFetcher); }
ThemeCssDbMapper implements DomainMapper<String, String> { @Override public String execute(final String inRequest) { InputStream xsltInputStream = null; InputStream xmlInputStream = null; try { String themeUrl = getThemeXmlUrlByUuidDbMapper.execute(inRequest.toLowerCase()); xsltInputStream = getClass().getResourceAsStream(xsltPath); Source xsltSource = new StreamSource(xsltInputStream); TransformerFactory transFactory = TransformerFactory.newInstance(); javax.xml.transform.Transformer transformer = transFactory.newTransformer(xsltSource); StreamResult cssResult = new StreamResult(new StringWriter()); xmlInputStream = xmlFetcher.getInputStream(themeUrl); transformer.transform(new StreamSource(xmlInputStream), cssResult); return cssResult.getWriter().toString(); } catch (Exception e) { throw new RuntimeException("Unable to retrieve theme css", e); } finally { try { if (xsltInputStream != null) { xsltInputStream.close(); } if (xmlInputStream != null) { xmlInputStream.close(); } } catch (Exception e) { throw new RuntimeException("Unable to close streams", e); } } } ThemeCssDbMapper(final String inXsltPath, final DomainMapper<String, String> inGetThemeXmlUrlByUuidDbMapper,
            final ResourceFetcher inXmlFetcher); @Override String execute(final String inRequest); }
ThemeCssDbMapper implements DomainMapper<String, String> { @Override public String execute(final String inRequest) { InputStream xsltInputStream = null; InputStream xmlInputStream = null; try { String themeUrl = getThemeXmlUrlByUuidDbMapper.execute(inRequest.toLowerCase()); xsltInputStream = getClass().getResourceAsStream(xsltPath); Source xsltSource = new StreamSource(xsltInputStream); TransformerFactory transFactory = TransformerFactory.newInstance(); javax.xml.transform.Transformer transformer = transFactory.newTransformer(xsltSource); StreamResult cssResult = new StreamResult(new StringWriter()); xmlInputStream = xmlFetcher.getInputStream(themeUrl); transformer.transform(new StreamSource(xmlInputStream), cssResult); return cssResult.getWriter().toString(); } catch (Exception e) { throw new RuntimeException("Unable to retrieve theme css", e); } finally { try { if (xsltInputStream != null) { xsltInputStream.close(); } if (xmlInputStream != null) { xmlInputStream.close(); } } catch (Exception e) { throw new RuntimeException("Unable to close streams", e); } } } ThemeCssDbMapper(final String inXsltPath, final DomainMapper<String, String> inGetThemeXmlUrlByUuidDbMapper,
            final ResourceFetcher inXmlFetcher); @Override String execute(final String inRequest);  }