MergedCsvReportRenderer implements ReportRenderer { protected static String prepareVal(Object val) { if (val == null) { return null; } String text = String.valueOf(val); return "\"" + text.replace("\"", "\\\"") + "\""; }  @Override boolean canRender(ReportDefinition definition); @Override Collection<RenderingMode> getRenderingModes(ReportDefinition definition); @Override String getRenderedContentType(ReportRequest request); @Override String getFilename(ReportRequest request); @Override void render(ReportData reportData, String argument, OutputStream out);  }
@Test public void prepareVal_shouldFormatValueForCsvInclusion() { Assert.assertThat(MergedCsvReportRenderer.prepareVal(123), is("\"123\"")); Assert.assertThat(MergedCsvReportRenderer.prepareVal("test"), is("\"test\"")); Assert.assertThat(MergedCsvReportRenderer.prepareVal("test \" "), is("\"test \\\" \"")); }