HasMailAttributeWithValue extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { return AttributeUtils .getAttributeValueFromMail(mail, fieldAttributeName) .filter(attributeValue -> attributeValue.toString().trim().equals(fieldAttributeValue)) .map(any -> mail.getRecipients()) .orElse(null); }  @Override Collection<MailAddress> match(Mail mail); @Override void init(); @Override String getMatcherInfo();  }
@Test void testAttributeIsNotMatchedCauseValue() throws MessagingException { setMailAttribute(new Attribute(MAIL_ATTRIBUTE.getName(), AttributeValue.of("false"))); setupMockedMail(); setupMatcher(); Collection<MailAddress> matchedRecipients = matcher.match(mockedMail); assertNull(matchedRecipients); }