Search in sources :

Example 86 with Tx

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

the class TestSingleRecipReliableMessageMonitorRoute method testSingleRecip_MDNProcessedAndErrorReceived_assertConditionComplete.

@Test
public void testSingleRecip_MDNProcessedAndErrorReceived_assertConditionComplete() throws Exception {
    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);
    // send MDN processed to original message
    Tx mdnMessage = TestUtils.makeReliableMessage(TxMessageType.MDN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "", MDNStandard.Disposition_Processed);
    template.sendBody("direct:start", mdnMessage);
    // send MDN error to original message
    mdnMessage = TestUtils.makeReliableMessage(TxMessageType.MDN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "", MDNStandard.Disposition_Error);
    template.sendBody("direct:start", mdnMessage);
    List<Exchange> exchanges = mock.getReceivedExchanges();
    assertEquals(1, exchanges.size());
}
Also used : Exchange(org.apache.camel.Exchange) Tx(org.nhindirect.common.tx.model.Tx) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 87 with Tx

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

the class TestSingleRecipReliableMessageMonitorRoute method testSingleRecip_DSNErroReceived_assertConditionComplete.

@Test
public void testSingleRecip_DSNErroReceived_assertConditionComplete() throws Exception {
    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);
    // send MDN error to original message
    Tx mdnMessage = TestUtils.makeReliableMessage(TxMessageType.DSN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", DSNStandard.DSNAction.FAILED.toString(), "");
    template.sendBody("direct:start", mdnMessage);
    List<Exchange> exchanges = mock.getReceivedExchanges();
    assertEquals(1, exchanges.size());
}
Also used : Exchange(org.apache.camel.Exchange) Tx(org.nhindirect.common.tx.model.Tx) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 88 with Tx

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

the class TestSingleRecipReliableMessageMonitorRoute method testSingleRecip_MDNProcessedAndDisplayedReceived_assertConditionNotComplete.

@Test
public void testSingleRecip_MDNProcessedAndDisplayedReceived_assertConditionNotComplete() throws Exception {
    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);
    // send MDN processed to original message
    Tx mdnMessage = TestUtils.makeReliableMessage(TxMessageType.MDN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "", MDNStandard.Disposition_Processed);
    template.sendBody("direct:start", mdnMessage);
    // send MDN dispatched to original message
    mdnMessage = TestUtils.makeReliableMessage(TxMessageType.MDN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "", MDNStandard.Disposition_Displayed);
    template.sendBody("direct:start", mdnMessage);
    List<Exchange> exchanges = mock.getReceivedExchanges();
    assertEquals(0, exchanges.size());
}
Also used : Exchange(org.apache.camel.Exchange) Tx(org.nhindirect.common.tx.model.Tx) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 89 with Tx

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

the class TxResource_suppressNotificationTest method testSuppressNotification_suppressFalse_assertFalseAnd200StatusCode.

@Test
public void testSuppressNotification_suppressFalse_assertFalseAnd200StatusCode() {
    Tx tx = mock(Tx.class);
    DuplicateNotificationStateManager dupMgr = mock(DuplicateNotificationStateManager.class);
    TxsResource resource = new TxsResource(null, dupMgr);
    Response res = resource.supressNotification(tx);
    assertEquals(200, res.getStatus());
    assertFalse((Boolean) res.getEntity());
}
Also used : Response(javax.ws.rs.core.Response) DuplicateNotificationStateManager(org.nhindirect.monitor.processor.DuplicateNotificationStateManager) Tx(org.nhindirect.common.tx.model.Tx) Test(org.junit.Test)

Example 90 with Tx

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

the class TxResource_suppressNotificationTest method testSuppressNotification_nullDAO_assertExcecption.

@Test
public void testSuppressNotification_nullDAO_assertExcecption() {
    Tx tx = mock(Tx.class);
    TxsResource resource = new TxsResource(null, null);
    boolean exceptionOccured = false;
    try {
        resource.supressNotification(tx);
    } catch (IllegalStateException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) 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