use of org.apache.mailet.MailAddress in project nhin-d by DirectProject.
the class MockMail method getSender.
public MailAddress getSender() {
MailAddress retVal = null;
try {
Address addr = mimeMessage.getSender();
if (addr == null) {
Address[] addrs = mimeMessage.getFrom();
addr = addrs[0];
}
retVal = new MailAddress(addr.toString());
} catch (Exception e) {
}
return retVal;
}
use of org.apache.mailet.MailAddress in project nhin-d by DirectProject.
the class NHINDSecurityAndTrustMailet_service_Test method testService_ProcessIsNull_AssertGhostState.
public void testService_ProcessIsNull_AssertGhostState() throws Exception {
final MimeMessage mimeMsg = EntitySerializer.Default.deserialize(TestUtils.readMessageResource("PlainOutgoingMessage.txt"));
final SmtpAgent mockAgent = mock(SmtpAgent.class);
final Mail mockMail = mock(MockMail.class, CALLS_REAL_METHODS);
when(mockMail.getRecipients()).thenReturn(null);
when(mockMail.getSender()).thenReturn(new MailAddress("me@cerner.com"));
mockMail.setMessage(mimeMsg);
NHINDSecurityAndTrustMailet mailet = new NHINDSecurityAndTrustMailet();
mailet.agent = mockAgent;
mailet.service(mockMail);
assertEquals(Mail.GHOST, mockMail.getState());
}
use of org.apache.mailet.MailAddress in project nhin-d by DirectProject.
the class RecipAndSenderIsNotLocalTest method testMatch_LocalSender_LocalAndRemoteRcpt_AssertRemoteRcptReturned.
public void testMatch_LocalSender_LocalAndRemoteRcpt_AssertRemoteRcptReturned() throws Exception {
final Mail mockMail = mock(Mail.class);
when(mockMail.getSender()).thenReturn(new MailAddress("me@cerner.com"));
when(mockMail.getRecipients()).thenReturn(Arrays.asList(new MailAddress("you@cerner.com"), new MailAddress("someone@remoteMail.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("someone@remoteMail.com", matchAddresses.iterator().next().toString());
}
use of org.apache.mailet.MailAddress in project nhin-d by DirectProject.
the class RecipAndSenderIsNotLocalTest method testMatch_LocalSender_LocalRcpt_AssertNoneReturned.
public void testMatch_LocalSender_LocalRcpt_AssertNoneReturned() throws Exception {
final Mail mockMail = mock(Mail.class);
when(mockMail.getSender()).thenReturn(new MailAddress("me@cerner.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(0, matchAddresses.size());
}
use of org.apache.mailet.MailAddress 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());
}
Aggregations