コード例 #1
0
ファイル: ReportManagerTest.java プロジェクト: philsawa/sakai
  public void testReportsFromOverviewPage() {
    M_sum.collectEvents(getSampleData2());

    // MiniStatsVisits & MiniStatUniqueVisits
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      rp.setWhat(ReportManager.WHAT_VISITS_TOTALS);
      rp.setWhen(ReportManager.WHEN_ALL);
      rp.setWho(ReportManager.WHO_ALL);
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_DATE);
      totalsBy.add(StatsManager.T_VISITS);
      totalsBy.add(StatsManager.T_UNIQUEVISITS);
      rp.setHowTotalsBy(totalsBy);
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_DATE);
      rp.setHowSortAscending(false);
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_BOTH);
      rp.setHowChartType(StatsManager.CHARTTYPE_TIMESERIESBAR);
      rp.setHowChartSource(StatsManager.T_DATE);
      rp.setHowChartSeriesSource(StatsManager.T_NONE);
      rp.setHowChartSeriesPeriod(StatsManager.CHARTTIMESERIES_DAY);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(5, rep.getReportData().size());
    }

    // MiniStatEnrolledUsersWithVisits
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      rp.setWhat(ReportManager.WHAT_VISITS);
      rp.setWhen(ReportManager.WHEN_ALL);
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_USER);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(false);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(2, rep.getReportData().size());
    }

    // MiniStatEnrolledUsersWithoutVisits
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      rp.setWhat(ReportManager.WHAT_VISITS);
      rp.setWhen(ReportManager.WHEN_ALL);
      rp.setWho(ReportManager.WHO_NONE);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_USER);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(false);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(0, rep.getReportData().size());
    }

    // MiniStatActivityEvents
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      // what
      rp.setWhat(ReportManager.WHAT_EVENTS);
      rp.setWhatEventSelType(ReportManager.WHAT_EVENTS_BYEVENTS);
      rp.setWhatEventIds(new ArrayList<String>(M_ers.getEventIds()));
      // when
      rp.setWhen(ReportManager.WHEN_ALL);
      // who
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_EVENT);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_EVENT);
      rp.setHowSortAscending(true);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(6, rep.getReportData().size());
    }

    // MiniStatMostActiveUser
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      // what
      rp.setWhat(ReportManager.WHAT_EVENTS);
      rp.setWhatEventSelType(ReportManager.WHAT_EVENTS_BYEVENTS);
      rp.setWhatEventIds(new ArrayList<String>(M_ers.getEventIds()));
      // when
      rp.setWhen(ReportManager.WHEN_ALL);
      // who
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_USER);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_TOTAL);
      rp.setHowSortAscending(false);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(3, rep.getReportData().size());
    }

    // MiniStatFiles (files with new event)
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      // what
      rp.setWhat(ReportManager.WHAT_RESOURCES);
      rp.setWhatLimitedAction(true);
      rp.setWhatResourceAction(ReportManager.WHAT_RESOURCES_ACTION_NEW);
      rp.setWhatLimitedResourceIds(true);
      rp.setWhatResourceIds(Arrays.asList(StatsManager.RESOURCES_DIR + FakeData.SITE_A_ID + "/"));
      // when
      rp.setWhen(ReportManager.WHEN_ALL);
      // who
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_RESOURCE);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_RESOURCE);
      rp.setHowSortAscending(true);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(2, rep.getReportData().size());
    }

    // MiniStatOpenedFiles (files with read event)
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      // what
      rp.setWhat(ReportManager.WHAT_RESOURCES);
      rp.setWhatLimitedAction(true);
      rp.setWhatResourceAction(ReportManager.WHAT_RESOURCES_ACTION_READ);
      rp.setWhatLimitedResourceIds(true);
      rp.setWhatResourceIds(Arrays.asList(StatsManager.RESOURCES_DIR + FakeData.SITE_A_ID + "/"));
      // when
      rp.setWhen(ReportManager.WHEN_ALL);
      // who
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_RESOURCE);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_TOTAL);
      rp.setHowSortAscending(false);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(2, rep.getReportData().size());
    }

    // MiniStatUserThatOpenedMoreFiles
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      // what
      rp.setWhat(ReportManager.WHAT_RESOURCES);
      rp.setWhatLimitedAction(true);
      rp.setWhatResourceAction(ReportManager.WHAT_RESOURCES_ACTION_READ);
      rp.setWhatLimitedResourceIds(true);
      rp.setWhatResourceIds(Arrays.asList(StatsManager.RESOURCES_DIR + FakeData.SITE_A_ID + "/"));
      // when
      rp.setWhen(ReportManager.WHEN_ALL);
      // who
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_USER);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_TOTAL);
      rp.setHowSortAscending(false);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(2, rep.getReportData().size());
    }
  }
コード例 #2
0
ファイル: ReportManagerTest.java プロジェクト: philsawa/sakai
  public void testGetMoreReports() {
    M_sum.collectEvents(getSampleData());
    String siteId = null;
    Report r = null;
    ReportDef rd = null;
    ReportParams rp = null;
    List<String> totalsBy = null;

    // resources
    siteId = FakeData.SITE_A_ID;
    rd = new ReportDef();
    rd.setId(0);
    rd.setSiteId(siteId);
    rp = new ReportParams(siteId);
    rp.setWhat(ReportManager.WHAT_RESOURCES);
    rp.setWhen(ReportManager.WHEN_ALL);
    rp.setWho(ReportManager.WHO_ALL);
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_SITE);
    totalsBy.add(StatsManager.T_USER);
    rp.setHowTotalsBy(totalsBy);
    rp.setHowSort(false);
    rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
    rd.setReportParams(rp);
    r = M_rm.getReport(rd, true, null, false);
    checkCollumns(rd.getReportParams());
    assertEquals(1, r.getReportData().size());

    // visits
    rp.setWhat(ReportManager.WHAT_VISITS);
    r = M_rm.getReport(rd, true, null, true);
    checkCollumns(rd.getReportParams());
    assertEquals(2, r.getReportData().size());

    // visits totals
    rp.setWhat(ReportManager.WHAT_VISITS_TOTALS);
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_SITE);
    rp.setHowTotalsBy(totalsBy);
    rd.setId(1);
    r = M_rm.getReport(rd, true, new PagingPosition(0, 5), true);
    assertEquals(1, r.getReportData().size());
    assertEquals(9, ((SiteVisits) (r.getReportData().get(0))).getTotalVisits());
    assertEquals(7, ((SiteVisits) (r.getReportData().get(0))).getTotalUnique());

    //		// activity totals
    //		rp.setWhat(ReportManager.WHAT_ACTIVITY_TOTALS);
    //		rp.setWhatEventIds(FakeData.EVENTIDS);
    //		rp.setWhen(ReportManager.WHEN_LAST365DAYS);
    //		r = M_rm.getReport(rd, false, null, false);
    //		System.out.println(r.getReportData());
    //		System.out.println("ReportParams: "+ rp);
    //		System.out.println("ReportData: "+ r.getReportData());
    //		assertEquals(1, r.getReportData().size());
    //		assertEquals(1, r.getReportData().get(0).getCount());

    // presences I
    rp.setWhat(ReportManager.WHAT_PRESENCES);
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_SITE);
    totalsBy.add(StatsManager.T_USER);
    totalsBy.add(StatsManager.T_DATE);
    rp.setHowTotalsBy(totalsBy);
    rp.setHowSort(false);
    r = M_rm.getReport(rd, true, null, true);
    checkCollumns(rd.getReportParams());
    assertEquals(7, r.getReportData().size());

    // presences II
    rp.setWhat(ReportManager.WHAT_PRESENCES);
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_SITE);
    totalsBy.add(StatsManager.T_DATE);
    rp.setHowTotalsBy(totalsBy);
    rp.setHowSort(false);
    r = M_rm.getReport(rd, true, null, true);
    checkCollumns(rd.getReportParams());
    assertEquals(5, r.getReportData().size());

    // presences III
    rp.setWhat(ReportManager.WHAT_PRESENCES);
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_SITE);
    rp.setHowTotalsBy(totalsBy);
    rp.setHowSort(false);
    r = M_rm.getReport(rd, true, null, true);
    checkCollumns(rd.getReportParams());
    assertEquals(1, r.getReportData().size());
  }
コード例 #3
0
ファイル: ReportManagerTest.java プロジェクト: philsawa/sakai
  private List<Event> getSampleData2() {
    List<Event> samples = new ArrayList<Event>();
    Date today = new Date();
    Date oneDayBefore = new Date(today.getTime() - 24 * 60 * 60 * 1000);
    Date twoDaysBefore = new Date(today.getTime() - 2 * 24 * 60 * 60 * 1000);
    Date fourDaysBefore = new Date(today.getTime() - 4 * 24 * 60 * 60 * 1000);
    Date sixDaysBefore = new Date(today.getTime() - 6 * 24 * 60 * 60 * 1000);
    // visits
    Event vAToday =
        M_sum.buildEvent(
            today,
            StatsManager.SITEVISIT_EVENTID,
            "/presence/" + FakeData.SITE_A_ID + "-presence",
            null,
            FakeData.USER_A_ID,
            "session-id-a");
    Event vBToday =
        M_sum.buildEvent(
            today,
            StatsManager.SITEVISIT_EVENTID,
            "/presence/" + FakeData.SITE_A_ID + "-presence",
            null,
            FakeData.USER_B_ID,
            "session-id-b");
    Event vAOneDayBefore =
        M_sum.buildEvent(
            oneDayBefore,
            StatsManager.SITEVISIT_EVENTID,
            "/presence/" + FakeData.SITE_A_ID + "-presence",
            null,
            FakeData.USER_A_ID,
            "session-id-a");
    Event vATowDaysBefore =
        M_sum.buildEvent(
            twoDaysBefore,
            StatsManager.SITEVISIT_EVENTID,
            "/presence/" + FakeData.SITE_A_ID + "-presence",
            null,
            FakeData.USER_A_ID,
            "session-id-a");
    Event vAFourDaysBefore =
        M_sum.buildEvent(
            fourDaysBefore,
            StatsManager.SITEVISIT_EVENTID,
            "/presence/" + FakeData.SITE_A_ID + "-presence",
            null,
            FakeData.USER_A_ID,
            "session-id-a");
    Event vBFourDaysBefore =
        M_sum.buildEvent(
            fourDaysBefore,
            StatsManager.SITEVISIT_EVENTID,
            "/presence/" + FakeData.SITE_A_ID + "-presence",
            null,
            FakeData.USER_B_ID,
            "session-id-b");
    Event vBSixDaysBefore =
        M_sum.buildEvent(
            sixDaysBefore,
            StatsManager.SITEVISIT_EVENTID,
            "/presence/" + FakeData.SITE_A_ID + "-presence",
            null,
            FakeData.USER_B_ID,
            "session-id-b");
    samples.addAll(
        Arrays.asList(
            vAToday,
            vAToday,
            vBToday, // today:			3 visits, 2 unique
            vAOneDayBefore, // 1 day before:	1 visits, 1 unique
            vATowDaysBefore,
            vATowDaysBefore, // 2 day before:	2 visits, 1 unique
            vAFourDaysBefore,
            vBFourDaysBefore, // 4 day before:	2 visits, 2 unique
            vBSixDaysBefore // 6 day before:	1 visits, 1 unique
            ));
    // activity
    Event aAToday =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CHATNEW,
            "/chat/msg/" + FakeData.SITE_B_ID,
            FakeData.SITE_B_ID,
            FakeData.USER_A_ID,
            "session-id-a");
    Event aBToday =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTNEW,
            "/content/group/" + FakeData.SITE_B_ID + "/resource_id",
            FakeData.SITE_B_ID,
            FakeData.USER_B_ID,
            "session-id-b");
    Event aAOneDayBefore =
        M_sum.buildEvent(
            oneDayBefore,
            FakeData.EVENT_CHATNEW,
            "/chat/msg/" + FakeData.SITE_A_ID,
            FakeData.SITE_A_ID,
            FakeData.USER_A_ID,
            "session-id-a");
    Event aATowDaysBefore =
        M_sum.buildEvent(
            twoDaysBefore,
            FakeData.EVENT_CHATNEW,
            "/chat/msg/" + FakeData.SITE_A_ID,
            FakeData.SITE_A_ID,
            FakeData.USER_A_ID,
            "session-id-a");
    Event aAFourDaysBefore =
        M_sum.buildEvent(
            fourDaysBefore,
            FakeData.EVENT_CHATNEW,
            "/chat/msg/" + FakeData.SITE_A_ID,
            FakeData.SITE_A_ID,
            FakeData.USER_A_ID,
            "session-id-a");
    Event aBFourDaysBefore =
        M_sum.buildEvent(
            fourDaysBefore,
            FakeData.EVENT_CHATNEW,
            "/chat/msg/" + FakeData.SITE_A_ID,
            FakeData.SITE_A_ID,
            FakeData.USER_B_ID,
            "session-id-b");
    Event aBSixDaysBefore =
        M_sum.buildEvent(
            sixDaysBefore,
            FakeData.EVENT_CONTENTREV,
            "/content/group/" + FakeData.SITE_A_ID + "/resource_id",
            FakeData.SITE_A_ID,
            FakeData.USER_B_ID,
            "session-id-b");
    samples.addAll(
        Arrays.asList(
            aAToday,
            aBToday, // today:			2 (1 chat + 1 content)
            aAOneDayBefore, // 1 day before:	1 (1 chat)
            aATowDaysBefore,
            aATowDaysBefore, // 2 day before:	2 (2 chat)
            aAFourDaysBefore,
            aBFourDaysBefore, // 4 day before:	2 (2 chat)
            aBSixDaysBefore // 6 day before:	1 (1 chat)
            ));
    // resources
    Event r1 =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTNEW,
            "/content/group/" + FakeData.SITE_A_ID + "/resource_id1",
            FakeData.SITE_A_ID,
            FakeData.USER_A_ID,
            "session-id-a");
    Event r1a =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTREAD,
            "/content/group/" + FakeData.SITE_A_ID + "/resource_id1",
            FakeData.SITE_A_ID,
            FakeData.USER_A_ID,
            "session-id-a");
    Event r1b =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTREAD,
            "/content/group/" + FakeData.SITE_A_ID + "/resource_id1",
            FakeData.SITE_A_ID,
            FakeData.USER_B_ID,
            "session-id-b");
    Event r1c =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTREAD,
            "/content/group/" + FakeData.SITE_A_ID + "/resource_id1",
            FakeData.SITE_A_ID,
            FakeData.USER_B_ID,
            "session-id-b");
    Event r2 =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTNEW,
            "/content/group/" + FakeData.SITE_A_ID + "/resource_id2",
            FakeData.SITE_A_ID,
            FakeData.USER_B_ID,
            "session-id-b");
    Event r2a =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTREAD,
            "/content/group/" + FakeData.SITE_A_ID + "/resource_id2",
            FakeData.SITE_A_ID,
            FakeData.USER_A_ID,
            "session-id-a");
    Event r2b =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTREAD,
            "/content/group/" + FakeData.SITE_A_ID + "/resource_id2",
            FakeData.SITE_A_ID,
            FakeData.USER_A_ID,
            "session-id-a");
    Event r3 =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTDEL,
            "/content/group/" + FakeData.SITE_A_ID + "/resource_id2",
            FakeData.SITE_A_ID,
            FakeData.USER_B_ID,
            "session-id-b");
    Event r4 =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTNEW,
            "/content/group/" + FakeData.SITE_B_ID + "/resource_id2",
            FakeData.SITE_B_ID,
            FakeData.USER_A_ID,
            "session-id-a");
    // resources: attachment
    Event r5 =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTNEW,
            FakeData.RES_ATTACH,
            FakeData.SITE_A_ID,
            FakeData.USER_A_ID,
            "session-id-a");
    // resources: dropbox
    Event r6 =
        M_sum.buildEvent(
            today,
            FakeData.EVENT_CONTENTNEW,
            FakeData.RES_DROPBOX_SITE_A_USER_A_FILE,
            FakeData.SITE_A_ID,
            FakeData.USER_A_ID,
            "session-id-a");

    samples.addAll(Arrays.asList(r1, r1a, r1b, r1c, r2, r2a, r2b, r3, r4, r5, r6));
    return samples;
  }
コード例 #4
0
ファイル: ReportManagerTest.java プロジェクト: philsawa/sakai
  // ---- TESTS ----
  public void testGetReport() {
    M_sum.collectEvents(getSampleData());
    String siteId = null;
    Report r = null;
    ReportDef rd = null;
    ReportParams rp = null;
    List<String> totalsBy = null;

    // #1 getReport(ReportDef reportDef, boolean restrictToToolsInSite)
    siteId = FakeData.SITE_B_ID;
    rd = new ReportDef();
    rd.setId(0);
    rd.setSiteId(siteId);
    rp = new ReportParams(siteId);
    rp.setWhat(ReportManager.WHAT_EVENTS);
    rp.setWhatEventSelType(ReportManager.WHAT_EVENTS_BYTOOL);
    rp.setWhatToolIds(Arrays.asList(ReportManager.WHAT_EVENTS_ALLTOOLS));
    rp.setWhen(ReportManager.WHEN_ALL);
    rp.setWho(ReportManager.WHO_ALL);
    // grouping
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_TOOL);
    totalsBy.add(StatsManager.T_DATE);
    rp.setHowTotalsBy(totalsBy);
    // sorting
    rp.setHowSort(true);
    rp.setHowSortBy(StatsManager.T_TOOL);
    rp.setHowSortAscending(false);
    // chart
    rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_BOTH);
    rp.setHowChartType(StatsManager.CHARTTYPE_TIMESERIESBAR);
    rp.setHowChartSource(StatsManager.T_DATE);
    rp.setHowChartSeriesSource(StatsManager.T_NONE);
    rp.setHowChartSeriesPeriod(StatsManager.CHARTTIMESERIES_DAY);
    rd.setReportParams(rp);
    r = M_rm.getReport(rd, true);
    checkCollumns(rd.getReportParams());
    assertEquals(1, r.getReportData().size());
    r = M_rm.getReport(rd, false);
    checkCollumns(rd.getReportParams());
    assertEquals(2, r.getReportData().size());
    assertNotNull(M_rm.getReportFormattedParams());

    // #2 getReportRowCount(ReportDef reportDef, boolean restrictToToolsInSite)
    assertEquals(1, M_rm.getReportRowCount(rd, true));
    assertEquals(2, M_rm.getReportRowCount(rd, false));

    siteId = FakeData.SITE_B_ID;
    rd = new ReportDef();
    rd.setId(0);
    rd.setSiteId(siteId);
    rp = new ReportParams(siteId);
    rp.setWhat(ReportManager.WHAT_RESOURCES);
    rp.setWhen(ReportManager.WHEN_ALL);
    rp.setWho(ReportManager.WHO_ALL);
    // grouping
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_RESOURCE);
    totalsBy.add(StatsManager.T_DATE);
    rp.setHowTotalsBy(totalsBy);
    // sorting
    rp.setHowSort(true);
    rp.setHowSortBy(StatsManager.T_TOOL);
    rp.setHowSortAscending(false);
    // chart
    rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
    rd.setReportParams(rp);
    assertEquals(1, M_rm.getReportRowCount(rd, true));
    assertEquals(1, M_rm.getReportRowCount(rd, false));
  }
コード例 #5
0
ファイル: ReportManagerTest.java プロジェクト: philsawa/sakai
 private List<Event> getSampleData() {
   List<Event> samples = new ArrayList<Event>();
   Date today = new Date();
   Date today_2 = new Date(today.getTime() + 60 * 1000);
   Date today_3 = new Date(today.getTime() + 2 * 60 * 1000);
   Date today_4 = new Date(today.getTime() + 3 * 60 * 1000);
   Date oneDayBefore = new Date(today.getTime() - 24 * 60 * 60 * 1000);
   Date oneDayBefore_2 = new Date(today.getTime() - 24 * 60 * 60 * 1000 + 60 * 1000);
   Date oneDayBefore_3 = new Date(today.getTime() - 24 * 60 * 60 * 1000 + 2 * 60 * 1000);
   Date oneDayBefore_4 = new Date(today.getTime() - 24 * 60 * 60 * 1000 + 3 * 60 * 1000);
   Date twoDaysBefore = new Date(today.getTime() - 2 * 24 * 60 * 60 * 1000);
   Date twoDaysBefore_2 = new Date(today.getTime() - 2 * 24 * 60 * 60 * 1000 + 60 * 1000);
   Date fourDaysBefore = new Date(today.getTime() - 4 * 24 * 60 * 60 * 1000);
   Date fourDaysBefore_2 = new Date(today.getTime() - 4 * 24 * 60 * 60 * 1000 + 60 * 1000);
   Date sixDaysBefore = new Date(today.getTime() - 6 * 24 * 60 * 60 * 1000);
   Date sixDaysBefore_2 = new Date(today.getTime() - 6 * 24 * 60 * 60 * 1000 + 60 * 1000);
   // visits
   Event vATodayS1 =
       M_sum.buildEvent(
           today,
           StatsManager.SITEVISIT_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_A_ID,
           "session-id-a");
   Event vATodayE1 =
       M_sum.buildEvent(
           today_2,
           StatsManager.SITEVISITEND_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_A_ID,
           "session-id-a");
   Event vATodayS2 =
       M_sum.buildEvent(
           today_3,
           StatsManager.SITEVISIT_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_A_ID,
           "session-id-a");
   Event vATodayE2 =
       M_sum.buildEvent(
           today_4,
           StatsManager.SITEVISITEND_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_A_ID,
           "session-id-a");
   Event vBTodayS1 =
       M_sum.buildEvent(
           today,
           StatsManager.SITEVISIT_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_B_ID,
           "session-id-b");
   Event vBTodayE1 =
       M_sum.buildEvent(
           today_3,
           StatsManager.SITEVISITEND_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_B_ID,
           "session-id-b");
   Event vAOneDayBefore =
       M_sum.buildEvent(
           oneDayBefore,
           StatsManager.SITEVISIT_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_A_ID,
           "session-id-a");
   Event vATowDaysBefore =
       M_sum.buildEvent(
           twoDaysBefore,
           StatsManager.SITEVISIT_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_A_ID,
           "session-id-a");
   Event vAFourDaysBefore =
       M_sum.buildEvent(
           fourDaysBefore,
           StatsManager.SITEVISIT_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_A_ID,
           "session-id-a");
   Event vBFourDaysBefore =
       M_sum.buildEvent(
           fourDaysBefore,
           StatsManager.SITEVISIT_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_B_ID,
           "session-id-b");
   Event vBSixDaysBefore =
       M_sum.buildEvent(
           sixDaysBefore,
           StatsManager.SITEVISIT_EVENTID,
           "/presence/" + FakeData.SITE_A_ID + "-presence",
           null,
           FakeData.USER_B_ID,
           "session-id-b");
   samples.addAll(
       Arrays.asList(
           vATodayS1,
           vATodayE1,
           vATodayS2,
           vATodayE2,
           vBTodayS1,
           vBTodayE1, // today:			3 visits, 2 unique
           vAOneDayBefore, // 1 day before:	1 visits, 1 unique
           vATowDaysBefore,
           vATowDaysBefore, // 2 day before:	2 visits, 1 unique
           vAFourDaysBefore,
           vBFourDaysBefore, // 4 day before:	2 visits, 2 unique
           vBSixDaysBefore // 6 day before:	1 visits, 1 unique
           ));
   // activity
   Event aAToday =
       M_sum.buildEvent(
           today,
           FakeData.EVENT_CHATNEW,
           "/chat/msg/" + FakeData.SITE_B_ID,
           FakeData.SITE_B_ID,
           FakeData.USER_A_ID,
           "session-id-a");
   Event aBToday =
       M_sum.buildEvent(
           today,
           FakeData.EVENT_CONTENTNEW,
           "/content/group/" + FakeData.SITE_B_ID + "/resource_id",
           FakeData.SITE_B_ID,
           FakeData.USER_B_ID,
           "session-id-b");
   Event aAOneDayBefore =
       M_sum.buildEvent(
           oneDayBefore,
           FakeData.EVENT_CHATNEW,
           "/chat/msg/" + FakeData.SITE_A_ID,
           FakeData.SITE_A_ID,
           FakeData.USER_A_ID,
           "session-id-a");
   Event aATowDaysBefore =
       M_sum.buildEvent(
           twoDaysBefore,
           FakeData.EVENT_CHATNEW,
           "/chat/msg/" + FakeData.SITE_A_ID,
           FakeData.SITE_A_ID,
           FakeData.USER_A_ID,
           "session-id-a");
   Event aAFourDaysBefore =
       M_sum.buildEvent(
           fourDaysBefore,
           FakeData.EVENT_CHATNEW,
           "/chat/msg/" + FakeData.SITE_A_ID,
           FakeData.SITE_A_ID,
           FakeData.USER_A_ID,
           "session-id-a");
   Event aBFourDaysBefore =
       M_sum.buildEvent(
           fourDaysBefore,
           FakeData.EVENT_CHATNEW,
           "/chat/msg/" + FakeData.SITE_A_ID,
           FakeData.SITE_A_ID,
           FakeData.USER_B_ID,
           "session-id-b");
   Event aBSixDaysBefore =
       M_sum.buildEvent(
           sixDaysBefore,
           FakeData.EVENT_CONTENTREV,
           "/content/group/" + FakeData.SITE_A_ID + "/resource_id",
           FakeData.SITE_A_ID,
           FakeData.USER_B_ID,
           "session-id-b");
   samples.addAll(
       Arrays.asList(
           aAToday,
           aBToday, // today:			2 (1 chat + 1 content)
           aAOneDayBefore, // 1 day before:	1 (1 chat)
           aATowDaysBefore,
           aATowDaysBefore, // 2 day before:	2 (2 chat)
           aAFourDaysBefore,
           aBFourDaysBefore, // 4 day before:	2 (2 chat)
           aBSixDaysBefore // 6 day before:	1 (1 chat)
           ));
   return samples;
 }