@Test public void testWriteDocumentationSummary() throws Exception { final String outputAbsolutePath = "i am absolutely the output path"; final File outputDirectory = mock(File.class); when(outputDirectory.getAbsolutePath()).thenReturn(outputAbsolutePath); final SummaryGenerator generator = mock(SummaryGenerator.class); whenNew(SummaryGenerator.class).withNoArguments().thenReturn(generator); final File outputFile = mock(File.class); whenNew(File.class).withArguments(outputAbsolutePath, "cdoc-report.html").thenReturn(outputFile); final FileOutputStream fileOutputStream = mock(FileOutputStream.class); whenNew(FileOutputStream.class).withArguments(outputFile).thenReturn(fileOutputStream); final OutputStreamWriter writer = mock(OutputStreamWriter.class); whenNew(OutputStreamWriter.class).withArguments(fileOutputStream, Charset.forName("utf-8")).thenReturn(writer); final MavenProject project = mock(MavenProject.class); @SuppressWarnings("unchecked") final List<Documentation> docs = mock(List.class); final File cssDirectory = mock(File.class); final CssCopyRecordingMojo testMojo = new CssCopyRecordingMojo(textParser, detailsParser); Field fieldOutputDirectory = testMojo.getClass().getSuperclass().getDeclaredField("outputDirectory"); Field fieldOutputEncoding = testMojo.getClass().getSuperclass().getDeclaredField("outputEncoding"); Field fieldProject = testMojo.getClass().getSuperclass().getDeclaredField("project"); fieldOutputDirectory.setAccessible(true); fieldOutputEncoding.setAccessible(true); fieldProject.setAccessible(true); fieldOutputDirectory.set(testMojo, outputDirectory); fieldOutputEncoding.set(testMojo, "utf-8"); fieldProject.set(testMojo, project); testMojo.writeDocumentationSummary(cssDirectory, docs); verify(generator).generate(project, docs, cssDirectory, writer); }
void writeDocumentationSummary(final File cssDirectory, final List<Documentation> documentation) throws MavenReportException { final SummaryGenerator generator = new SummaryGenerator(); try (Writer destination = getIndexWriter()) { generator.generate(getProject(), documentation, cssDirectory, destination); } catch (IOException e) { getLog().error(e.getMessage()); } }
CDocReportMojo extends AbstractMavenReport { void writeDocumentationSummary(final File cssDirectory, final List<Documentation> documentation) throws MavenReportException { final SummaryGenerator generator = new SummaryGenerator(); try (Writer destination = getIndexWriter()) { generator.generate(getProject(), documentation, cssDirectory, destination); } catch (IOException e) { getLog().error(e.getMessage()); } } }
CDocReportMojo extends AbstractMavenReport { void writeDocumentationSummary(final File cssDirectory, final List<Documentation> documentation) throws MavenReportException { final SummaryGenerator generator = new SummaryGenerator(); try (Writer destination = getIndexWriter()) { generator.generate(getProject(), documentation, cssDirectory, destination); } catch (IOException e) { getLog().error(e.getMessage()); } } CDocReportMojo();  CDocReportMojo(final TextParser textParser, final ScriptExecutionDetailsParser detailsParser); }
CDocReportMojo extends AbstractMavenReport { void writeDocumentationSummary(final File cssDirectory, final List<Documentation> documentation) throws MavenReportException { final SummaryGenerator generator = new SummaryGenerator(); try (Writer destination = getIndexWriter()) { generator.generate(getProject(), documentation, cssDirectory, destination); } catch (IOException e) { getLog().error(e.getMessage()); } } CDocReportMojo();  CDocReportMojo(final TextParser textParser, final ScriptExecutionDetailsParser detailsParser); @Override boolean canGenerateReport(); @Override String getDescription(final Locale locale); @Override String getName(final Locale locale); @Override String getOutputName(); @Override boolean isExternalReport(); }
CDocReportMojo extends AbstractMavenReport { void writeDocumentationSummary(final File cssDirectory, final List<Documentation> documentation) throws MavenReportException { final SummaryGenerator generator = new SummaryGenerator(); try (Writer destination = getIndexWriter()) { generator.generate(getProject(), documentation, cssDirectory, destination); } catch (IOException e) { getLog().error(e.getMessage()); } } CDocReportMojo();  CDocReportMojo(final TextParser textParser, final ScriptExecutionDetailsParser detailsParser); @Override boolean canGenerateReport(); @Override String getDescription(final Locale locale); @Override String getName(final Locale locale); @Override String getOutputName(); @Override boolean isExternalReport();  }