Search in sources :

Example 6 with MatcherConfig

use of org.apache.mailet.MatcherConfig in project nhin-d by DirectProject.

the class RecipAndSenderIsNotLocalTest method testMatch_RemoteSender_AssertRecipeintReturned.

public void testMatch_RemoteSender_AssertRecipeintReturned() throws Exception {
    final Mail mockMail = mock(Mail.class);
    when(mockMail.getSender()).thenReturn(new MailAddress("me@remoteMail.com"));
    when(mockMail.getRecipients()).thenReturn(Arrays.asList(new MailAddress("you@cerner.com")));
    final MatcherConfig newConfig = mock(MatcherConfig.class);
    when(newConfig.getCondition()).thenReturn("cerner.com");
    RecipAndSenderIsNotLocal matcher = new RecipAndSenderIsNotLocal();
    matcher.init(newConfig);
    Collection<MailAddress> matchAddresses = matcher.match(mockMail);
    assertEquals(1, matchAddresses.size());
    assertEquals("you@cerner.com", matchAddresses.iterator().next().toString());
}
Also used : Mail(org.apache.mailet.Mail) MailAddress(org.apache.mailet.MailAddress) MatcherConfig(org.apache.mailet.MatcherConfig)

Aggregations

MatcherConfig (org.apache.mailet.MatcherConfig)6 Mail (org.apache.mailet.Mail)4 MailAddress (org.apache.mailet.MailAddress)4 SmtpAgentException (org.nhindirect.gateway.smtp.SmtpAgentException)2