@Test public void matchShouldRemoveMatchingHeaders() throws MessagingException { FakeMail fakeMail = FakeMail.builder() .name("mail") .recipients(ANY_AT_JAMES, OTHER_AT_JAMES) .mimeMessage(MailUtil.createMimeMessage(FetchedFrom.X_FETCHED_FROM, EXPECTED_HEADER_VALUE)) .build(); matcher.match(fakeMail); assertThat(fakeMail.getMessage().getHeader(FetchedFrom.X_FETCHED_FROM)).isNull(); }
@Override public Collection<MailAddress> match(Mail mail) throws MessagingException { MimeMessage message = mail.getMessage(); String fetchHeaderValue = message.getHeader(X_FETCHED_FROM, null); if (Objects.equal(fetchHeaderValue, getCondition())) { mail.getMessage().removeHeader(X_FETCHED_FROM); return mail.getRecipients(); } return null; }
FetchedFrom extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { MimeMessage message = mail.getMessage(); String fetchHeaderValue = message.getHeader(X_FETCHED_FROM, null); if (Objects.equal(fetchHeaderValue, getCondition())) { mail.getMessage().removeHeader(X_FETCHED_FROM); return mail.getRecipients(); } return null; } }
FetchedFrom extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { MimeMessage message = mail.getMessage(); String fetchHeaderValue = message.getHeader(X_FETCHED_FROM, null); if (Objects.equal(fetchHeaderValue, getCondition())) { mail.getMessage().removeHeader(X_FETCHED_FROM); return mail.getRecipients(); } return null; }  }
FetchedFrom extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { MimeMessage message = mail.getMessage(); String fetchHeaderValue = message.getHeader(X_FETCHED_FROM, null); if (Objects.equal(fetchHeaderValue, getCondition())) { mail.getMessage().removeHeader(X_FETCHED_FROM); return mail.getRecipients(); } return null; }  @Override Collection<MailAddress> match(Mail mail); }
FetchedFrom extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { MimeMessage message = mail.getMessage(); String fetchHeaderValue = message.getHeader(X_FETCHED_FROM, null); if (Objects.equal(fetchHeaderValue, getCondition())) { mail.getMessage().removeHeader(X_FETCHED_FROM); return mail.getRecipients(); } return null; }  @Override Collection<MailAddress> match(Mail mail); static final String X_FETCHED_FROM; }