Search in sources :

Example 1 with EmailLogEntry

use of teammates.common.util.EmailLogEntry in project teammates by TEAMMATES.

the class AdminEmailLogPageActionTest method verifyActionResult.

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

Example 2 with EmailLogEntry

use of teammates.common.util.EmailLogEntry in project teammates by TEAMMATES.

the class AdminEmailLogPageAction method filterLogsForEmailLogPage.

private List<EmailLogEntry> filterLogsForEmailLogPage(List<AppLogLine> appLogLines, AdminEmailLogPageData data) {
    List<EmailLogEntry> emailLogs = new LinkedList<>();
    for (AppLogLine appLog : appLogLines) {
        String logMsg = appLog.getLogMessage();
        boolean isNotEmailLog = !logMsg.contains("TEAMMATESEMAILLOG");
        if (isNotEmailLog) {
            continue;
        }
        EmailLogEntry emailLogEntry = new EmailLogEntry(appLog);
        if (data.shouldShowLog(emailLogEntry)) {
            emailLogs.add(emailLogEntry);
        }
    }
    return emailLogs;
}
Also used : EmailLogEntry(teammates.common.util.EmailLogEntry) AppLogLine(com.google.appengine.api.log.AppLogLine) LinkedList(java.util.LinkedList)

Example 3 with EmailLogEntry

use of teammates.common.util.EmailLogEntry in project teammates by TEAMMATES.

the class AdminEmailLogPageAction method searchEmailLogsWithTimeIncrement.

/**
 * Searches enough email logs within MAX_SEARCH_PERIOD hours.
 */
private void searchEmailLogsWithTimeIncrement(AdminEmailLogPageData data) {
    List<EmailLogEntry> emailLogs = new LinkedList<>();
    List<String> versionToQuery = getVersionsForQuery(data.getVersions());
    AdminLogQuery query = new AdminLogQuery(versionToQuery, null, data.getToDate());
    int totalLogsSearched = 0;
    GaeLogApi logApi = new GaeLogApi();
    long startTime = query.getEndTime() - SEARCH_TIME_INCREMENT;
    query.setTimePeriod(startTime, query.getEndTime());
    for (int i = 0; i < MAX_SEARCH_TIMES; i++) {
        if (emailLogs.size() >= LOGS_PER_PAGE) {
            break;
        }
        List<AppLogLine> searchResult = logApi.fetchLogs(query);
        List<EmailLogEntry> filteredLogs = filterLogsForEmailLogPage(searchResult, data);
        emailLogs.addAll(filteredLogs);
        totalLogsSearched += searchResult.size();
        query.moveTimePeriodBackward(SEARCH_TIME_INCREMENT);
    }
    data.setLogs(emailLogs);
    long nextEndTimeToSearch = query.getEndTime();
    String status = "&nbsp;&nbsp;Total Logs gone through in last search: " + totalLogsSearched + "<br>" + "<button class=\"btn-link\" id=\"button_older\" data-next-end-time-to-search=\"" + nextEndTimeToSearch + "\">Search More</button>";
    data.setStatusForAjax(status);
    statusToUser.add(new StatusMessage(status, StatusMessageColor.INFO));
}
Also used : EmailLogEntry(teammates.common.util.EmailLogEntry) AppLogLine(com.google.appengine.api.log.AppLogLine) LinkedList(java.util.LinkedList) AdminLogQuery(teammates.common.util.AdminLogQuery) GaeLogApi(teammates.common.util.GaeLogApi) StatusMessage(teammates.common.util.StatusMessage)

Example 4 with EmailLogEntry

use of teammates.common.util.EmailLogEntry in project teammates by TEAMMATES.

the class EmailSender method sendEmail.

/**
 * Sends the given {@code message} and generates a log report.
 */
public void sendEmail(EmailWrapper message) throws EmailSendingException {
    service.sendEmail(message);
    EmailLogEntry newEntry = new EmailLogEntry(message);
    String emailLogInfo = newEntry.generateLogMessage();
    log.info(emailLogInfo);
}
Also used : EmailLogEntry(teammates.common.util.EmailLogEntry)

Example 5 with EmailLogEntry

use of teammates.common.util.EmailLogEntry in project teammates by TEAMMATES.

the class EmailLogEntryTest method emailLog_withAppLogLine_constructionFailAsNotInCorrectFormat.

@Test
public void emailLog_withAppLogLine_constructionFailAsNotInCorrectFormat() {
    String logMessage = "NotInDesiredFormat";
    AppLogLine appLog = new AppLogLine();
    appLog.setLogMessage(logMessage);
    appLog.setTimeUsec(410333L);
    EmailLogEntry logEntry = new EmailLogEntry(appLog);
    assertEquals("", logEntry.getReceiver());
    assertEquals("", logEntry.getSubject());
    assertEquals("", logEntry.getContent());
    assertEquals(410L, logEntry.getTime());
    assertFalse(logEntry.isTestData());
}
Also used : EmailLogEntry(teammates.common.util.EmailLogEntry) AppLogLine(com.google.appengine.api.log.AppLogLine) Test(org.testng.annotations.Test)

Aggregations

EmailLogEntry (teammates.common.util.EmailLogEntry)8 AppLogLine (com.google.appengine.api.log.AppLogLine)4 Test (org.testng.annotations.Test)3 LinkedList (java.util.LinkedList)2 AdminLogQuery (teammates.common.util.AdminLogQuery)1 EmailWrapper (teammates.common.util.EmailWrapper)1 GaeLogApi (teammates.common.util.GaeLogApi)1 StatusMessage (teammates.common.util.StatusMessage)1 AdminEmailLogPageAction (teammates.ui.controller.AdminEmailLogPageAction)1 ShowPageResult (teammates.ui.controller.ShowPageResult)1 AdminEmailLogPageData (teammates.ui.pagedata.AdminEmailLogPageData)1 AdminEmailTableRow (teammates.ui.template.AdminEmailTableRow)1