Search in sources :

Example 96 with Tx

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

the class GeneralCompletionCondition_isCompleteTest method testIsComplete_MDNMessageReceived_plusNotationOnMDNRecip_rfc822NotactionOnFinalRecip_assertTrue.

@Test
public void testIsComplete_MDNMessageReceived_plusNotationOnMDNRecip_rfc822NotactionOnFinalRecip_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.MDN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552+readreciept@cerner.com", "rfc822; 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 97 with Tx

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

the class TimelyAndReliableCompletionCondition_isCompleteTest method testIsComplete_failedDSNAction_plusNotationOnDSNRecip_rfc822NotactionOnFinalRecip_assertTrue.

@Test
public void testIsComplete_failedDSNAction_plusNotationOnDSNRecip_rfc822NotactionOnFinalRecip_assertTrue() {
    TimelyAndReliableCompletionCondition condition = new TimelyAndReliableCompletionCondition();
    // original message
    final String originalMessageId = UUID.randomUUID().toString();
    Tx originalMessage = TestUtils.makeMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "");
    // DSN to original message, no reliable headers
    Tx mdnMessage = TestUtils.makeMessage(TxMessageType.DSN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552+readrecipt@cerner.com", "rfc822; gm2552@direct.securehealthemail.com", DSNStandard.DSNAction.FAILED.toString(), "");
    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 98 with Tx

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

the class GeneralCompletionCondition_isCompleteTest method testIsComplete_nonFriendlyFinalRecipName_MDNMessageReceived_assertTrue.

@Test
public void testIsComplete_nonFriendlyFinalRecipName_MDNMessageReceived_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.MDN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "\"Greg Meyer\" <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 99 with Tx

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

the class TimelyAndReliableCompletionCondition_isCompleteTest method testIsComplete_completedMDNs_plusNotationOnDSNRecip_rfc822NotactionOnFinalRecip_assertTrue.

@Test
public void testIsComplete_completedMDNs_plusNotationOnDSNRecip_rfc822NotactionOnFinalRecip_assertTrue() {
    TimelyAndReliableCompletionCondition condition = new TimelyAndReliableCompletionCondition();
    // 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, no reliable headers
    Tx mdnProcessedMessage = TestUtils.makeMessage(TxMessageType.MDN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552+readrecipt@cerner.com", "rfc822; gm2552@direct.securehealthemail.com", "", MDNStandard.Disposition_Processed, "");
    // MDN to original message, no reliable headers
    Tx mdnDispatchedMessage = TestUtils.makeMessage(TxMessageType.MDN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552+readrecipt@cerner.com", "rfc822; gm2552@direct.securehealthemail.com", "", MDNStandard.Disposition_Dispatched, MDNStandard.DispositionOption_TimelyAndReliable);
    List<Tx> txs = Arrays.asList(originalMessage, mdnProcessedMessage, mdnDispatchedMessage);
    assertTrue(condition.isComplete(txs));
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) Test(org.junit.Test)

Example 100 with Tx

use of org.nhindirect.common.tx.model.Tx 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());
}
Also used : Exchange(org.apache.camel.Exchange) Tx(org.nhindirect.common.tx.model.Tx) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) MimeMessage(javax.mail.internet.MimeMessage) NotificationDuplicationDAO(org.nhindirect.monitor.dao.NotificationDuplicationDAO) 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