diff --git a/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java b/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java index 8c67c24f4..b32f7710a 100644 --- a/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java +++ b/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java @@ -278,9 +278,15 @@ public final class IcannReportingUploadAction implements Runnable { } private void emailUploadResults(ImmutableMap 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", diff --git a/core/src/test/java/google/registry/reporting/icann/IcannReportingUploadActionTest.java b/core/src/test/java/google/registry/reporting/icann/IcannReportingUploadActionTest.java index f292a1fe7..3c4203975 100644 --- a/core/src/test/java/google/registry/reporting/icann/IcannReportingUploadActionTest.java +++ b/core/src/test/java/google/registry/reporting/icann/IcannReportingUploadActionTest.java @@ -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