use of org.nhindirect.monitor.dao.NotificationDuplicationDAO in project nhin-d by DirectProject.
the class TestTimeoutToDupStateManager method testTimeoutReliableMessage_conditionNotComplete_assertDupAdded.
@Test
public void testTimeoutReliableMessage_conditionNotComplete_assertDupAdded() throws Exception {
NotificationDuplicationDAO dao = context.getRegistry().lookup("notificationDuplicationDAO", NotificationDuplicationDAO.class);
assertNotNull(dao);
purgeNotifDAO(dao);
MockEndpoint mock = getMockEndpoint("mock:result");
// send original message
final String originalMessageId = UUID.randomUUID().toString();
Tx originalMessage = TestUtils.makeReliableMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "", "", "");
template.sendBody("direct:start", originalMessage);
// no MDN sent... messages should timeout after 2 seconds
// sleep 3 seconds to make sure it completes
Thread.sleep(3000);
List<Exchange> exchanges = mock.getReceivedExchanges();
assertEquals(1, exchanges.size());
Exchange exchange = exchanges.iterator().next();
// make sure there is only 1 message in the exchange
MimeMessage message = exchange.getIn().getBody(MimeMessage.class);
assertNotNull(message);
assertEquals("timeout", exchange.getProperty(Exchange.AGGREGATED_COMPLETED_BY));
Set<String> addresses = dao.getReceivedAddresses(originalMessageId + "\t" + message.getMessageID(), Arrays.asList("gm2552@direct.securehealthemail.com"));
assertEquals(1, addresses.size());
assertTrue(addresses.contains("gm2552@direct.securehealthemail.com"));
addresses = dao.getReceivedAddresses(originalMessageId, Arrays.asList("gm2552@direct.securehealthemail.com"));
assertEquals(1, addresses.size());
assertTrue(addresses.contains("gm2552@direct.securehealthemail.com"));
}
use of org.nhindirect.monitor.dao.NotificationDuplicationDAO in project nhin-d by DirectProject.
the class DefaultDuplicateNotificationStateManager_purgeTest method testPurgeNotification_daoError_assertException.
@Test
public void testPurgeNotification_daoError_assertException() throws Exception {
DefaultDuplicateNotificationStateManager mgr = new DefaultDuplicateNotificationStateManager();
NotificationDuplicationDAO spyDao = mock(NotificationDuplicationDAO.class);
doThrow(new NotificationDAOException("")).when(spyDao).purgeNotifications((Calendar) any());
mgr.setDao(spyDao);
mgr.purge();
}
use of org.nhindirect.monitor.dao.NotificationDuplicationDAO in project nhin-d by DirectProject.
the class DefaultDuplicateNotificationStateManager_suppressNotificationTest method testAddNotification_daoError_assertException.
@SuppressWarnings("unchecked")
@Test
public void testAddNotification_daoError_assertException() throws Exception {
DefaultDuplicateNotificationStateManager mgr = new DefaultDuplicateNotificationStateManager();
boolean execptionOccured = false;
NotificationDuplicationDAO spyDao = mock(NotificationDuplicationDAO.class);
doThrow(new NotificationDAOException("")).when(spyDao).getReceivedAddresses((String) any(), (Collection<String>) any());
mgr.setDao(spyDao);
try {
Tx tx = TestUtils.makeMessage(TxMessageType.DSN, "1234", "5678", "", "", "gm2552@cerner.com,ah4626@cerner.com");
mgr.suppressNotification(tx);
} catch (DuplicateNotificationStateManagerException e) {
execptionOccured = true;
}
assertTrue(execptionOccured);
}
use of org.nhindirect.monitor.dao.NotificationDuplicationDAO in project nhin-d by DirectProject.
the class TimeoutDupStateManager_addNotificationForOriginalRecipsTest method testAddNotificationForOriginalRecips_noOrigMsg_assertNotificationNotAdded.
@Test
public void testAddNotificationForOriginalRecips_noOrigMsg_assertNotificationNotAdded() throws Exception {
TimeoutDupStateManager mgr = new TimeoutDupStateManager();
NotificationDuplicationDAO dao = mock(NotificationDuplicationDAO.class);
mgr.setDao(dao);
final Tx tx = TestUtils.makeMessage(TxMessageType.MDN, "1234", "", "test@test.com", "me@you.com", "test@test.com");
mgr.addNotificationForOriginalRecips(Arrays.asList(tx));
verify(dao, never()).addNotification((String) any(), (String) any());
}
use of org.nhindirect.monitor.dao.NotificationDuplicationDAO in project nhin-d by DirectProject.
the class TestTimeoutToDupStateManager method testTimeoutReliableMessage_conditionNotComplete_msgNotReliable_assertDupNotAdded.
@Test
public void testTimeoutReliableMessage_conditionNotComplete_msgNotReliable_assertDupNotAdded() throws Exception {
NotificationDuplicationDAO dao = context.getRegistry().lookup("notificationDuplicationDAO", NotificationDuplicationDAO.class);
assertNotNull(dao);
purgeNotifDAO(dao);
MockEndpoint mock = getMockEndpoint("mock:result");
// send original message
final String originalMessageId = UUID.randomUUID().toString();
Tx originalMessage = TestUtils.makeMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "");
template.sendBody("direct:start", originalMessage);
// no MDN sent... messages should timeout after 2 seconds
// sleep 3 seconds to make sure it completes
Thread.sleep(3000);
List<Exchange> exchanges = mock.getReceivedExchanges();
assertEquals(1, exchanges.size());
Exchange exchange = exchanges.iterator().next();
// make sure there is only 1 message in the exchange
MimeMessage messages = exchange.getIn().getBody(MimeMessage.class);
assertNotNull(messages);
assertEquals("timeout", exchange.getProperty(Exchange.AGGREGATED_COMPLETED_BY));
Set<String> addresses = dao.getReceivedAddresses(originalMessageId, Arrays.asList("gm2552@direct.securehealthemail.com"));
assertEquals(0, addresses.size());
}
Aggregations