Search in sources :

Example 6 with ConcurrentJPAAggregationRepository

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

the class ConcurrentJPAAggregationRepository_scanTest method testScan_emptyRepository_assertEmptySet.

@Test
public void testScan_emptyRepository_assertEmptySet() {
    final ConcurrentJPAAggregationRepository repo = new ConcurrentJPAAggregationRepository(notifDao);
    final Set<String> ids = repo.scan(context);
    assertEquals(0, ids.size());
}
Also used : ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) Test(org.junit.Test)

Example 7 with ConcurrentJPAAggregationRepository

use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository 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 8 with ConcurrentJPAAggregationRepository

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

the class ConcurrentJPAAggregationRepository_addTest method testAdd_existingExchange_updateBody_assertExchangeAdded.

@Test
@SuppressWarnings("unchecked")
public void testAdd_existingExchange_updateBody_assertExchangeAdded() {
    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);
    // now update it
    Exchange retrievedEx = repo.get(context, "12345");
    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);
    retrievedEx.getIn().setBody(txs);
    repo.add(context, "12345", retrievedEx);
    retrievedEx = repo.get(context, "12345");
    final Collection<Tx> retrievedTxs = (Collection<Tx>) retrievedEx.getIn().getBody();
    assertEquals(2, retrievedTxs.size());
    assertEquals("12345", retrievedTxs.iterator().next().getDetail(TxDetailType.MSG_ID).getDetailValue());
    final Integer version = (Integer) retrievedEx.getProperty(ConcurrentJPAAggregationRepository.AGGREGATION_ENTITY_VERSON);
    assertEquals(3, version.intValue());
}
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) Collection(java.util.Collection) ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) Test(org.junit.Test)

Example 9 with ConcurrentJPAAggregationRepository

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

the class ConcurrentJPAAggregationRepository_confirmTest method testConfirm_completedExchangeInRepository_assertExchangeRemoved.

@Test
public void testConfirm_completedExchangeInRepository_assertExchangeRemoved() {
    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);
    assertNull(repo.get(context, "12345"));
    final Exchange completedExchange = repo.recover(context, exchange.getExchangeId());
    assertNotNull(completedExchange);
    repo.confirm(context, exchange.getExchangeId());
    assertNull(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) ConcurrentJPAAggregationRepository(org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository) Test(org.junit.Test)

Example 10 with ConcurrentJPAAggregationRepository

use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository 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)

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