@Test public void testGenerate() throws Exception { final String projectName = "a-project-name"; final String projectVersion = "1.374783937467-beta-1"; when(project.getName()).thenReturn(projectName); when(project.getVersion()).thenReturn(projectVersion); final File tempCssDirectory = File.createTempFile("testGenerate", null).getParentFile(); final VelocityContext context = mock(VelocityContext.class); whenNew(VelocityContext.class).withNoArguments().thenReturn(context); final Template template = mock(Template.class); when(engine.getTemplate("/velocity/script-doc-summary.vm", "utf-8")).thenReturn(template); generator.generate(project, documentation, tempCssDirectory, writer); verify(context).put("projectName", projectName); verify(context).put("projectVersion", projectVersion); verify(context).put("docs", documentation); verify(context).put("cssDirectory", tempCssDirectory.toURI().toURL().toExternalForm()); verify(template).merge(context, writer); }
public void generate(final MavenProject project, final List<Documentation> documentation, final File cssDirectory, final Writer destination) throws MavenReportException { if (project == null) { throw new IllegalArgumentException("Maven project cannot be null."); } if (documentation == null) { throw new IllegalArgumentException("Documentation cannot be null."); } if (cssDirectory == null) { throw new IllegalArgumentException("CSS directory cannot be null."); } if (destination == null) { throw new IllegalArgumentException("Destination writer cannot be null."); } final VelocityContext context = new VelocityContext(); context.put("projectName", project.getName()); context.put("projectVersion", project.getVersion()); context.put("docs", documentation); try { context.put("cssDirectory", cssDirectory.toURI().toURL().toExternalForm()); } catch (final MalformedURLException e) { throw new MavenReportException("Failed to convert CSS directory to URL.", e); } final VelocityEngine engine = getEngine(); try { final Template template = engine.getTemplate("/velocity/script-doc-summary.vm", "utf-8"); template.merge(context, destination); } catch (final Exception e) { throw new MavenReportException("Failed to initialize and merge template.", e); } }
SummaryGenerator extends AbstractVelocityGenerator { public void generate(final MavenProject project, final List<Documentation> documentation, final File cssDirectory, final Writer destination) throws MavenReportException { if (project == null) { throw new IllegalArgumentException("Maven project cannot be null."); } if (documentation == null) { throw new IllegalArgumentException("Documentation cannot be null."); } if (cssDirectory == null) { throw new IllegalArgumentException("CSS directory cannot be null."); } if (destination == null) { throw new IllegalArgumentException("Destination writer cannot be null."); } final VelocityContext context = new VelocityContext(); context.put("projectName", project.getName()); context.put("projectVersion", project.getVersion()); context.put("docs", documentation); try { context.put("cssDirectory", cssDirectory.toURI().toURL().toExternalForm()); } catch (final MalformedURLException e) { throw new MavenReportException("Failed to convert CSS directory to URL.", e); } final VelocityEngine engine = getEngine(); try { final Template template = engine.getTemplate("/velocity/script-doc-summary.vm", "utf-8"); template.merge(context, destination); } catch (final Exception e) { throw new MavenReportException("Failed to initialize and merge template.", e); } } }
SummaryGenerator extends AbstractVelocityGenerator { public void generate(final MavenProject project, final List<Documentation> documentation, final File cssDirectory, final Writer destination) throws MavenReportException { if (project == null) { throw new IllegalArgumentException("Maven project cannot be null."); } if (documentation == null) { throw new IllegalArgumentException("Documentation cannot be null."); } if (cssDirectory == null) { throw new IllegalArgumentException("CSS directory cannot be null."); } if (destination == null) { throw new IllegalArgumentException("Destination writer cannot be null."); } final VelocityContext context = new VelocityContext(); context.put("projectName", project.getName()); context.put("projectVersion", project.getVersion()); context.put("docs", documentation); try { context.put("cssDirectory", cssDirectory.toURI().toURL().toExternalForm()); } catch (final MalformedURLException e) { throw new MavenReportException("Failed to convert CSS directory to URL.", e); } final VelocityEngine engine = getEngine(); try { final Template template = engine.getTemplate("/velocity/script-doc-summary.vm", "utf-8"); template.merge(context, destination); } catch (final Exception e) { throw new MavenReportException("Failed to initialize and merge template.", e); } }  }
SummaryGenerator extends AbstractVelocityGenerator { public void generate(final MavenProject project, final List<Documentation> documentation, final File cssDirectory, final Writer destination) throws MavenReportException { if (project == null) { throw new IllegalArgumentException("Maven project cannot be null."); } if (documentation == null) { throw new IllegalArgumentException("Documentation cannot be null."); } if (cssDirectory == null) { throw new IllegalArgumentException("CSS directory cannot be null."); } if (destination == null) { throw new IllegalArgumentException("Destination writer cannot be null."); } final VelocityContext context = new VelocityContext(); context.put("projectName", project.getName()); context.put("projectVersion", project.getVersion()); context.put("docs", documentation); try { context.put("cssDirectory", cssDirectory.toURI().toURL().toExternalForm()); } catch (final MalformedURLException e) { throw new MavenReportException("Failed to convert CSS directory to URL.", e); } final VelocityEngine engine = getEngine(); try { final Template template = engine.getTemplate("/velocity/script-doc-summary.vm", "utf-8"); template.merge(context, destination); } catch (final Exception e) { throw new MavenReportException("Failed to initialize and merge template.", e); } }  void generate(final MavenProject project, final List<Documentation> documentation, final File cssDirectory,
            final Writer destination); }
SummaryGenerator extends AbstractVelocityGenerator { public void generate(final MavenProject project, final List<Documentation> documentation, final File cssDirectory, final Writer destination) throws MavenReportException { if (project == null) { throw new IllegalArgumentException("Maven project cannot be null."); } if (documentation == null) { throw new IllegalArgumentException("Documentation cannot be null."); } if (cssDirectory == null) { throw new IllegalArgumentException("CSS directory cannot be null."); } if (destination == null) { throw new IllegalArgumentException("Destination writer cannot be null."); } final VelocityContext context = new VelocityContext(); context.put("projectName", project.getName()); context.put("projectVersion", project.getVersion()); context.put("docs", documentation); try { context.put("cssDirectory", cssDirectory.toURI().toURL().toExternalForm()); } catch (final MalformedURLException e) { throw new MavenReportException("Failed to convert CSS directory to URL.", e); } final VelocityEngine engine = getEngine(); try { final Template template = engine.getTemplate("/velocity/script-doc-summary.vm", "utf-8"); template.merge(context, destination); } catch (final Exception e) { throw new MavenReportException("Failed to initialize and merge template.", e); } }  void generate(final MavenProject project, final List<Documentation> documentation, final File cssDirectory,
            final Writer destination);  }