private ReportOutput runReportOnAppData( ReportFormat rf, MockMartusApp app, RunReportOptions options) throws IOException, DamagedBulletinException, NoKeyPairException, Exception { MiniFieldSpec sortSpecs[] = { new MiniFieldSpec(StandardFieldSpecs.findStandardFieldSpec(Bulletin.TAGAUTHOR)), new MiniFieldSpec(StandardFieldSpecs.findStandardFieldSpec(Bulletin.TAGSUMMARY)), }; return runReportOnAppData(rf, app, options, sortSpecs); }
public void testBreakSection() throws Exception { String sampleDate = "2004-06-19"; MockMartusApp app = createAppWithBulletinsForBreaks(sampleDate); ReportFormat rf = new ReportFormat(); String breakSection = "$BreakLevel had $BreakCount\n" + "#foreach($x in [0..$BreakLevel])\n" + "$BreakFields.get($x).getLocalizedLabelHtml($localization): " + "$BreakFields.get($x).html($localization) " + "#end\n\n"; rf.setBreakSection(breakSection); RunReportOptions options = new RunReportOptions(); options.includePrivate = true; options.hideDetail = false; options.printBreaks = true; MiniLocalization localization = new MiniLocalization(); String authorLabel = localization.getFieldLabelHtml(Bulletin.TAGAUTHOR); String summaryLabel = localization.getFieldLabelHtml(Bulletin.TAGSUMMARY); ReportOutput sortByAuthorSummary = runReportOnAppData(rf, app, options); assertEquals( "1 had 2\n" + authorLabel + ": a " + summaryLabel + ": 1 \n" + "1 had 1\n" + authorLabel + ": a " + summaryLabel + ": 2 \n" + "0 had 3\n" + authorLabel + ": a \n" + "1 had 1\n" + authorLabel + ": b " + summaryLabel + ": 2 \n" + "0 had 1\n" + authorLabel + ": b \n", sortByAuthorSummary.getPageText(0)); MiniFieldSpec[] entryDateSorting = { new MiniFieldSpec(StandardFieldSpecs.findStandardFieldSpec(Bulletin.TAGENTRYDATE)), }; String entryDateLabel = localization.getFieldLabelHtml(Bulletin.TAGENTRYDATE); String formattedDate = localization.convertStoredDateToDisplay(sampleDate); ReportOutput sortedByEntryDate = runReportOnAppData(rf, app, options, entryDateSorting); assertEquals( "0 had 4\n" + entryDateLabel + ": " + formattedDate + " \n", sortedByEntryDate.getPageText(0)); options.printBreaks = false; assertEquals("Still had output?", "", runReportOnAppData(rf, app, options).getPageText(0)); }