Search in sources :

Example 31 with ConcurrentJPAAggregationRepository

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

the class ConcurrentJPAAggregationRepository_getKeysTest method testGetKeys_daoException_assertException.

@Test
public void testGetKeys_daoException_assertException() throws Exception {
    AggregationDAO dao = mock(AggregationDAO.class);
    doThrow(new RuntimeException()).when(dao).getAggregationKeys();
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(dao);
    boolean exceptionOccured = false;
    try {
        repo.getKeys();
    } 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 32 with ConcurrentJPAAggregationRepository

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

the class ConcurrentJPAAggregationRepository_getTest method testGet_exchangeInRepository_txCollectionBody_assertExchangeFound.

@Test
@SuppressWarnings("unchecked")
public void testGet_exchangeInRepository_txCollectionBody_assertExchangeFound() throws Exception {
    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);
    final Exchange ex = repo.get(context, "12345");
    assertNotNull(ex);
    final Collection<Tx> retrievedTxs = (Collection<Tx>) ex.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 33 with ConcurrentJPAAggregationRepository

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

the class ConcurrentJPAAggregationRepository_getTest method testGet_emptyRepository_assertNull.

@Test
public void testGet_emptyRepository_assertNull() throws Exception {
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(notifDao);
    assertNull(repo.get(context, "12345"));
}
Also used : 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