@Test public void testFormat() throws Exception { final VelocityContext context = mock(VelocityContext.class); whenNew(VelocityContext.class).withNoArguments().thenReturn(context); final String formatted = "i am the formatted text"; final StringWriter writer = mock(StringWriter.class); when(writer.toString()).thenReturn(formatted); whenNew(StringWriter.class).withNoArguments().thenReturn(writer); final RecordInclude include = mock(RecordInclude.class); assertThat(formatter.format(include)).isEqualTo(formatted); verify(context).put("member", include); verify(template).merge(context, writer); }
@Override public String format(final RecordInclude member) throws MavenReportException { final VelocityContext context = new VelocityContext(); context.put("member", member); final StringWriter writer = new StringWriter(); try { template.merge(context, writer); } catch (final Exception e) { throw new MavenReportException("Failed to merge template for member " + member.getName(), e); } return writer.toString(); }
IncludeFormatter implements MemberFormatter<RecordInclude> { @Override public String format(final RecordInclude member) throws MavenReportException { final VelocityContext context = new VelocityContext(); context.put("member", member); final StringWriter writer = new StringWriter(); try { template.merge(context, writer); } catch (final Exception e) { throw new MavenReportException("Failed to merge template for member " + member.getName(), e); } return writer.toString(); } }
IncludeFormatter implements MemberFormatter<RecordInclude> { @Override public String format(final RecordInclude member) throws MavenReportException { final VelocityContext context = new VelocityContext(); context.put("member", member); final StringWriter writer = new StringWriter(); try { template.merge(context, writer); } catch (final Exception e) { throw new MavenReportException("Failed to merge template for member " + member.getName(), e); } return writer.toString(); } IncludeFormatter(final VelocityEngine engine); }
IncludeFormatter implements MemberFormatter<RecordInclude> { @Override public String format(final RecordInclude member) throws MavenReportException { final VelocityContext context = new VelocityContext(); context.put("member", member); final StringWriter writer = new StringWriter(); try { template.merge(context, writer); } catch (final Exception e) { throw new MavenReportException("Failed to merge template for member " + member.getName(), e); } return writer.toString(); } IncludeFormatter(final VelocityEngine engine); @Override String format(final RecordInclude member); }
IncludeFormatter implements MemberFormatter<RecordInclude> { @Override public String format(final RecordInclude member) throws MavenReportException { final VelocityContext context = new VelocityContext(); context.put("member", member); final StringWriter writer = new StringWriter(); try { template.merge(context, writer); } catch (final Exception e) { throw new MavenReportException("Failed to merge template for member " + member.getName(), e); } return writer.toString(); } IncludeFormatter(final VelocityEngine engine); @Override String format(final RecordInclude member);  }