Don't send email notification when 0 uploads were attempted (#1058)

* Don't send email notification when 0 uploads were attempted
This commit is contained in:
Ben McIlwain 2021-04-06 18:17:57 -04:00 committed by GitHub
parent 06b0887c51
commit e31f0cb9ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View file

@ -278,9 +278,15 @@ public final class IcannReportingUploadAction implements Runnable {
}
private void emailUploadResults(ImmutableMap<String, Boolean> reportSummary) {
String subject = String.format(
"ICANN Monthly report upload summary: %d/%d succeeded",
reportSummary.values().stream().filter((b) -> b).count(), reportSummary.size());
if (reportSummary.size() == 0) {
logger.atInfo().log("No uploads were attempted today; skipping notification email.");
return;
}
String subject =
String.format(
"ICANN Monthly report upload summary: %d/%d succeeded",
// This filter() does in fact do something: It counts only the trues.
reportSummary.values().stream().filter((b) -> b).count(), reportSummary.size());
String body =
String.format(
"Report Filename - Upload status:\n%s",

View file

@ -210,13 +210,7 @@ class IcannReportingUploadActionTest {
action.run();
tm().clearSessionCache();
verifyNoMoreInteractions(mockReporter);
verify(emailService)
.sendEmail(
EmailMessage.create(
"ICANN Monthly report upload summary: 0/0 succeeded",
"Report Filename - Upload status:\n",
new InternetAddress("recipient@example.com"),
new InternetAddress("sender@example.com")));
verifyNoMoreInteractions(emailService);
}
@TestOfyAndSql