Пример #1
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));
  }
Пример #2
0
 private ReportOutput runReportOnAppData(
     ReportFormat rf, MockMartusApp app, RunReportOptions options, MiniFieldSpec[] sortSpecs)
     throws IOException, DamagedBulletinException, NoKeyPairException, Exception {
   BulletinStore store = app.getStore();
   MartusCrypto security = app.getSecurity();
   ReadableDatabase db = store.getDatabase();
   Set leafUids = store.getAllBulletinLeafUids();
   MiniLocalization localization = new MiniLocalization();
   localization.setCurrentLanguageCode(MiniLocalization.ENGLISH);
   SortableBulletinList list = new SortableBulletinList(localization, sortSpecs);
   Iterator it = leafUids.iterator();
   while (it.hasNext()) {
     DatabaseKey key = DatabaseKey.createLegacyKey((UniversalId) it.next());
     Bulletin b = BulletinLoader.loadFromDatabase(db, key, security);
     list.add(b);
   }
   ReportOutput result = new ReportOutput();
   rr.runReport(
       rf, store.getDatabase(), list, result, options, PoolOfReusableChoicesLists.EMPTY_POOL);
   result.close();
   return result;
 }