Search in sources :

Example 1 with AdminActivityLogPageAction

use of teammates.ui.controller.AdminActivityLogPageAction in project teammates by TEAMMATES.

the class AdminActivityLogPageActionTest method verifyActionResult.

private void verifyActionResult(int[][] expectedLogs, String... params) {
    AdminActivityLogPageAction action = getAction(params);
    ShowPageResult result = getShowPageResult(action);
    AdminActivityLogPageData pageData = (AdminActivityLogPageData) result.data;
    List<ActivityLogEntry> actualLogs = getLogsFromLogTemplateRows(pageData.getLogs());
    verifyLogs(expectedLogs, actualLogs);
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) ActivityLogEntry(teammates.common.util.ActivityLogEntry) AdminActivityLogPageAction(teammates.ui.controller.AdminActivityLogPageAction) AdminActivityLogPageData(teammates.ui.pagedata.AdminActivityLogPageData)

Example 2 with AdminActivityLogPageAction

use of teammates.ui.controller.AdminActivityLogPageAction in project teammates by TEAMMATES.

the class AdminActivityLogPageActionTest method statusMessage_validQuery_generatedCorrectly.

@Test(groups = "typicalActivityLogs")
public void statusMessage_validQuery_generatedCorrectly() {
    // test statusMessage for default search
    AdminActivityLogPageAction action = getAction();
    String statusMessage = getShowPageResult(action).getStatusMessage();
    verifyStatusMessage(statusMessage, 11, 5, YESTERDAY);
    verifyLocalTimeInStatusMessage(statusMessage, YESTERDAY, Const.SystemParams.ADMIN_TIME_ZONE_ID);
    // test statusMessage with filterQuery
    String query = "person:idOfInstructor1OfCourse1";
    action = getAction("filterQuery", query);
    statusMessage = getShowPageResult(action).getStatusMessage();
    verifyStatusMessage(statusMessage, 11, 1, YESTERDAY);
    // test statusMessage with `to`
    query = "to:" + formatAdminDate(YESTERDAY);
    action = getAction("filterQuery", query);
    Instant toDate = getEndOfTheDayOffsetNowInAdminTimeZone(-2);
    statusMessage = getShowPageResult(action).getStatusMessage();
    verifyStatusMessage(statusMessage, 6, 3, toDate);
    verifyLocalTimeInStatusMessage(statusMessage, toDate, Const.SystemParams.ADMIN_TIME_ZONE_ID);
    // test statusMessage with `from`
    query = "from:" + formatAdminDate(YESTERDAY);
    action = getAction("filterQuery", query);
    Instant fromDate = getBeginOfTheDayOffsetNowInAdminTimeZone(-1);
    statusMessage = getShowPageResult(action).getStatusMessage();
    verifyStatusMessage(statusMessage, 17, 8, fromDate);
    verifyLocalTimeInStatusMessage(statusMessage, fromDate, Const.SystemParams.ADMIN_TIME_ZONE_ID);
}
Also used : AdminActivityLogPageAction(teammates.ui.controller.AdminActivityLogPageAction) Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 3 with AdminActivityLogPageAction

use of teammates.ui.controller.AdminActivityLogPageAction in project teammates by TEAMMATES.

the class AdminActivityLogPageActionTest method verifyContinueSearch.

private void verifyContinueSearch(String[] params, int[][] expected, int totalLogs, int filteredLogs, Instant earliestDateInUtc) {
    AdminActivityLogPageAction action = getAction(params);
    ShowPageResult result = getShowPageResult(action);
    AdminActivityLogPageData pageData = (AdminActivityLogPageData) result.data;
    verifyStatusMessage(result.getStatusMessage(), totalLogs, filteredLogs, earliestDateInUtc);
    verifyLogs(expected, getLogsFromLogTemplateRows(pageData.getLogs()));
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) AdminActivityLogPageAction(teammates.ui.controller.AdminActivityLogPageAction) AdminActivityLogPageData(teammates.ui.pagedata.AdminActivityLogPageData)

Example 4 with AdminActivityLogPageAction

use of teammates.ui.controller.AdminActivityLogPageAction in project teammates by TEAMMATES.

the class AdminActivityLogPageActionTest method verifyLoadingLocalTimeAjaxResult.

private void verifyLoadingLocalTimeAjaxResult(String expected, String role, String googleId, long timeInMillis) {
    String[] params = new String[] { "logRole", role, "logGoogleId", googleId, "logUnixTimeMillis", String.valueOf(timeInMillis) };
    AdminActivityLogPageAction action = getAction(params);
    AjaxResult result = getAjaxResult(action);
    AdminActivityLogPageData pageData = (AdminActivityLogPageData) result.data;
    assertEquals(expected, pageData.getLogLocalTime());
}
Also used : AjaxResult(teammates.ui.controller.AjaxResult) AdminActivityLogPageAction(teammates.ui.controller.AdminActivityLogPageAction) AdminActivityLogPageData(teammates.ui.pagedata.AdminActivityLogPageData)

Example 5 with AdminActivityLogPageAction

use of teammates.ui.controller.AdminActivityLogPageAction in project teammates by TEAMMATES.

the class AdminActivityLogPageActionTest method statusMessageAndContinueSearch_withManyLogs_searchCorrectly.

// The two test groups should have different 'priority' so that they can run separately
// as they depend on different sets of log messages
@Test(groups = "manyActivityLogs", priority = 2)
public void statusMessageAndContinueSearch_withManyLogs_searchCorrectly() {
    Instant now = Instant.now();
    // default search will stop at #logs around 50
    AdminActivityLogPageAction action = getAction();
    ShowPageResult result = getShowPageResult(action);
    Instant earliestDateInUtc = now.minusMillis(54 * LOG_MESSAGE_INTERVAL_MANY_LOGS * 1000);
    verifyManyLogs(55, 0, 54, result.data, result.getStatusMessage(), earliestDateInUtc);
    // continue search will get next #logs around 50
    long nextSearch = now.toEpochMilli() - 56 * LOG_MESSAGE_INTERVAL_MANY_LOGS * 1000;
    action = getAction("searchTimeOffset", String.valueOf(nextSearch));
    result = getShowPageResult(action);
    earliestDateInUtc = now.minusMillis(110 * LOG_MESSAGE_INTERVAL_MANY_LOGS * 1000);
    verifyManyLogs(56, 55, 110, result.data, result.getStatusMessage(), earliestDateInUtc);
    // continue search will get logs until no logs
    nextSearch = now.toEpochMilli() - 112 * LOG_MESSAGE_INTERVAL_MANY_LOGS * 1000;
    action = getAction("searchTimeOffset", String.valueOf(nextSearch));
    result = getShowPageResult(action);
    earliestDateInUtc = Instant.ofEpochMilli(nextSearch - 24 * 60 * 60 * 1000);
    verifyManyLogs(39, 111, 149, result.data, result.getStatusMessage(), earliestDateInUtc);
    // default search with filter stop at #logs around 50
    action = getAction("filterQuery", "request:testdata1");
    result = getShowPageResult(action);
    earliestDateInUtc = now.minusMillis(54 * LOG_MESSAGE_INTERVAL_MANY_LOGS * 1000);
    verifyManyLogs(55, 0, 54, result.data, result.getStatusMessage(), earliestDateInUtc);
    // continue search with filter will get logs until no logs
    nextSearch = now.toEpochMilli() - 56 * LOG_MESSAGE_INTERVAL_MANY_LOGS * 1000;
    action = getAction("filterQuery", "request:testdata1", "searchTimeOffset", String.valueOf(nextSearch));
    result = getShowPageResult(action);
    earliestDateInUtc = Instant.ofEpochMilli(nextSearch - 24 * 60 * 60 * 1000);
    verifyManyLogs(95, 55, 60, result.data, result.getStatusMessage(), earliestDateInUtc);
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) AdminActivityLogPageAction(teammates.ui.controller.AdminActivityLogPageAction) Instant(java.time.Instant) Test(org.testng.annotations.Test)

Aggregations

AdminActivityLogPageAction (teammates.ui.controller.AdminActivityLogPageAction)5 ShowPageResult (teammates.ui.controller.ShowPageResult)3 AdminActivityLogPageData (teammates.ui.pagedata.AdminActivityLogPageData)3 Instant (java.time.Instant)2 Test (org.testng.annotations.Test)2 ActivityLogEntry (teammates.common.util.ActivityLogEntry)1 AjaxResult (teammates.ui.controller.AjaxResult)1