Search in sources :

Example 6 with AggregationDAO

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

the class TestRecoveryMonitorRoute method postProcessTest.

@Override
public void postProcessTest() throws Exception {
    super.postProcessTest();
    final AggregationDAO dao = (AggregationDAO) context.getRegistry().lookup("shortRecoveryIntervalAggregationDAO");
    dao.purgeAll();
    assertEquals(0, dao.getAggregationKeys().size());
    assertEquals(0, dao.getAggregationCompletedKeys().size());
    // pre populate some recovery data
    // send original message
    final String originalMessageId = UUID.randomUUID().toString();
    final Tx originalMessage = TestUtils.makeMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com,ah4626@direct.securehealthemail.com", "");
    final Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setBody(originalMessage);
    final ConcurrentJPAAggregationRepository repo = (ConcurrentJPAAggregationRepository) context.getRegistry().lookup("monitoringRepo");
    repo.add(context, originalMessageId, exchange);
    repo.remove(context, originalMessageId, exchange);
    // lock the row to create a delay and ensure we recover 
    // exchange ids that return null at some point
    repo.recover(context, exchange.getExchangeId());
}
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) AggregationDAO(org.nhindirect.monitor.dao.AggregationDAO) ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository)

Example 7 with AggregationDAO

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

the class TestTimedOutMonitorRoute 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 8 with AggregationDAO

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

the class ConcurrentJPAAggregationRepository_doStartTest method testDoStart_nonEmptyAggregation_assertNoException.

@Test
public void testDoStart_nonEmptyAggregation_assertNoException() throws Exception {
    AggregationDAO dao = mock(AggregationDAO.class);
    when(dao.getAggregationKeys()).thenReturn(Arrays.asList("12345"));
    when(dao.getAggregationCompletedKeys()).thenReturn(Arrays.asList("12345"));
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(dao);
    repo.doStart();
    repo.doStop();
}
Also used : AggregationDAO(org.nhindirect.monitor.dao.AggregationDAO) ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) Test(org.junit.Test)

Example 9 with AggregationDAO

use of org.nhindirect.monitor.dao.AggregationDAO 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 10 with AggregationDAO

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

the class ConcurrentJPAAggregationRepository_scanTest method testScan_nullKeys_assertEmptySet.

@Test
public void testScan_nullKeys_assertEmptySet() throws Exception {
    AggregationDAO dao = mock(AggregationDAO.class);
    when(dao.getAggregationCompletedKeys()).thenReturn(null);
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(notifDao);
    final Set<String> ids = repo.scan(context);
    assertEquals(0, ids.size());
}
Also used : AggregationDAO(org.nhindirect.monitor.dao.AggregationDAO) ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) 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