@Test void matchShouldReturnRecipientsWhenEnvelopRecipientsMatches() throws Exception { Dlp dlp = new Dlp( asRulesLoaderFor( JAMES_APACHE_ORG_DOMAIN, DlpDomainRules.builder().recipientRule(Id.of("match recipient"), Pattern.compile(RECIPIENT1.asString())).build())); FakeMail mail = FakeMail.builder() .name("name") .sender(ANY_AT_JAMES) .recipient(RECIPIENT1) .recipient(RECIPIENT2) .build(); assertThat(dlp.match(mail)).contains(RECIPIENT1, RECIPIENT2); }
@Override public Collection<MailAddress> match(Mail mail) { Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail); if (firstMatchingRuleId.isPresent()) { DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get(); setRuleIdAsMailAttribute(mail, ruleId); return mail.getRecipients(); } return ImmutableList.of(); }
Dlp extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail); if (firstMatchingRuleId.isPresent()) { DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get(); setRuleIdAsMailAttribute(mail, ruleId); return mail.getRecipients(); } return ImmutableList.of(); } }
Dlp extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail); if (firstMatchingRuleId.isPresent()) { DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get(); setRuleIdAsMailAttribute(mail, ruleId); return mail.getRecipients(); } return ImmutableList.of(); } @VisibleForTesting  Dlp(DlpRulesLoader rulesLoader); @Inject  Dlp(DLPConfigurationStore configurationStore); }
Dlp extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail); if (firstMatchingRuleId.isPresent()) { DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get(); setRuleIdAsMailAttribute(mail, ruleId); return mail.getRecipients(); } return ImmutableList.of(); } @VisibleForTesting  Dlp(DlpRulesLoader rulesLoader); @Inject  Dlp(DLPConfigurationStore configurationStore); @Override Collection<MailAddress> match(Mail mail); @Override String getMatcherInfo(); }
Dlp extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) { Optional<DLPConfigurationItem.Id> firstMatchingRuleId = findFirstMatchingRule(mail); if (firstMatchingRuleId.isPresent()) { DLPConfigurationItem.Id ruleId = firstMatchingRuleId.get(); setRuleIdAsMailAttribute(mail, ruleId); return mail.getRecipients(); } return ImmutableList.of(); } @VisibleForTesting  Dlp(DlpRulesLoader rulesLoader); @Inject  Dlp(DLPConfigurationStore configurationStore); @Override Collection<MailAddress> match(Mail mail); @Override String getMatcherInfo();  }