use of org.nhindirect.monitor.dao.entity.Aggregation in project nhin-d by DirectProject.
the class ConcurrentJPAAggregationRepository method get.
/**
* {@inheritDoc}
*/
@Override
public Exchange get(CamelContext camelContext, String key) {
Exchange retVal = null;
try {
// get the aggregation
final Aggregation agg = dao.getAggregation(key);
if (agg == null)
return null;
// deserialized to an exchange object
retVal = codec.unmarshallExchange(camelContext, new Buffer(agg.getExchangeBlob()));
// set the version of the exchange for later consistency checking
retVal.setProperty(AGGREGATION_ENTITY_VERSON, agg.getVersion());
} catch (Exception e) {
// wrap exception in a runtime exception
throw new RuntimeException("Error retrieving from repository aggregation with key " + key, e);
}
return retVal;
}
use of org.nhindirect.monitor.dao.entity.Aggregation in project nhin-d by DirectProject.
the class AggregationDAOImpl_getAggregationCompletedKeysTest method testGetAggregationCompletedKeys_singleEntryInRepository_assertKeysRetrieved.
@Test
public void testGetAggregationCompletedKeys_singleEntryInRepository_assertKeysRetrieved() 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");
List<String> keys = notifDao.getAggregationCompletedKeys();
assertEquals(1, keys.size());
assertEquals("12345", keys.iterator().next());
}
use of org.nhindirect.monitor.dao.entity.Aggregation in project nhin-d by DirectProject.
the class AggregationDAOImpl_getAggregationKeysTest method testGetAggregationKeys_singleEntryInRepository_assertKeysRetrieved.
@Test
public void testGetAggregationKeys_singleEntryInRepository_assertKeysRetrieved() throws Exception {
final Aggregation insert = new Aggregation();
insert.setExchangeBlob(new byte[] { 0, 3, 2 });
insert.setId("12345");
insert.setVersion(0);
notifDao.addUpdateAggregation(insert);
List<String> keys = notifDao.getAggregationKeys();
assertEquals(1, keys.size());
assertEquals("12345", keys.iterator().next());
}
use of org.nhindirect.monitor.dao.entity.Aggregation in project nhin-d by DirectProject.
the class AggregationDAOImpl_removeAggregationTest method testRemoveAggregation_removeAggregation_incorrectVersion_assertException.
@Test
public void testRemoveAggregation_removeAggregation_incorrectVersion_assertException() 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(3);
boolean exceptionOccured = false;
try {
notifDao.removeAggregation(remove, "12345");
} catch (AggregationDAOException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.monitor.dao.entity.Aggregation in project nhin-d by DirectProject.
the class AggregationDAOImpl_removeAggregationTest method testRemoveAggregation_removeAggregation_assertRemovedAndCompletedRepositry.
@Test
public void testRemoveAggregation_removeAggregation_assertRemovedAndCompletedRepositry() 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");
assertNull(notifDao.getAggregation("12345"));
final AggregationCompleted completed = notifDao.getAggregationCompleted("12345", true);
assertNotNull(completed);
assertEquals("12345", completed.getId());
assertEquals(3, completed.getVersion());
assertTrue(Arrays.equals(remove.getExchangeBlob(), completed.getExchangeBlob()));
}
Aggregations