@Test public void shouldNegateWhenOneMatcher() throws Exception { when(matcher1.match(mail)).thenReturn(ImmutableList.of(recipient1, recipient3)); testee.add(matcher1); assertThat(testee.match(mail)).containsOnly(recipient2, recipient4); }
@Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Collection<MailAddress> finalResult = Optional.ofNullable(Lists.newArrayList(mail.getRecipients())).orElse(new ArrayList<>()); for (Matcher matcher : getMatchers()) { Collection<MailAddress> matcherResult = matcher.match(mail); if (matcherResult != null) { finalResult.removeAll(matcherResult); } } return finalResult; }
Not extends GenericCompositeMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Collection<MailAddress> finalResult = Optional.ofNullable(Lists.newArrayList(mail.getRecipients())).orElse(new ArrayList<>()); for (Matcher matcher : getMatchers()) { Collection<MailAddress> matcherResult = matcher.match(mail); if (matcherResult != null) { finalResult.removeAll(matcherResult); } } return finalResult; } }
Not extends GenericCompositeMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Collection<MailAddress> finalResult = Optional.ofNullable(Lists.newArrayList(mail.getRecipients())).orElse(new ArrayList<>()); for (Matcher matcher : getMatchers()) { Collection<MailAddress> matcherResult = matcher.match(mail); if (matcherResult != null) { finalResult.removeAll(matcherResult); } } return finalResult; }  }
Not extends GenericCompositeMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Collection<MailAddress> finalResult = Optional.ofNullable(Lists.newArrayList(mail.getRecipients())).orElse(new ArrayList<>()); for (Matcher matcher : getMatchers()) { Collection<MailAddress> matcherResult = matcher.match(mail); if (matcherResult != null) { finalResult.removeAll(matcherResult); } } return finalResult; }  @Override Collection<MailAddress> match(Mail mail); }
Not extends GenericCompositeMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Collection<MailAddress> finalResult = Optional.ofNullable(Lists.newArrayList(mail.getRecipients())).orElse(new ArrayList<>()); for (Matcher matcher : getMatchers()) { Collection<MailAddress> matcherResult = matcher.match(mail); if (matcherResult != null) { finalResult.removeAll(matcherResult); } } return finalResult; }  @Override Collection<MailAddress> match(Mail mail);  }