use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_getAggregationCompletedKeysTest method testGetAggregationCompletedKeys_emptyListResultSet_assertEmptyList.
@Test
public void testGetAggregationCompletedKeys_emptyListResultSet_assertEmptyList() throws Exception {
Query query = mock(Query.class);
when(query.getResultList()).thenReturn(Collections.emptyList());
EntityManager mgr = mock(EntityManager.class);
when(mgr.createQuery((String) any())).thenReturn(query);
final AggregationDAOImpl dao = new AggregationDAOImpl();
dao.setEntityManager(mgr);
assertEquals(0, dao.getAggregationCompletedKeys().size());
}
use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_getAggregationCompletedTest method testGetAggregationCompleted_optomisticLockException_assertAggregationCompletedNotFound.
@Test
public void testGetAggregationCompleted_optomisticLockException_assertAggregationCompletedNotFound() throws Exception {
EntityManager mgr = mock(EntityManager.class);
doThrow(new OptimisticLockException()).when(mgr).find((Class<?>) any(), any());
final AggregationDAOImpl dao = new AggregationDAOImpl();
dao.setEntityManager(mgr);
final AggregationCompleted lockedAggr = dao.getAggregationCompleted("12345", true);
assertNull(lockedAggr);
}
use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_getAggregationKeysTest method testGetAggregationKeys_entityManagerException_assertNoAggregation.
@Test
public void testGetAggregationKeys_entityManagerException_assertNoAggregation() throws Exception {
EntityManager mgr = mock(EntityManager.class);
doThrow(new RuntimeException()).when(mgr).createQuery((String) any());
final AggregationDAOImpl dao = new AggregationDAOImpl();
dao.setEntityManager(mgr);
boolean exceptionOccured = false;
try {
dao.getAggregationKeys();
} 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_emptyListResultSet_assertEmptyList.
@Test
public void testGetAggregationKeys_emptyListResultSet_assertEmptyList() throws Exception {
Query query = mock(Query.class);
when(query.getResultList()).thenReturn(Collections.emptyList());
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_getAggregationTest method testGetAggregation_entityManagerException_assertNoAggregation.
@Test
public void testGetAggregation_entityManagerException_assertNoAggregation() 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.getAggregation("12345");
} catch (AggregationDAOException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
Aggregations