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);
}
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;
}
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 = " 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));
}
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);
}
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());
}
Aggregations