Search in sources :

Example 46 with Tx

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

the class ExchangeToTxCollectionConverter_toTxCollectionTest method testToTxCollection_convertExchangeToTxCollection.

@Test
public void testToTxCollection_convertExchangeToTxCollection() {
    Collection<Tx> txs = new ArrayList<Tx>();
    Tx tx = mock(Tx.class);
    txs.add(tx);
    Exchange exchange = new DefaultExchange(mock(CamelContext.class));
    exchange.getIn().setBody(txs);
    Collection<Tx> retrievedTxs = ExchangeToTxCollectionConverter.toTxCollection(exchange);
    assertEquals(txs, retrievedTxs);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) CamelContext(org.apache.camel.CamelContext) Tx(org.nhindirect.common.tx.model.Tx) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 47 with Tx

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

the class TimelyAndReliableCompletionCondition_isCompleteTest method testIsComplete_noFinalRecips_assertFalse.

@Test
public void testIsComplete_noFinalRecips_assertFalse() {
    TimelyAndReliableCompletionCondition condition = new TimelyAndReliableCompletionCondition();
    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 48 with Tx

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

the class TimelyAndReliableCompletionCondition_isCompleteTest method testIsComplete_failedDSNAction_finalRecipNotInOriginalMessage_assertFalse.

@Test
public void testIsComplete_failedDSNAction_finalRecipNotInOriginalMessage_assertFalse() {
    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 mdnMessage = TestUtils.makeMessage(TxMessageType.DSN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "me@test.com", DSNStandard.DSNAction.FAILED.toString(), "");
    List<Tx> txs = Arrays.asList(originalMessage, mdnMessage);
    assertFalse(condition.isComplete(txs));
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) Test(org.junit.Test)

Example 49 with Tx

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

the class VariableCompletionCondition_isCompleteTest method testIsComplete_isNotTimely_assertNotComplete.

@SuppressWarnings("unchecked")
@Test
public void testIsComplete_isNotTimely_assertNotComplete() {
    TxCompletionCondition timelyCond = mock(TxCompletionCondition.class);
    when(timelyCond.isComplete((Collection<Tx>) any())).thenReturn(true);
    TxCompletionCondition generalCond = mock(TxCompletionCondition.class);
    VariableCompletionCondition cond = new VariableCompletionCondition(timelyCond, generalCond);
    VariableCompletionCondition spy = spy(cond);
    Tx msgToTrack = mock(Tx.class);
    when(spy.getMessageToTrackInternal((Collection<Tx>) any())).thenReturn(msgToTrack);
    when(spy.isRelAndTimelyRequired((Tx) any())).thenReturn(false);
    assertFalse(spy.isComplete(null));
    verify(timelyCond, never()).isComplete((Collection<Tx>) any());
    verify(generalCond, times(1)).isComplete((Collection<Tx>) any());
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) Tx(org.nhindirect.common.tx.model.Tx) Test(org.junit.Test)

Example 50 with Tx

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

the class VariableCompletionCondition_isCompleteTest method testIsComplete_isNotTimely_assertComplete.

@SuppressWarnings("unchecked")
@Test
public void testIsComplete_isNotTimely_assertComplete() {
    TxCompletionCondition timelyCond = mock(TxCompletionCondition.class);
    TxCompletionCondition generalCond = mock(TxCompletionCondition.class);
    when(generalCond.isComplete((Collection<Tx>) any())).thenReturn(true);
    VariableCompletionCondition cond = new VariableCompletionCondition(timelyCond, generalCond);
    VariableCompletionCondition spy = spy(cond);
    Tx msgToTrack = mock(Tx.class);
    when(spy.getMessageToTrackInternal((Collection<Tx>) any())).thenReturn(msgToTrack);
    when(spy.isRelAndTimelyRequired((Tx) any())).thenReturn(false);
    assertTrue(spy.isComplete(null));
    verify(timelyCond, never()).isComplete((Collection<Tx>) any());
    verify(generalCond, times(1)).isComplete((Collection<Tx>) any());
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) 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