@Test public void matchShouldReturnNotMatchWhenFetchFromHeaderHoldsWrongValue() throws MessagingException { FakeMail fakeMail = FakeMail.builder() .name("mail") .recipients(ANY_AT_JAMES, OTHER_AT_JAMES) .mimeMessage(MailUtil.createMimeMessage(FetchedFrom.X_FETCHED_FROM, WRONG_HEADER_VALUE)) .build(); assertThat(matcher.match(fakeMail)).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; }