Search in sources :

Example 11 with Mail

use of org.apache.mailet.Mail 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

Mail (org.apache.mailet.Mail)11 MailAddress (org.apache.mailet.MailAddress)11 MimeMessage (javax.mail.internet.MimeMessage)7 SmtpAgent (org.nhindirect.gateway.smtp.SmtpAgent)7 MatcherConfig (org.apache.mailet.MatcherConfig)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 MessageProcessResult (org.nhindirect.gateway.smtp.MessageProcessResult)4 NHINDAddressCollection (org.nhindirect.stagent.NHINDAddressCollection)4 Message (org.nhindirect.stagent.mail.Message)3 DefaultMessageEnvelope (org.nhindirect.stagent.DefaultMessageEnvelope)2 NHINDAddress (org.nhindirect.stagent.NHINDAddress)2 MessagingException (javax.mail.MessagingException)1 SmtpAgentException (org.nhindirect.gateway.smtp.SmtpAgentException)1 MockNHINDAgent (org.nhindirect.stagent.MockNHINDAgent)1