@SuppressWarnings("unchecked") @Test public void testExecuteReport() throws Exception { final List<File> files = mock(List.class); final List<Documentation> documentation = mock(List.class); final File destinationDirectory = mock(File.class); final File cssDirectory = mock(File.class); when(cssDirectory.exists()).thenReturn(Boolean.TRUE); whenNew(File.class).withArguments(destinationDirectory, "css").thenReturn(cssDirectory); final ExecutionRecordingMojo testMojo = new ExecutionRecordingMojo(textParser, detailsParser); testMojo.setDestinationDirectory(destinationDirectory); testMojo.setFiles(files); testMojo.addDocumentation(files, documentation); testMojo.executeReport(Locale.getDefault()); assertThat(testMojo.getObjectDocInvocations()).hasSize(1); final WriteInvocation objectInvocation = testMojo.getObjectDocInvocations().get(0); assertThat(objectInvocation.getCssDirectory()).isEqualTo(cssDirectory); assertThat(objectInvocation.getDocs()).isEqualTo(documentation); assertThat(testMojo.getSummaryInvocations()).hasSize(1); final WriteInvocation summaryInvocation = testMojo.getSummaryInvocations().get(0); assertThat(summaryInvocation.getCssDirectory()).isEqualTo(cssDirectory); assertThat(summaryInvocation.getDocs()).isEqualTo(documentation); assertThat(testMojo.getCopyInvocations()).hasSize(3); final CopyInvocation cdocCssInvocation = testMojo.getCopyInvocations().get(0); assertThat(cdocCssInvocation.getCssDirectory()).isEqualTo(cssDirectory); assertThat(cdocCssInvocation.getCssFilename()).isEqualTo("cdoc.css"); final CopyInvocation scriptCssInvocation = testMojo.getCopyInvocations().get(1); assertThat(scriptCssInvocation.getCssDirectory()).isEqualTo(cssDirectory); assertThat(scriptCssInvocation.getCssFilename()).isEqualTo("script-doc.css"); final CopyInvocation summaryCssInvocation = testMojo.getCopyInvocations().get(2); assertThat(summaryCssInvocation.getCssDirectory()).isEqualTo(cssDirectory); assertThat(summaryCssInvocation.getCssFilename()).isEqualTo("script-doc-summary.css"); }
@Override protected void executeReport(final Locale locale) throws MavenReportException { final List<File> scriptFiles = getFiles(); final File cssDirectory = new File(getDestinationDirectory(), "css"); if (!cssDirectory.exists()) { try { FileUtils.forceMkdir(cssDirectory); } catch (final IOException e) { throw new MavenReportException("Failed to create CSS directory.", e); } } copyCss(cssDirectory, "cdoc.css"); copyCss(cssDirectory, "script-doc.css"); final List<Documentation> docs = toDocumentation(scriptFiles); if (docs.size() == 1) { try (final Writer indexWriter = getIndexWriter()) { writeObjectDocumentation(cssDirectory, docs.get(0), indexWriter, new Navigation("Back to Maven Site", "./project-reports.html")); } catch (IOException e) { getLog().info(e.getMessage()); } } else { copyCss(cssDirectory, "script-doc-summary.css"); writeDocumentationSummary(cssDirectory, docs); writeObjectDocumentation(cssDirectory, docs, new Navigation("Back to Summary", "../cdoc-report.html")); } }
CDocReportMojo extends AbstractMavenReport { @Override protected void executeReport(final Locale locale) throws MavenReportException { final List<File> scriptFiles = getFiles(); final File cssDirectory = new File(getDestinationDirectory(), "css"); if (!cssDirectory.exists()) { try { FileUtils.forceMkdir(cssDirectory); } catch (final IOException e) { throw new MavenReportException("Failed to create CSS directory.", e); } } copyCss(cssDirectory, "cdoc.css"); copyCss(cssDirectory, "script-doc.css"); final List<Documentation> docs = toDocumentation(scriptFiles); if (docs.size() == 1) { try (final Writer indexWriter = getIndexWriter()) { writeObjectDocumentation(cssDirectory, docs.get(0), indexWriter, new Navigation("Back to Maven Site", "./project-reports.html")); } catch (IOException e) { getLog().info(e.getMessage()); } } else { copyCss(cssDirectory, "script-doc-summary.css"); writeDocumentationSummary(cssDirectory, docs); writeObjectDocumentation(cssDirectory, docs, new Navigation("Back to Summary", "../cdoc-report.html")); } } }
CDocReportMojo extends AbstractMavenReport { @Override protected void executeReport(final Locale locale) throws MavenReportException { final List<File> scriptFiles = getFiles(); final File cssDirectory = new File(getDestinationDirectory(), "css"); if (!cssDirectory.exists()) { try { FileUtils.forceMkdir(cssDirectory); } catch (final IOException e) { throw new MavenReportException("Failed to create CSS directory.", e); } } copyCss(cssDirectory, "cdoc.css"); copyCss(cssDirectory, "script-doc.css"); final List<Documentation> docs = toDocumentation(scriptFiles); if (docs.size() == 1) { try (final Writer indexWriter = getIndexWriter()) { writeObjectDocumentation(cssDirectory, docs.get(0), indexWriter, new Navigation("Back to Maven Site", "./project-reports.html")); } catch (IOException e) { getLog().info(e.getMessage()); } } else { copyCss(cssDirectory, "script-doc-summary.css"); writeDocumentationSummary(cssDirectory, docs); writeObjectDocumentation(cssDirectory, docs, new Navigation("Back to Summary", "../cdoc-report.html")); } } CDocReportMojo();  CDocReportMojo(final TextParser textParser, final ScriptExecutionDetailsParser detailsParser); }
CDocReportMojo extends AbstractMavenReport { @Override protected void executeReport(final Locale locale) throws MavenReportException { final List<File> scriptFiles = getFiles(); final File cssDirectory = new File(getDestinationDirectory(), "css"); if (!cssDirectory.exists()) { try { FileUtils.forceMkdir(cssDirectory); } catch (final IOException e) { throw new MavenReportException("Failed to create CSS directory.", e); } } copyCss(cssDirectory, "cdoc.css"); copyCss(cssDirectory, "script-doc.css"); final List<Documentation> docs = toDocumentation(scriptFiles); if (docs.size() == 1) { try (final Writer indexWriter = getIndexWriter()) { writeObjectDocumentation(cssDirectory, docs.get(0), indexWriter, new Navigation("Back to Maven Site", "./project-reports.html")); } catch (IOException e) { getLog().info(e.getMessage()); } } else { copyCss(cssDirectory, "script-doc-summary.css"); writeDocumentationSummary(cssDirectory, docs); writeObjectDocumentation(cssDirectory, docs, new Navigation("Back to Summary", "../cdoc-report.html")); } } 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 { @Override protected void executeReport(final Locale locale) throws MavenReportException { final List<File> scriptFiles = getFiles(); final File cssDirectory = new File(getDestinationDirectory(), "css"); if (!cssDirectory.exists()) { try { FileUtils.forceMkdir(cssDirectory); } catch (final IOException e) { throw new MavenReportException("Failed to create CSS directory.", e); } } copyCss(cssDirectory, "cdoc.css"); copyCss(cssDirectory, "script-doc.css"); final List<Documentation> docs = toDocumentation(scriptFiles); if (docs.size() == 1) { try (final Writer indexWriter = getIndexWriter()) { writeObjectDocumentation(cssDirectory, docs.get(0), indexWriter, new Navigation("Back to Maven Site", "./project-reports.html")); } catch (IOException e) { getLog().info(e.getMessage()); } } else { copyCss(cssDirectory, "script-doc-summary.css"); writeDocumentationSummary(cssDirectory, docs); writeObjectDocumentation(cssDirectory, docs, new Navigation("Back to Summary", "../cdoc-report.html")); } } 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();  }