@Test(expected = CluecumberPluginException.class) public void processedContentIoExceptionTest() throws Exception { Template template = mock(Template.class); doThrow(new IOException("Test", null)).when(template).process(any(PageCollection.class), any(Writer.class)); PageCollection pageCollection = mock(PageCollection.class); String processedContent = pageWithChartRenderer.processedContent(template, pageCollection); assertThat(processedContent, is("")); }
String processedContent(final Template template, final Object pageCollection) throws CluecumberPluginException { Writer stringWriter = new StringWriter(); try { template.process(pageCollection, stringWriter); } catch (TemplateException | IOException e) { throw new CluecumberPluginException("Could not render page content: " + e.getMessage()); } return stringWriter.toString(); }
PageRenderer { String processedContent(final Template template, final Object pageCollection) throws CluecumberPluginException { Writer stringWriter = new StringWriter(); try { template.process(pageCollection, stringWriter); } catch (TemplateException | IOException e) { throw new CluecumberPluginException("Could not render page content: " + e.getMessage()); } return stringWriter.toString(); } }
PageRenderer { String processedContent(final Template template, final Object pageCollection) throws CluecumberPluginException { Writer stringWriter = new StringWriter(); try { template.process(pageCollection, stringWriter); } catch (TemplateException | IOException e) { throw new CluecumberPluginException("Could not render page content: " + e.getMessage()); } return stringWriter.toString(); } @Inject  PageRenderer(); }
PageRenderer { String processedContent(final Template template, final Object pageCollection) throws CluecumberPluginException { Writer stringWriter = new StringWriter(); try { template.process(pageCollection, stringWriter); } catch (TemplateException | IOException e) { throw new CluecumberPluginException("Could not render page content: " + e.getMessage()); } return stringWriter.toString(); } @Inject  PageRenderer();  }
PageRenderer { String processedContent(final Template template, final Object pageCollection) throws CluecumberPluginException { Writer stringWriter = new StringWriter(); try { template.process(pageCollection, stringWriter); } catch (TemplateException | IOException e) { throw new CluecumberPluginException("Could not render page content: " + e.getMessage()); } return stringWriter.toString(); } @Inject  PageRenderer();   }