Search in sources :

Example 16 with AggregationDAOException

use of org.nhindirect.monitor.dao.AggregationDAOException 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);
}
Also used : Aggregation(org.nhindirect.monitor.dao.entity.Aggregation) AggregationDAOException(org.nhindirect.monitor.dao.AggregationDAOException) Test(org.junit.Test)

Example 17 with AggregationDAOException

use of org.nhindirect.monitor.dao.AggregationDAOException 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);
}
Also used : EntityManager(javax.persistence.EntityManager) AggregationDAOException(org.nhindirect.monitor.dao.AggregationDAOException) AggregationDAOImpl(org.nhindirect.monitor.dao.impl.AggregationDAOImpl) Test(org.junit.Test)

Aggregations

AggregationDAOException (org.nhindirect.monitor.dao.AggregationDAOException)17 Test (org.junit.Test)10 OptimisticLockException (javax.persistence.OptimisticLockException)7 AggregationVersionException (org.nhindirect.monitor.dao.AggregationVersionException)7 Aggregation (org.nhindirect.monitor.dao.entity.Aggregation)7 Transactional (org.springframework.transaction.annotation.Transactional)7 EntityManager (javax.persistence.EntityManager)6 AggregationDAOImpl (org.nhindirect.monitor.dao.impl.AggregationDAOImpl)6 Query (javax.persistence.Query)3 AggregationCompleted (org.nhindirect.monitor.dao.entity.AggregationCompleted)3 Calendar (java.util.Calendar)1