@Test void testNonMatch() throws MessagingException { final MailAddress address1 = new MailAddress("user", "domain"); final MailAddress address2 = new MailAddress("user", "domain2"); MatcherInverter inverter = new MatcherInverter(new GenericMatcher() { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { return mail.getRecipients(); } }); FakeMail mail = FakeMail.builder() .name("mail") .recipients(address1, address2) .build(); assertThat(inverter.match(mail)).withFailMessage("Should match all recipients").isNull(); }
@Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Collection<MailAddress> recipients = new ArrayList<>(mail.getRecipients()); Collection<MailAddress> matchedRcpts = wrappedMatcher.match(mail); if (matchedRcpts != null) { recipients.removeAll(matchedRcpts); if (recipients.isEmpty()) { return null; } } return recipients; }
MatcherInverter implements Matcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Collection<MailAddress> recipients = new ArrayList<>(mail.getRecipients()); Collection<MailAddress> matchedRcpts = wrappedMatcher.match(mail); if (matchedRcpts != null) { recipients.removeAll(matchedRcpts); if (recipients.isEmpty()) { return null; } } return recipients; } }
MatcherInverter implements Matcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Collection<MailAddress> recipients = new ArrayList<>(mail.getRecipients()); Collection<MailAddress> matchedRcpts = wrappedMatcher.match(mail); if (matchedRcpts != null) { recipients.removeAll(matchedRcpts); if (recipients.isEmpty()) { return null; } } return recipients; } MatcherInverter(Matcher wrappedMatcher); }
MatcherInverter implements Matcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Collection<MailAddress> recipients = new ArrayList<>(mail.getRecipients()); Collection<MailAddress> matchedRcpts = wrappedMatcher.match(mail); if (matchedRcpts != null) { recipients.removeAll(matchedRcpts); if (recipients.isEmpty()) { return null; } } return recipients; } MatcherInverter(Matcher wrappedMatcher); @Override void destroy(); @Override MatcherConfig getMatcherConfig(); @Override String getMatcherInfo(); @Override void init(MatcherConfig config); @Override Collection<MailAddress> match(Mail mail); }
MatcherInverter implements Matcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Collection<MailAddress> recipients = new ArrayList<>(mail.getRecipients()); Collection<MailAddress> matchedRcpts = wrappedMatcher.match(mail); if (matchedRcpts != null) { recipients.removeAll(matchedRcpts); if (recipients.isEmpty()) { return null; } } return recipients; } MatcherInverter(Matcher wrappedMatcher); @Override void destroy(); @Override MatcherConfig getMatcherConfig(); @Override String getMatcherInfo(); @Override void init(MatcherConfig config); @Override Collection<MailAddress> match(Mail mail);  }