@Test public void serviceShouldAcceptMailsWithNoRecipients() throws Exception { Mail mail = FakeMail.builder().name("mail").build(); testee.service(mail); assertThat(mail.getRecipients()).isEmpty(); }
@Override public void service(Mail mail) throws MessagingException { Collection<MailAddress> postmasterAliases = mail.getRecipients() .stream() .filter(this::isPostmasterAlias) .collect(Guavate.toImmutableList()); if (!postmasterAliases.isEmpty()) { mail.setRecipients( Stream.concat( mail.getRecipients() .stream() .filter(address -> !postmasterAliases.contains(address)), Stream.of(getMailetContext().getPostmaster())) .collect(Guavate.toImmutableSet())); } }
PostmasterAlias extends GenericMailet { @Override public void service(Mail mail) throws MessagingException { Collection<MailAddress> postmasterAliases = mail.getRecipients() .stream() .filter(this::isPostmasterAlias) .collect(Guavate.toImmutableList()); if (!postmasterAliases.isEmpty()) { mail.setRecipients( Stream.concat( mail.getRecipients() .stream() .filter(address -> !postmasterAliases.contains(address)), Stream.of(getMailetContext().getPostmaster())) .collect(Guavate.toImmutableSet())); } } }
PostmasterAlias extends GenericMailet { @Override public void service(Mail mail) throws MessagingException { Collection<MailAddress> postmasterAliases = mail.getRecipients() .stream() .filter(this::isPostmasterAlias) .collect(Guavate.toImmutableList()); if (!postmasterAliases.isEmpty()) { mail.setRecipients( Stream.concat( mail.getRecipients() .stream() .filter(address -> !postmasterAliases.contains(address)), Stream.of(getMailetContext().getPostmaster())) .collect(Guavate.toImmutableSet())); } }  }
PostmasterAlias extends GenericMailet { @Override public void service(Mail mail) throws MessagingException { Collection<MailAddress> postmasterAliases = mail.getRecipients() .stream() .filter(this::isPostmasterAlias) .collect(Guavate.toImmutableList()); if (!postmasterAliases.isEmpty()) { mail.setRecipients( Stream.concat( mail.getRecipients() .stream() .filter(address -> !postmasterAliases.contains(address)), Stream.of(getMailetContext().getPostmaster())) .collect(Guavate.toImmutableSet())); } }  @Override void service(Mail mail); @Override String getMailetInfo(); }
PostmasterAlias extends GenericMailet { @Override public void service(Mail mail) throws MessagingException { Collection<MailAddress> postmasterAliases = mail.getRecipients() .stream() .filter(this::isPostmasterAlias) .collect(Guavate.toImmutableList()); if (!postmasterAliases.isEmpty()) { mail.setRecipients( Stream.concat( mail.getRecipients() .stream() .filter(address -> !postmasterAliases.contains(address)), Stream.of(getMailetContext().getPostmaster())) .collect(Guavate.toImmutableSet())); } }  @Override void service(Mail mail); @Override String getMailetInfo();  }