Search in sources :

Example 21 with Aggregation

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

Example 22 with Aggregation

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);
}
Also used : Aggregation(org.nhindirect.monitor.dao.entity.Aggregation) AggregationVersionException(org.nhindirect.monitor.dao.AggregationVersionException) EntityManager(javax.persistence.EntityManager) OptimisticLockException(javax.persistence.OptimisticLockException) AggregationDAOImpl(org.nhindirect.monitor.dao.impl.AggregationDAOImpl) Test(org.junit.Test)

Example 23 with Aggregation

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

Example 24 with Aggregation

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

Example 25 with Aggregation

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

Aggregations

Aggregation (org.nhindirect.monitor.dao.entity.Aggregation)25 Test (org.junit.Test)20 AggregationDAOException (org.nhindirect.monitor.dao.AggregationDAOException)7 AggregationCompleted (org.nhindirect.monitor.dao.entity.AggregationCompleted)6 OptimisticLockException (javax.persistence.OptimisticLockException)3 AggregationVersionException (org.nhindirect.monitor.dao.AggregationVersionException)3 EntityManager (javax.persistence.EntityManager)2 AggregationDAOImpl (org.nhindirect.monitor.dao.impl.AggregationDAOImpl)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Exchange (org.apache.camel.Exchange)1 Buffer (org.fusesource.hawtbuf.Buffer)1