public int deliverAll(Set<EmailDeliveryRequest> deliveries) {
    if (deliveries.isEmpty() || !isActivated()) {
      LOG.debug(SMTP_HOST_NOT_CONFIGURED_DEBUG_MSG);
      return 0;
    }

    return (int) deliveries.stream()
      .filter(t -> !t.recipientEmail().isBlank())
      .map(t -> {
        EmailMessage emailMessage = format(t.notification());
        if (emailMessage != null) {
          emailMessage.setTo(t.recipientEmail());
          return deliver(emailMessage);
        }
        return false;
      })
      .filter(Boolean::booleanValue)
      .count();
  }
@Test
  public void deliverAll_has_no_effect_if_smtp_host_is_null() {
    EmailSmtpConfiguration emailSettings = mock(EmailSmtpConfiguration.class);
    when(emailSettings.getSmtpHost()).thenReturn(null);
    Set<EmailDeliveryRequest> requests = IntStream.range(0, 1 + new Random().nextInt(10))
      .mapToObj(i -> new EmailDeliveryRequest("foo" + i + "@moo", mock(Notification.class)))
      .collect(toSet());
    EmailNotificationChannel emailNotificationChannel = new EmailNotificationChannel(emailSettings, server, null, null);

    int count = emailNotificationChannel.deliverAll(requests);

    assertThat(count).isZero();
    verify(emailSettings).getSmtpHost();
    verifyNoMoreInteractions(emailSettings);
    assertThat(smtpServer.getMessages()).isEmpty();
  }