use of org.apache.mailet.MatcherConfig in project nhin-d by DirectProject.
the class RecipAndSenderIsNotLocalTest method testMatch_LocalSender_RemoteRcpt_AssertRecipeintReturned.
public void testMatch_LocalSender_RemoteRcpt_AssertRecipeintReturned() 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@remoteMail")));
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@remoteMail", matchAddresses.iterator().next().toString());
}
use of org.apache.mailet.MatcherConfig in project nhin-d by DirectProject.
the class RecipAndSenderIsNotLocalTest method testEmptyDomainList.
public void testEmptyDomainList() throws Exception {
final MatcherConfig newConfig = mock(MatcherConfig.class);
when(newConfig.getCondition()).thenReturn("");
RecipAndSenderIsNotLocal matcher = new RecipAndSenderIsNotLocal();
boolean exceptionOccured = false;
try {
matcher.init(newConfig);
} catch (SmtpAgentException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.apache.mailet.MatcherConfig 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.MatcherConfig 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.MatcherConfig in project nhin-d by DirectProject.
the class RecipAndSenderIsNotLocalTest method testNullDomainList.
public void testNullDomainList() throws Exception {
final MatcherConfig newConfig = mock(MatcherConfig.class);
when(newConfig.getCondition()).thenReturn(null);
RecipAndSenderIsNotLocal matcher = new RecipAndSenderIsNotLocal();
boolean exceptionOccured = false;
try {
matcher.init(newConfig);
} catch (SmtpAgentException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
Aggregations