use of org.nhindirect.monitor.dao.entity.Aggregation in project nhin-d by DirectProject.
the class AggregationDAOImpl_addUpdateAggregationTest method testAddUpdateAggregationTest_emptyRepository_addNon0Version_assertException.
@Test
public void testAddUpdateAggregationTest_emptyRepository_addNon0Version_assertException() throws Exception {
final Aggregation insert = new Aggregation();
insert.setExchangeBlob(new byte[] { 0, 3, 2 });
insert.setId("12345");
insert.setVersion(1);
boolean exceptionOccured = false;
try {
notifDao.addUpdateAggregation(insert);
} catch (AggregationDAOException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
final Aggregation aggr = notifDao.getAggregation("12345");
assertNull(aggr);
}
use of org.nhindirect.monitor.dao.entity.Aggregation in project nhin-d by DirectProject.
the class AggregationDAOImpl_addUpdateAggregationTest method testAddUpdateAggregationTest_optomisticLockException_assertAggregationVersionException.
@Test
public void testAddUpdateAggregationTest_optomisticLockException_assertAggregationVersionException() throws Exception {
EntityManager mgr = mock(EntityManager.class);
doThrow(new OptimisticLockException()).when(mgr).persist(any());
final AggregationDAOImpl dao = new AggregationDAOImpl();
dao.setEntityManager(mgr);
boolean exceptionOccured = false;
try {
final Aggregation insert = new Aggregation();
insert.setExchangeBlob(new byte[] { 0, 3, 2 });
insert.setId("12345");
insert.setVersion(0);
dao.addUpdateAggregation(insert);
} catch (AggregationVersionException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.monitor.dao.entity.Aggregation in project nhin-d by DirectProject.
the class AggregationDAOImpl_addUpdateAggregationTest method testAddUpdateAggregationTest_emptyRepository_assertAggregationAdded.
@Test
public void testAddUpdateAggregationTest_emptyRepository_assertAggregationAdded() throws Exception {
final Aggregation insert = new Aggregation();
insert.setExchangeBlob(new byte[] { 0, 3, 2 });
insert.setId("12345");
insert.setVersion(0);
notifDao.addUpdateAggregation(insert);
final Aggregation aggr = notifDao.getAggregation("12345");
assertNotNull(aggr);
assertEquals(insert, aggr);
}
use of org.nhindirect.monitor.dao.entity.Aggregation in project nhin-d by DirectProject.
the class AggregationDAOImpl_addUpdateAggregationTest method testAddUpdateAggregationTest_updateExisting_assertAggregationUpdated.
@Test
public void testAddUpdateAggregationTest_updateExisting_assertAggregationUpdated() throws Exception {
final Aggregation insert = new Aggregation();
insert.setExchangeBlob(new byte[] { 0, 3, 2 });
insert.setId("12345");
insert.setVersion(0);
notifDao.addUpdateAggregation(insert);
final Aggregation insert2 = new Aggregation();
insert2.setExchangeBlob(new byte[] { 0, 3, 2, 4, 1, 32 });
insert2.setVersion(1);
insert2.setId("12345");
notifDao.addUpdateAggregation(insert2);
final Aggregation aggr = notifDao.getAggregation("12345");
assertNotNull(aggr);
assertEquals(insert, aggr);
}
use of org.nhindirect.monitor.dao.entity.Aggregation in project nhin-d by DirectProject.
the class AggregationDAOImpl_confirmAggregationTest method testConfirmAggregationTest_aggregationRemoved.
@Test
public void testConfirmAggregationTest_aggregationRemoved() throws Exception {
final Aggregation insert = new Aggregation();
insert.setExchangeBlob(new byte[] { 0, 3, 2 });
insert.setId("12345");
insert.setVersion(0);
notifDao.addUpdateAggregation(insert);
assertNotNull(notifDao.getAggregation("12345"));
final Aggregation remove = new Aggregation();
remove.setExchangeBlob(new byte[] { 0, 3, 2 });
remove.setId("12345");
remove.setVersion(1);
notifDao.removeAggregation(remove, "12345");
assertNotNull(notifDao.getAggregationCompleted("12345", true));
notifDao.confirmAggregation("12345");
assertNull(notifDao.getAggregationCompleted("12345", true));
}
Aggregations