@Test public void removeRecipientShouldNotThrowWhenRecipientIsNull() throws Exception { FakeMail mail = FakeMail.builder() .name("name") .recipients(MailAddressFixture.ANY_AT_JAMES) .build(); ActionContext actionContext = mock(ActionContext.class); when(actionContext.getRecipient()).thenReturn(null); DiscardAction.removeRecipient(mail, actionContext); assertThat(mail.getRecipients()).containsOnly(MailAddressFixture.ANY_AT_JAMES); }
public static void removeRecipient(Mail mail, ActionContext context) { mail.setRecipients(mail.getRecipients() .stream() .filter(Predicate.not(Predicate.isEqual(context.getRecipient()))) .collect(Guavate.toImmutableList())); }
DiscardAction extends FileIntoAction implements MailAction { public static void removeRecipient(Mail mail, ActionContext context) { mail.setRecipients(mail.getRecipients() .stream() .filter(Predicate.not(Predicate.isEqual(context.getRecipient()))) .collect(Guavate.toImmutableList())); } }
DiscardAction extends FileIntoAction implements MailAction { public static void removeRecipient(Mail mail, ActionContext context) { mail.setRecipients(mail.getRecipients() .stream() .filter(Predicate.not(Predicate.isEqual(context.getRecipient()))) .collect(Guavate.toImmutableList())); }  }
DiscardAction extends FileIntoAction implements MailAction { public static void removeRecipient(Mail mail, ActionContext context) { mail.setRecipients(mail.getRecipients() .stream() .filter(Predicate.not(Predicate.isEqual(context.getRecipient()))) .collect(Guavate.toImmutableList())); }  @Override void execute(Action action, Mail mail, final ActionContext context); static void removeRecipient(Mail mail, ActionContext context); }
DiscardAction extends FileIntoAction implements MailAction { public static void removeRecipient(Mail mail, ActionContext context) { mail.setRecipients(mail.getRecipients() .stream() .filter(Predicate.not(Predicate.isEqual(context.getRecipient()))) .collect(Guavate.toImmutableList())); }  @Override void execute(Action action, Mail mail, final ActionContext context); static void removeRecipient(Mail mail, ActionContext context);  }