Search in sources :

Example 6 with NotificationDuplicationDAO

use of org.nhindirect.monitor.dao.NotificationDuplicationDAO in project nhin-d by DirectProject.

the class TimeoutDupStateManager_addNotificationForOriginalRecipsTest method testAddNotificationForOriginalRecips_noRecips_assertNotificationNotAdded.

@Test
public void testAddNotificationForOriginalRecips_noRecips_assertNotificationNotAdded() throws Exception {
    TimeoutDupStateManager mgr = new TimeoutDupStateManager();
    NotificationDuplicationDAO dao = mock(NotificationDuplicationDAO.class);
    mgr.setDao(dao);
    final Tx tx = TestUtils.makeMessage(TxMessageType.IMF, "1234", "", "", "", "");
    mgr.addNotificationForOriginalRecips(Arrays.asList(tx));
    verify(dao, never()).addNotification((String) any(), (String) any());
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) NotificationDuplicationDAO(org.nhindirect.monitor.dao.NotificationDuplicationDAO) Test(org.junit.Test)

Example 7 with NotificationDuplicationDAO

use of org.nhindirect.monitor.dao.NotificationDuplicationDAO in project nhin-d by DirectProject.

the class TimeoutDupStateManager_addNotificationForOriginalRecipsTest method testAddNotificationForOriginalRecips_addSingleRecip_nonReliable_assertNotificationsNotAdded.

@Test
public void testAddNotificationForOriginalRecips_addSingleRecip_nonReliable_assertNotificationsNotAdded() throws Exception {
    TimeoutDupStateManager mgr = new TimeoutDupStateManager();
    NotificationDuplicationDAO dao = mock(NotificationDuplicationDAO.class);
    mgr.setDao(dao);
    final Tx tx = TestUtils.makeMessage(TxMessageType.IMF, "1234", "", "test@test.com", "me@you.com", "test@test.com");
    mgr.addNotificationForOriginalRecips(Arrays.asList(tx));
    verify(dao, never()).addNotification((String) any(), (String) any());
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) NotificationDuplicationDAO(org.nhindirect.monitor.dao.NotificationDuplicationDAO) Test(org.junit.Test)

Example 8 with NotificationDuplicationDAO

use of org.nhindirect.monitor.dao.NotificationDuplicationDAO in project nhin-d by DirectProject.

the class DefaultDuplicateNotificationStateManager_addNotificationTest method testAddNotification_daoError_assertException.

@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).addNotification((String) any(), (String) any());
    mgr.setDao(spyDao);
    try {
        Tx tx = TestUtils.makeMessage(TxMessageType.DSN, "1234", "5678", "", "", "gm2552@cerner.com,ah4626@cerner.com");
        mgr.addNotification(tx);
    } catch (DuplicateNotificationStateManagerException e) {
        execptionOccured = true;
    }
    assertTrue(execptionOccured);
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) NotificationDAOException(org.nhindirect.monitor.dao.NotificationDAOException) NotificationDuplicationDAO(org.nhindirect.monitor.dao.NotificationDuplicationDAO) DuplicateNotificationStateManagerException(org.nhindirect.monitor.processor.DuplicateNotificationStateManagerException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 NotificationDuplicationDAO (org.nhindirect.monitor.dao.NotificationDuplicationDAO)8 Tx (org.nhindirect.common.tx.model.Tx)7 NotificationDAOException (org.nhindirect.monitor.dao.NotificationDAOException)3 MimeMessage (javax.mail.internet.MimeMessage)2 Exchange (org.apache.camel.Exchange)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 DuplicateNotificationStateManagerException (org.nhindirect.monitor.processor.DuplicateNotificationStateManagerException)2