unmarshalledMessage.put(MessageSchema.MESSAGE_SENT_ON, KapuaDateUtils.formatDate(message.getSentOn())); KapuaPosition kapuaPosition = message.getPosition(); if (kapuaPosition != null) { Map<String, Object> location = null;
private boolean checkThatTheInsertedMessageMatchesTheOriginal(KapuaDataMessage origMsg, DatastoreMessage foundMsg) throws KapuaException { assertTrue(areSemanticPartsEqual(origMsg.getChannel().getSemanticParts(), foundMsg.getChannel().getSemanticParts())); if (origMsg.getPayload() != null) { assertArrayEquals(origMsg.getPayload().getBody(), foundMsg.getPayload().getBody()); assertTrue(areMetricsEqual(origMsg.getPayload().getMetrics(), foundMsg.getPayload().getMetrics())); } assertTrue(arePositionsEqual(origMsg.getPosition(), foundMsg.getPosition())); assertTrue(foundMsg.getTimestamp().compareTo(origMsg.getReceivedOn()) >= 0); assertTrue(foundMsg.getTimestamp().compareTo(new Date(origMsg.getReceivedOn().getTime() + 10000)) <= 0); assertEquals(origMsg.getCapturedOn(), foundMsg.getCapturedOn()); assertEquals(origMsg.getSentOn(), foundMsg.getSentOn()); assertEquals(origMsg.getReceivedOn(), foundMsg.getReceivedOn()); return true; }
private boolean checkThatDatastoreMessagesMatch(DatastoreMessage firstMsg, DatastoreMessage secondMsg) throws KapuaException { assertEquals(firstMsg.getDatastoreId().toString(), secondMsg.getDatastoreId().toString()); assertTrue(areSemanticPartsEqual(firstMsg.getChannel().getSemanticParts(), secondMsg.getChannel().getSemanticParts())); if ((firstMsg.getPayload() != null) || (secondMsg.getPayload() != null)) { assertArrayEquals(firstMsg.getPayload().getBody(), secondMsg.getPayload().getBody()); assertTrue(areMetricsEqual(firstMsg.getPayload().getMetrics(), secondMsg.getPayload().getMetrics())); } assertTrue(arePositionsEqual(firstMsg.getPosition(), secondMsg.getPosition())); assertEquals(firstMsg.getTimestamp(), secondMsg.getTimestamp()); assertEquals(firstMsg.getCapturedOn(), secondMsg.getCapturedOn()); assertEquals(firstMsg.getSentOn(), secondMsg.getSentOn()); assertEquals(firstMsg.getReceivedOn(), secondMsg.getReceivedOn()); return true; }
public JsonDatastoreMessage(DatastoreMessage datastoreMessage) { super(); setId(datastoreMessage.getId()); setDatastoreId(datastoreMessage.getDatastoreId()); setTimestamp(datastoreMessage.getTimestamp()); setScopeId(datastoreMessage.getScopeId()); setDeviceId(datastoreMessage.getDeviceId()); setClientId(datastoreMessage.getClientId()); setReceivedOn(datastoreMessage.getReceivedOn()); setSentOn(datastoreMessage.getSentOn()); setCapturedOn(datastoreMessage.getCapturedOn()); setPosition(datastoreMessage.getPosition()); setChannel((KapuaDataChannel) datastoreMessage.getChannel()); setPayload(datastoreMessage.getPayload()); }