use of org.eclipse.kapua.service.datastore.DatastoreObjectFactory in project kapua by eclipse.
the class MessageStoreServiceTest method testStore.
@Test
public void testStore() throws Exception {
KapuaId scopeId = new KapuaEid(BigInteger.valueOf(1));
long accountSerial = (new Date()).getTime();
AccountCreator accountCreator = this.getTestAccountCreator(scopeId, accountSerial);
MessageStoreService messageStoreService = locator.getService(MessageStoreService.class);
DatastoreObjectFactory dsObjectFactory = locator.getFactory(DatastoreObjectFactory.class);
MessageCreator messageCreator = dsObjectFactory.newMessageCreator();
Payload messagePayload = dsObjectFactory.newPayload();
Position messagePosition = dsObjectFactory.newPosition();
Map<String, Object> metrics = new HashMap<String, Object>();
Date now = new Date();
messageCreator.setTimestamp(now);
messageCreator.setReceivedOn(now);
String topicName = String.format("%s/CLIENT001/APP01", accountCreator.getName());
messageCreator.setTopic(topicName);
metrics.put("metric_long", 1L);
metrics.put("metric_string", "pippo");
messagePayload.setMetrics(metrics);
messagePayload.setCollectedOn(now);
messagePosition.setAltitude(1.0);
messagePosition.setTimestamp(now);
messagePayload.setPosition(messagePosition);
messagePayload.setMetrics(metrics);
messageCreator.setPayload(messagePayload);
// FIXME store fails fix it !!
// StorableId messageId = messageStoreService.store(scopeId, messageCreator);
//
// Message asserts
// assertNotNull(messageId);
// assertTrue(!messageId.toString().isEmpty());
}
Aggregations