Search in sources :

Example 6 with Tx

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

the class ConcurrentJPAAggregationRepository_recoverTest method testRecover_exchangeInRepo_assertRecovered.

@Test
public void testRecover_exchangeInRepo_assertRecovered() {
    final Tx tx = TestUtils.makeMessage(TxMessageType.IMF, "12345", "", "me@test.com", "you@test.com", "", "", "");
    final Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setBody(tx);
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(notifDao);
    repo.add(context, "12345", exchange);
    repo.remove(context, "12345", exchange);
    final Exchange completedExchange = repo.recover(context, exchange.getExchangeId());
    assertNotNull(completedExchange);
    final Tx completedTx = (Tx) completedExchange.getIn().getBody();
    assertEquals("12345", completedTx.getDetail(TxDetailType.MSG_ID).getDetailValue());
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Tx(org.nhindirect.common.tx.model.Tx) ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) Test(org.junit.Test)

Example 7 with Tx

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

the class ConcurrentJPAAggregationRepository_recoverTest method testRecover_exchangeWithCollectionBodyInRepo_assertRecovered.

@Test
@SuppressWarnings("unchecked")
public void testRecover_exchangeWithCollectionBodyInRepo_assertRecovered() {
    final Tx tx1 = TestUtils.makeMessage(TxMessageType.IMF, "12345", "", "me@test.com", "you@test.com", "", "", "");
    final Tx tx2 = TestUtils.makeMessage(TxMessageType.IMF, "67890", "", "me@test2.com", "you@test2.com", "", "", "");
    final Collection<Tx> txs = Arrays.asList(tx1, tx2);
    final Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setBody(txs);
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(notifDao);
    repo.add(context, "12345", exchange);
    repo.remove(context, "12345", exchange);
    final Exchange completedExchange = repo.recover(context, exchange.getExchangeId());
    assertNotNull(completedExchange);
    final Collection<Tx> retrievedTxs = (Collection<Tx>) completedExchange.getIn().getBody();
    assertEquals(2, retrievedTxs.size());
    assertEquals("12345", retrievedTxs.iterator().next().getDetail(TxDetailType.MSG_ID).getDetailValue());
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Tx(org.nhindirect.common.tx.model.Tx) Collection(java.util.Collection) ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) Test(org.junit.Test)

Example 8 with Tx

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

the class ConcurrentJPAAggregationRepository_removeTest method testRemove_exchangeNotInRepo_assertException.

@Test
public void testRemove_exchangeNotInRepo_assertException() {
    final Tx tx = TestUtils.makeMessage(TxMessageType.IMF, "12345", "", "me@test.com", "you@test.com", "", "", "");
    final Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setBody(tx);
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(notifDao);
    boolean exceptionOccured = false;
    try {
        repo.remove(context, "12345", exchange);
    } catch (RuntimeException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Tx(org.nhindirect.common.tx.model.Tx) ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) Test(org.junit.Test)

Example 9 with Tx

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

the class AbstractCompletionCondition_getMessageToTrackTest method testGetMessageToTrack_assertMessageFound.

@Test
public void testGetMessageToTrack_assertMessageFound() {
    ConditionAdapter condition = new ConditionAdapter();
    Tx tx = new Tx(TxMessageType.IMF, new HashMap<String, TxDetail>());
    List<Tx> txs = Arrays.asList(tx);
    Tx foundTx = condition.getMessageToTrackInternal(txs);
    assertEquals(tx, foundTx);
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 10 with Tx

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

the class GeneralCompletionCondition_getIncompleteRecipientsEmptyTxsTest method testIsComplete_noMessageToTrack_emptyTxs.

@Test
public void testIsComplete_noMessageToTrack_emptyTxs() {
    GeneralCompletionCondition condition = new GeneralCompletionCondition();
    Tx originalMessage = TestUtils.makeMessage(TxMessageType.DSN, "", UUID.randomUUID().toString(), "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "");
    Collection<Tx> txs = new ArrayList<Tx>();
    txs.add(originalMessage);
    Collection<String> recips = condition.getIncompleteRecipients(txs);
    assertEquals(0, recips.size());
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) ArrayList(java.util.ArrayList) 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