public void testOmitDetail() throws Exception {
    String sampleDate = "2004-06-19";
    MockMartusApp app = createAppWithBulletinsForBreaks(sampleDate);
    RunReportOptions options = new RunReportOptions();
    options.includePrivate = true;
    options.printBreaks = true;

    ReportFormat rf = new ReportFormat();
    rf.setDocumentStartSection("Start ");
    rf.setDetailSection("Detail ");
    rf.setBreakSection("Break ");
    rf.setHeaderSection("Header ");
    rf.setFooterSection("Footer ");
    rf.setTotalBreakSection("TotalBreak ");
    rf.setTotalSection("Total ");
    rf.setDocumentEndSection("End ");
    rf.setFakePageBreakSection(". ");

    ReportOutput sortByAuthorSummaryWithDetail = runReportOnAppData(rf, app, options);
    assertEquals(
        "Start Header Detail Detail Break Detail Break Break Detail Break Break TotalBreak Footer . End ",
        sortByAuthorSummaryWithDetail.getPrintableDocument());

    options.hideDetail = true;
    ReportOutput sortByAuthorSummaryWithoutDetail = runReportOnAppData(rf, app, options);
    assertEquals("Start Total . End ", sortByAuthorSummaryWithoutDetail.getPrintableDocument());

    rf.setBulletinPerPage(true);
    options.hideDetail = false;
    ReportOutput pageWithDetail = runReportOnAppData(rf, app, options);
    assertEquals(
        "Start Header Detail Footer . Header Detail Footer . Header Detail Footer . Header Detail Footer . Total . End ",
        pageWithDetail.getPrintableDocument());

    options.hideDetail = true;
    ReportOutput pageWithoutDetail = runReportOnAppData(rf, app, options);
    assertEquals("Start Total . End ", pageWithoutDetail.getPrintableDocument());
  }
  public void testPageReport() throws Exception {
    MockMartusApp app = MockMartusApp.create();
    FieldSpec[] topFields = {
      FieldSpec.createStandardField(Bulletin.TAGAUTHOR, new FieldTypeNormal()),
      FieldSpec.createCustomField("tag2", "Label 2", new FieldTypeDate()),
    };
    Bulletin b =
        new Bulletin(
            app.getSecurity(),
            new FieldSpecCollection(topFields),
            StandardFieldSpecs.getDefaultBottomSectionFieldSpecs());
    b.set(topFields[0].getTag(), "First");
    b.set(topFields[1].getTag(), "2005-04-07");
    b.set(Bulletin.TAGPRIVATEINFO, "Secret");
    app.saveBulletin(b, app.getFolderDraftOutbox());

    Bulletin b2 =
        new Bulletin(
            app.getSecurity(),
            new FieldSpecCollection(topFields),
            StandardFieldSpecs.getDefaultBottomSectionFieldSpecs());
    b2.set(topFields[0].getTag(), "Second");
    b2.set(topFields[1].getTag(), "2003-03-29");
    b2.set(Bulletin.TAGPRIVATEINFO, "Another secret");
    app.saveBulletin(b2, app.getFolderDraftOutbox());

    ReportFormat rf = new ReportFormat();
    rf.setBulletinPerPage(true);
    rf.setHeaderSection("Header\n");
    rf.setFooterSection("Footer\n");
    rf.setFakePageBreakSection("----\n");
    rf.setDetailSection(
        "TOP:\n"
            + "#foreach($field in $bulletin.getTopFields())\n"
            + "$field.getLocalizedLabel($localization) $field.html($localization)\n"
            + "#end\n"
            + "BOTTOM:\n"
            + "#foreach($field in $bulletin.getBottomFields())\n"
            + "$field.getLocalizedLabel($localization) $field.html($localization)\n"
            + "#end\n"
            + "");
    String expected0 =
        "Header\n"
            + "TOP:\n"
            + "<field:author> First\n"
            + "Label 2 04/07/2005\n"
            + "BOTTOM:\n"
            + "<field:privateinfo> Secret\n"
            + "Footer\n";
    String expected1 =
        "Header\n"
            + "TOP:\n"
            + "<field:author> Second\n"
            + "Label 2 03/29/2003\n"
            + "BOTTOM:\n"
            + "<field:privateinfo> Another secret\n"
            + "Footer\n";

    RunReportOptions options = new RunReportOptions();
    options.includePrivate = true;
    ReportOutput result = runReportOnAppData(rf, app, options);
    assertEquals("Wrong page report output?", expected0, result.getPageText(0));
    assertEquals("Wrong page report output?", expected1, result.getPageText(1));
    assertEquals("Didn't set fake page break?", "----\n", result.getFakePageBreak());
  }