Search in sources :

Example 56 with Tx

use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.

the class TimeoutDupStateManager_addNotificationForOriginalRecipsTest method testAddNotificationForOriginalRecips_addDupRecip_assertNotificationsAdded.

@Test
public void testAddNotificationForOriginalRecips_addDupRecip_assertNotificationsAdded() throws Exception {
    TimeoutDupStateManager mgr = new TimeoutDupStateManager();
    mgr.setDao(notifDao);
    final Tx tx = TestUtils.makeReliableMessage(TxMessageType.IMF, "1234", "", "test@test.com", "me@you.com,you@you.com", "test@test.com", "", "");
    mgr.addNotificationForOriginalRecips(Arrays.asList(tx));
    Set<String> recAddresses = notifDao.getReceivedAddresses("1234", Arrays.asList("me@you.com", "you@you.com"));
    assertTrue(recAddresses.contains("me@you.com"));
    assertTrue(recAddresses.contains("you@you.com"));
    // add it again
    mgr.addNotificationForOriginalRecips(Arrays.asList(tx));
    recAddresses = notifDao.getReceivedAddresses("1234", Arrays.asList("me@you.com", "you@you.com"));
    assertEquals(2, recAddresses.size());
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) Test(org.junit.Test)

Example 57 with Tx

use of org.nhindirect.common.tx.model.Tx 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());
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) NotificationDuplicationDAO(org.nhindirect.monitor.dao.NotificationDuplicationDAO) Test(org.junit.Test)

Example 58 with Tx

use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.

the class GeneralCompletionCondition_isCompleteTest method testIsComplete_noFinalRecips_assertFalse.

@Test
public void testIsComplete_noFinalRecips_assertFalse() {
    GeneralCompletionCondition condition = new GeneralCompletionCondition();
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    String msgId = UUID.randomUUID().toString();
    details.put(TxDetailType.MSG_ID.getType(), new TxDetail(TxDetailType.MSG_ID, msgId));
    Tx tx = new Tx(TxMessageType.IMF, details);
    List<Tx> txs = Arrays.asList(tx);
    assertFalse(condition.isComplete(txs));
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 59 with Tx

use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.

the class GeneralCompletionCondition_isCompleteTest method testIsComplete_DSNMessageReceived_assertTrue.

@Test
public void testIsComplete_DSNMessageReceived_assertTrue() {
    GeneralCompletionCondition condition = new GeneralCompletionCondition();
    // original message
    final String originalMessageId = UUID.randomUUID().toString();
    Tx originalMessage = TestUtils.makeMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "");
    // MDN to original message
    Tx mdnMessage = TestUtils.makeMessage(TxMessageType.DSN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com");
    List<Tx> txs = Arrays.asList(originalMessage, mdnMessage);
    assertTrue(condition.isComplete(txs));
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) Test(org.junit.Test)

Example 60 with Tx

use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.

the class GeneralCompletionCondition_isCompleteTest method testIsComplete_noMessageToTrack_assertFalse.

@Test
public void testIsComplete_noMessageToTrack_assertFalse() {
    GeneralCompletionCondition condition = new GeneralCompletionCondition();
    Tx tx = new Tx(TxMessageType.DSN, new HashMap<String, TxDetail>());
    List<Tx> txs = Arrays.asList(tx);
    assertFalse(condition.isComplete(txs));
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Aggregations

Tx (org.nhindirect.common.tx.model.Tx)174 Test (org.junit.Test)156 Exchange (org.apache.camel.Exchange)83 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)49 TxDetail (org.nhindirect.common.tx.model.TxDetail)35 DefaultExchange (org.apache.camel.impl.DefaultExchange)32 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)19 MimeMessage (javax.mail.internet.MimeMessage)17 CamelContext (org.apache.camel.CamelContext)17 ConcurrentJPAAggregationRepository (org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository)15 TxCompletionCondition (org.nhindirect.monitor.condition.TxCompletionCondition)14 TxTimeoutCondition (org.nhindirect.monitor.condition.TxTimeoutCondition)8 Collection (java.util.Collection)7 NotificationDuplicationDAO (org.nhindirect.monitor.dao.NotificationDuplicationDAO)7 NHINDAddress (org.nhindirect.stagent.NHINDAddress)6 NHINDAddressCollection (org.nhindirect.stagent.NHINDAddressCollection)6 Response (javax.ws.rs.core.Response)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 MessagingException (javax.mail.MessagingException)4