use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_getAggregationCompletedTest method testGetAggregationCompleted_entityManagerException_assertException.
@Test
public void testGetAggregationCompleted_entityManagerException_assertException() throws Exception {
EntityManager mgr = mock(EntityManager.class);
doThrow(new RuntimeException()).when(mgr).find((Class<?>) any(), any());
final AggregationDAOImpl dao = new AggregationDAOImpl();
dao.setEntityManager(mgr);
boolean exceptionOccured = false;
try {
dao.getAggregationCompleted("12345", true);
} catch (AggregationDAOException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_getAggregationKeysTest method testGetAggregationKeys_nullQueryResult_assertEmptyList.
@Test
public void testGetAggregationKeys_nullQueryResult_assertEmptyList() throws Exception {
Query query = mock(Query.class);
when(query.getResultList()).thenReturn(null);
EntityManager mgr = mock(EntityManager.class);
when(mgr.createQuery((String) any())).thenReturn(query);
final AggregationDAOImpl dao = new AggregationDAOImpl();
dao.setEntityManager(mgr);
assertEquals(0, dao.getAggregationKeys().size());
}
use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_validateStateTest method testValidateState_stateOK.
@Test
public void testValidateState_stateOK() throws Exception {
AggregationDAOImpl impl = new AggregationDAOImpl();
impl.setEntityManager(mock(EntityManager.class));
impl.validateState();
}
use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl 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.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_confirmAggregationTest method testConfirmAggregationTest_exceptionInRemove_assertException.
@Test
public void testConfirmAggregationTest_exceptionInRemove_assertException() throws Exception {
EntityManager mgr = mock(EntityManager.class);
doThrow(new RuntimeException()).when(mgr).find((Class<?>) any(), any());
final AggregationDAOImpl dao = new AggregationDAOImpl();
dao.setEntityManager(mgr);
boolean exceptionOccured = false;
try {
dao.confirmAggregation("12345");
} catch (AggregationDAOException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
Aggregations