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());
}
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);
}
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());
}
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"));
}
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());
}
Aggregations