public FormTemplate createSampleTemplate(String title) throws Exception {
   String description = "This is a description";
   FieldSpecCollection topSection = StandardFieldSpecs.getDefaultTopSectionFieldSpecs();
   FieldSpecCollection bottomSection = StandardFieldSpecs.getDefaultBottomSectionFieldSpecs();
   FormTemplate template = new FormTemplate(title, description, topSection, bottomSection);
   return template;
 }
Пример #2
0
  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);
  }
Пример #3
0
  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));
  }
Пример #4
0
 public Bulletin(MartusCrypto securityToUse) throws Exception {
   this(
       securityToUse,
       StandardFieldSpecs.getDefaultTopSetionFieldSpecs(),
       StandardFieldSpecs.getDefaultBottomSectionFieldSpecs());
 }
Пример #5
0
  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());
  }