Search in sources :

Example 16 with ConcurrentJPAAggregationRepository

use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository in project nhin-d by DirectProject.

the class ConcurrentJPAAggregationRepository_getSetPropertiesTest method testGetSetDeadLetterQueue.

@Test
public void testGetSetDeadLetterQueue() {
    ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository();
    repo.setDeadLetterUri("http://cerner.com");
    assertEquals("http://cerner.com", repo.getDeadLetterUri());
}
Also used : ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) Test(org.junit.Test)

Example 17 with ConcurrentJPAAggregationRepository

use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository in project nhin-d by DirectProject.

the class ConcurrentJPAAggregationRepository_getTest method testGet_daoException_assertException.

@Test
public void testGet_daoException_assertException() throws Exception {
    AggregationDAO dao = mock(AggregationDAO.class);
    doThrow(new RuntimeException()).when(dao).getAggregationCompleted((String) any(), eq(true));
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(dao);
    boolean exceptionOccured = false;
    try {
        repo.recover(context, "12345");
    } catch (RuntimeException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : AggregationDAO(org.nhindirect.monitor.dao.AggregationDAO) ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) Test(org.junit.Test)

Example 18 with ConcurrentJPAAggregationRepository

use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository in project nhin-d by DirectProject.

the class ConcurrentJPAAggregationRepository_getTest method testGet_exchangeInRepository_txBody_assertExchangeFound.

@Test
public void testGet_exchangeInRepository_txBody_assertExchangeFound() throws Exception {
    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);
    final Exchange ex = repo.get(context, "12345");
    assertNotNull(ex);
    final Tx retrievedTx = (Tx) ex.getIn().getBody();
    assertEquals("12345", retrievedTx.getDetail(TxDetailType.MSG_ID).getDetailValue());
    final Integer version = (Integer) ex.getProperty(ConcurrentJPAAggregationRepository.AGGREGATION_ENTITY_VERSON);
    assertEquals(1, version.intValue());
}
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 19 with ConcurrentJPAAggregationRepository

use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository in project nhin-d by DirectProject.

the class ConcurrentJPAAggregationRepository_recoverTest method testRecover_emptyRepository_assertNoRecovery.

@Test
public void testRecover_emptyRepository_assertNoRecovery() {
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(notifDao);
    assertNull(repo.recover(context, "12345"));
}
Also used : ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) Test(org.junit.Test)

Example 20 with ConcurrentJPAAggregationRepository

use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository in project nhin-d by DirectProject.

the class ConcurrentJPAAggregationRepository_removeTest method testRemove_exchangeInRepo_assertRemovedAndCompletedAdded.

@Test
public void testRemove_exchangeInRepo_assertRemovedAndCompletedAdded() {
    final Tx tx = TestUtils.makeMessage(TxMessageType.IMF, "12345", "", "me@test.com", "you@test.com", "", "", "");
    final Exchange exchange = new DefaultExchange(context);
    exchange.setExchangeId(UUID.randomUUID().toString());
    exchange.getIn().setBody(tx);
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(notifDao);
    repo.add(context, "12345", exchange);
    repo.remove(context, "12345", exchange);
    assertNull(repo.get(context, "12345"));
    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 : 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)

Aggregations

ConcurrentJPAAggregationRepository (org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository)33 Test (org.junit.Test)32 Exchange (org.apache.camel.Exchange)15 DefaultExchange (org.apache.camel.impl.DefaultExchange)15 Tx (org.nhindirect.common.tx.model.Tx)15 AggregationDAO (org.nhindirect.monitor.dao.AggregationDAO)9 Collection (java.util.Collection)4