@Test void testHeaderIsNotMatchedCauseValue() throws MessagingException { String invalidRegex = "(!("; String regexException = null; String exception = "Malformed pattern: " + invalidRegex; setRegex(invalidRegex); setupMockedMail(); try { setupMatcher(); } catch (MessagingException m) { regexException = m.getMessage(); } Collection<MailAddress> matchedRecipients = matcher.match(mockedMail); assertNull(matchedRecipients); try { assertThat(regexException).isEqualTo(exception); } catch (AssertionFailedError e) { assertThat(regexException).isEqualTo(exception + " (org.apache.oro.text.regex.MalformedPatternException: Unmatched parentheses.)"); } }
@Override public Collection<MailAddress> match(Mail mail) throws MessagingException { return AttributeUtils .getAttributeValueFromMail(mail, attributeName) .filter(obj -> pattern.matcher(obj.toString()).matches()) .map(any -> mail.getRecipients()) .orElse(null); }
HasMailAttributeWithValueRegex extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { return AttributeUtils .getAttributeValueFromMail(mail, attributeName) .filter(obj -> pattern.matcher(obj.toString()).matches()) .map(any -> mail.getRecipients()) .orElse(null); } }
HasMailAttributeWithValueRegex extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { return AttributeUtils .getAttributeValueFromMail(mail, attributeName) .filter(obj -> pattern.matcher(obj.toString()).matches()) .map(any -> mail.getRecipients()) .orElse(null); }  }
HasMailAttributeWithValueRegex extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { return AttributeUtils .getAttributeValueFromMail(mail, attributeName) .filter(obj -> pattern.matcher(obj.toString()).matches()) .map(any -> mail.getRecipients()) .orElse(null); }  @Override String getMatcherInfo(); @Override void init(MatcherConfig conf); @Override Collection<MailAddress> match(Mail mail); }
HasMailAttributeWithValueRegex extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { return AttributeUtils .getAttributeValueFromMail(mail, attributeName) .filter(obj -> pattern.matcher(obj.toString()).matches()) .map(any -> mail.getRecipients()) .orElse(null); }  @Override String getMatcherInfo(); @Override void init(MatcherConfig conf); @Override Collection<MailAddress> match(Mail mail);  }