@Test public void matchShouldReturnEmptyWhenLoopButNoRecipient() throws Exception { recipientRewriteTable.addAddressMapping(MappingSource.fromUser(SENDER.getLocalPart(), SENDER.getDomain()),"recipient1@domain.tld"); recipientRewriteTable.addAddressMapping(MappingSource.fromUser(RECIPIENT1.getLocalPart(), RECIPIENT1.getDomain()), SENDER.asString()); recipientRewriteTable.addDomainMapping(MappingSource.fromDomain(DOMAIN), Domain.LOCALHOST); Collection<MailAddress> result = testee.match(FakeMail.builder() .name("name") .sender(SENDER) .build()); assertThat(result).isEmpty(); }
@Override public Collection<MailAddress> match(Mail mail) { try { if (mail.hasSender()) { recipientRewriteTable.getResolvedMappings(mail.getMaybeSender().get().getLocalPart(), mail.getMaybeSender().get().getDomain()); } } catch (RecipientRewriteTable.TooManyMappingException e) { return mail.getRecipients(); } catch (Exception e) { LoggerFactory.getLogger(IsSenderInRRTLoop.class).warn("Error while executing RRT"); } return ImmutableList.of(); }
IsSenderInRRTLoop extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { try { if (mail.hasSender()) { recipientRewriteTable.getResolvedMappings(mail.getMaybeSender().get().getLocalPart(), mail.getMaybeSender().get().getDomain()); } } catch (RecipientRewriteTable.TooManyMappingException e) { return mail.getRecipients(); } catch (Exception e) { LoggerFactory.getLogger(IsSenderInRRTLoop.class).warn("Error while executing RRT"); } return ImmutableList.of(); } }
IsSenderInRRTLoop extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { try { if (mail.hasSender()) { recipientRewriteTable.getResolvedMappings(mail.getMaybeSender().get().getLocalPart(), mail.getMaybeSender().get().getDomain()); } } catch (RecipientRewriteTable.TooManyMappingException e) { return mail.getRecipients(); } catch (Exception e) { LoggerFactory.getLogger(IsSenderInRRTLoop.class).warn("Error while executing RRT"); } return ImmutableList.of(); } @Inject  IsSenderInRRTLoop(RecipientRewriteTable recipientRewriteTable); }
IsSenderInRRTLoop extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { try { if (mail.hasSender()) { recipientRewriteTable.getResolvedMappings(mail.getMaybeSender().get().getLocalPart(), mail.getMaybeSender().get().getDomain()); } } catch (RecipientRewriteTable.TooManyMappingException e) { return mail.getRecipients(); } catch (Exception e) { LoggerFactory.getLogger(IsSenderInRRTLoop.class).warn("Error while executing RRT"); } return ImmutableList.of(); } @Inject  IsSenderInRRTLoop(RecipientRewriteTable recipientRewriteTable); @Override Collection<MailAddress> match(Mail mail); }
IsSenderInRRTLoop extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { try { if (mail.hasSender()) { recipientRewriteTable.getResolvedMappings(mail.getMaybeSender().get().getLocalPart(), mail.getMaybeSender().get().getDomain()); } } catch (RecipientRewriteTable.TooManyMappingException e) { return mail.getRecipients(); } catch (Exception e) { LoggerFactory.getLogger(IsSenderInRRTLoop.class).warn("Error while executing RRT"); } return ImmutableList.of(); } @Inject  IsSenderInRRTLoop(RecipientRewriteTable recipientRewriteTable); @Override Collection<MailAddress> match(Mail mail);  }