use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository in project nhin-d by DirectProject.
the class ConcurrentJPAAggregationRepository_recoverTest method testRecover_exchangeInRepo_assertRecovered.
@Test
public void testRecover_exchangeInRepo_assertRecovered() {
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);
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());
}
use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository in project nhin-d by DirectProject.
the class ConcurrentJPAAggregationRepository_recoverTest method testRecover_exchangeWithCollectionBodyInRepo_assertRecovered.
@Test
@SuppressWarnings("unchecked")
public void testRecover_exchangeWithCollectionBodyInRepo_assertRecovered() {
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);
repo.remove(context, "12345", exchange);
final Exchange completedExchange = repo.recover(context, exchange.getExchangeId());
assertNotNull(completedExchange);
final Collection<Tx> retrievedTxs = (Collection<Tx>) completedExchange.getIn().getBody();
assertEquals(2, retrievedTxs.size());
assertEquals("12345", retrievedTxs.iterator().next().getDetail(TxDetailType.MSG_ID).getDetailValue());
}
use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository 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);
}
use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository in project nhin-d by DirectProject.
the class ConcurrentJPAAggregationRepository_removeTest method testRemove_exchangeNotInRepo_assertException.
@Test
public void testRemove_exchangeNotInRepo_assertException() {
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);
boolean exceptionOccured = false;
try {
repo.remove(context, "12345", exchange);
} catch (RuntimeException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.monitor.aggregator.repository.ConcurrentJPAAggregationRepository 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);
}
Aggregations