Exemplo n.º 1
0
  public void testTotalsInPageReport() throws Exception {
    MockMartusApp app = MockMartusApp.create();
    app.loadSampleData();

    ReportFormat rf = new ReportFormat();
    rf.setBulletinPerPage(true);
    rf.setTotalSection("Totals");

    RunReportOptions detailOnly = new RunReportOptions();
    detailOnly.hideDetail = false;
    detailOnly.printBreaks = false;
    ReportOutput details = runReportOnAppData(rf, app, detailOnly);
    assertEquals("", details.getPrintableDocument());

    RunReportOptions detailAndSummary = new RunReportOptions();
    detailAndSummary.hideDetail = false;
    detailAndSummary.printBreaks = true;
    ReportOutput both = runReportOnAppData(rf, app, detailAndSummary);
    assertEquals("Totals", both.getPrintableDocument());

    RunReportOptions summaryOnly = new RunReportOptions();
    summaryOnly.hideDetail = true;
    summaryOnly.printBreaks = true;
    ReportOutput summary = runReportOnAppData(rf, app, summaryOnly);
    assertEquals("Totals", summary.getPrintableDocument());
  }
Exemplo n.º 2
0
  public void testRunReport() throws Exception {
    MockMartusApp app = MockMartusApp.create();
    app.getLocalization().setCurrentLanguageCode(MiniLocalization.ENGLISH);
    app.loadSampleData();
    BulletinStore store = app.getStore();
    ReportFormat rf = new ReportFormat();
    rf.setDetailSection("$i. $bulletin.localId\n");
    ReportOutput result = new ReportOutput();
    Set leafUids = store.getAllBulletinLeafUids();
    SortableBulletinList list =
        new SortableBulletinList(app.getLocalization(), new MiniFieldSpec[0]);
    Iterator it = leafUids.iterator();
    while (it.hasNext()) {
      DatabaseKey key = DatabaseKey.createLegacyKey((UniversalId) it.next());
      list.add(BulletinLoader.loadFromDatabase(store.getDatabase(), key, app.getSecurity()));
    }

    RunReportOptions options = new RunReportOptions();
    rr.runReport(
        rf, store.getDatabase(), list, result, options, PoolOfReusableChoicesLists.EMPTY_POOL);
    result.close();
    StringBuffer expected = new StringBuffer();
    UniversalId[] uids = list.getSortedUniversalIds();
    for (int i = 0; i < uids.length; ++i) {
      expected.append(Integer.toString(i + 1));
      expected.append(". ");
      expected.append(uids[i].getLocalId());
      expected.append("\n");
    }
    assertEquals(new String(expected), result.getPageText(0));
  }
Exemplo n.º 3
0
 private ReportOutput runReportOnSampleData(ReportFormat rf) throws Exception {
   MockMartusApp app = MockMartusApp.create();
   app.loadSampleData();
   return runReportOnAppData(rf, app);
 }