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();   }
@Test public void processedContentTest() throws CluecumberPluginException { Template template = mock(Template.class); PageCollection pageCollection = mock(PageCollection.class); String processedContent = pageWithChartRenderer.processedContent(template, pageCollection); assertThat(processedContent, is("")); }
@Test(expected = CluecumberPluginException.class) public void processedContentTemplateExceptionTest() throws Exception { Template template = mock(Template.class); doThrow(new TemplateException("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("")); }
@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("")); }