use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_validateStateTest method testValidateState_nullManager_assertIllegalStateException.
@Test
public void testValidateState_nullManager_assertIllegalStateException() throws Exception {
AggregationDAOImpl impl = new AggregationDAOImpl();
boolean exceptionOccured = false;
try {
impl.validateState();
} catch (IllegalStateException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_addUpdateAggregationTest method testAddUpdateAggregationTest_entityManagerException_assertNoAggregation.
@Test
public void testAddUpdateAggregationTest_entityManagerException_assertNoAggregation() throws Exception {
EntityManager mgr = mock(EntityManager.class);
doThrow(new RuntimeException()).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 (AggregationDAOException 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_aggregationNotFound_nothingRemoved.
@Test
public void testConfirmAggregationTest_aggregationNotFound_nothingRemoved() throws Exception {
EntityManager mgr = mock(EntityManager.class);
when(mgr.find((Class<?>) any(), any())).thenReturn(null);
final AggregationDAOImpl dao = new AggregationDAOImpl();
dao.setEntityManager(mgr);
dao.confirmAggregation("12345");
verify(mgr, times(1)).find((Class<?>) any(), any());
verify(mgr, never()).remove(any());
}
use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_getAggregationCompletedKeysTest method testGetAggregationCompletedKeys_nullQueryResult_assertEmptyList.
@Test
public void testGetAggregationCompletedKeys_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.getAggregationCompletedKeys().size());
}
use of org.nhindirect.monitor.dao.impl.AggregationDAOImpl in project nhin-d by DirectProject.
the class AggregationDAOImpl_getAggregationCompletedKeysTest method testGetAggregationCompletedKeys_entityManagerException_assertNoAggregation.
@Test
public void testGetAggregationCompletedKeys_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.getAggregationCompletedKeys();
} catch (AggregationDAOException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
Aggregations