Search in sources :

Example 1 with AggregationDAO

use of org.nhindirect.monitor.dao.AggregationDAO in project nhin-d by DirectProject.

the class ConcurrentJPAAggregationRepository_recoverTest method testRecover_daoException_assertException.

@Test
public void testRecover_daoException_assertException() throws Exception {
    AggregationDAO dao = mock(AggregationDAO.class);
    doThrow(new RuntimeException()).when(dao).getAggregation((String) any());
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(dao);
    boolean exceptionOccured = false;
    try {
        repo.get(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 2 with AggregationDAO

use of org.nhindirect.monitor.dao.AggregationDAO in project nhin-d by DirectProject.

the class ConcurrentJPAAggregationRepository_scanTest method testScan_daoException_assertException.

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

use of org.nhindirect.monitor.dao.AggregationDAO in project nhin-d by DirectProject.

the class TestFailedRemovedExchangeMonitorRoute method postProcessTest.

@Override
public void postProcessTest() throws Exception {
    super.postProcessTest();
    final AggregationDAO dao = (AggregationDAO) context.getRegistry().lookup("errorGenAggregationDAO");
    dao.purgeAll();
    assertEquals(0, dao.getAggregationKeys().size());
    assertEquals(0, dao.getAggregationCompletedKeys().size());
}
Also used : AggregationDAO(org.nhindirect.monitor.dao.AggregationDAO)

Example 4 with AggregationDAO

use of org.nhindirect.monitor.dao.AggregationDAO in project nhin-d by DirectProject.

the class TestMultithreadedAddUpdateFailureMonitoringRoute method postProcessTest.

@Override
public void postProcessTest() throws Exception {
    super.postProcessTest();
    final AggregationDAO dao = (AggregationDAO) context.getRegistry().lookup("aggregationDAO");
    dao.purgeAll();
    assertEquals(0, dao.getAggregationKeys().size());
    assertEquals(0, dao.getAggregationCompletedKeys().size());
}
Also used : AggregationDAO(org.nhindirect.monitor.dao.AggregationDAO)

Example 5 with AggregationDAO

use of org.nhindirect.monitor.dao.AggregationDAO in project nhin-d by DirectProject.

the class TestRecoveryMonitorRoute method testRecoverFromRepository.

@Test
public void testRecoverFromRepository() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    boolean exchangeFound = false;
    int cnt = 0;
    List<Exchange> exchanges = null;
    while (cnt < 10) {
        exchanges = mock.getReceivedExchanges();
        if (exchanges.size() == 1) {
            exchangeFound = true;
            break;
        }
        ++cnt;
        Thread.sleep(2000);
    }
    assertTrue(exchangeFound);
    Tx originalMessage = (Tx) exchanges.iterator().next().getIn().getBody();
    assertEquals("gm2552@cerner.com", originalMessage.getDetail(TxDetailType.FROM).getDetailValue());
    // make sure everything got confirmed
    final AggregationDAO dao = (AggregationDAO) context.getRegistry().lookup("aggregationDAO");
    assertEquals(0, dao.getAggregationKeys().size());
    assertEquals(0, dao.getAggregationCompletedKeys().size());
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) Tx(org.nhindirect.common.tx.model.Tx) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) AggregationDAO(org.nhindirect.monitor.dao.AggregationDAO) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Aggregations

AggregationDAO (org.nhindirect.monitor.dao.AggregationDAO)17 Test (org.junit.Test)9 ConcurrentJPAAggregationRepository (org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository)9 Exchange (org.apache.camel.Exchange)2 DefaultExchange (org.apache.camel.impl.DefaultExchange)2 Tx (org.nhindirect.common.tx.model.Tx)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)1