@Override public String marshal(StorableId v) throws Exception { return v.toString(); }
@Override public StorableId unmarshal(String v) throws Exception { return STORABLE_ID_FACTORY.newStorableId(v); }
/** * Get the metric identifier getting parameters from the metricInfo. Then it calls {@link MetricInfoField#getOrDeriveId(StorableId id, KapuaId scopeId, String clientId, String channel, String * metricName, Class metricType)} * * @param id * @param metricInfo * @return */ public static String getOrDeriveId(StorableId id, MetricInfo metricInfo) { return getOrDeriveId(id, metricInfo.getScopeId(), metricInfo.getClientId(), metricInfo.getChannel(), metricInfo.getName(), metricInfo.getMetricType()); }
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()); }
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; }
private Map<String, Object> marshalChannelInfo(ChannelInfo channelInfo) throws ParseException { Map<String, Object> unmarshalledChannelInfo = new HashMap<>(); unmarshalledChannelInfo.put(ChannelInfoSchema.CHANNEL_NAME, channelInfo.getName()); unmarshalledChannelInfo.put(ChannelInfoSchema.CHANNEL_TIMESTAMP, KapuaDateUtils.formatDate(channelInfo.getFirstMessageOn())); unmarshalledChannelInfo.put(ChannelInfoSchema.CHANNEL_CLIENT_ID, channelInfo.getClientId()); unmarshalledChannelInfo.put(ChannelInfoSchema.CHANNEL_SCOPE_ID, channelInfo.getScopeId().toStringId()); unmarshalledChannelInfo.put(ChannelInfoSchema.CHANNEL_MESSAGE_ID, channelInfo.getFirstMessageId().toString()); return unmarshalledChannelInfo; }
private Map<String, Object> marshalClientInfo(ClientInfo clientInfo) throws ParseException { Map<String, Object> unmarshalledClientInfo = new HashMap<>(); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_ID, clientInfo.getClientId()); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_MESSAGE_ID, clientInfo.getFirstMessageId().toString()); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_TIMESTAMP, KapuaDateUtils.formatDate(clientInfo.getFirstMessageOn())); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_SCOPE_ID, clientInfo.getScopeId().toStringId()); return unmarshalledClientInfo; }
@Then("^The metric \"(.+)\" was first published in the list \"(.+)\" on \"(.+)\"$") public void checkFirstPublishDateOfMetricInList(String metric, String lstKey, String date) throws Exception { MetricInfoListResult metList = (MetricInfoListResult) stepData.get(lstKey); Date tmpCaptured = KapuaDateUtils.parseDate(date); for (MetricInfo tmpMet : metList.getItems()) { if (tmpMet.getName().equals(metric)) { assertEquals(tmpMet.getFirstMessageOn(), tmpCaptured); return; } } fail(String.format("There is no metric [%s]", metric)); }
/** * Get the metric identifier getting parameters from the metricInfoCreator. Then it calls {@link MetricInfoField#getOrDeriveId(StorableId id, KapuaId scopeId, String clientId, String channel, String * metricName, Class metricType)} * * @param id * @param metricInfoCreator * @return */ public static String getOrDeriveId(StorableId id, @SuppressWarnings("rawtypes") MetricInfoCreator metricInfoCreator) { return getOrDeriveId(id, metricInfoCreator.getScopeId(), metricInfoCreator.getClientId(), metricInfoCreator.getChannel(), metricInfoCreator.getName(), metricInfoCreator.getMetricType());// use short me }
/** * Get the channel identifier getting parameters from the channelInfo. Then it calls {@link ChannelInfoField#getOrDeriveId(StorableId id, KapuaId scopeId, String clientId, String channel)} * * @param id * @param channelInfo * @return */ public static String getOrDeriveId(StorableId id, ChannelInfo channelInfo) { return getOrDeriveId(id, channelInfo.getScopeId(), channelInfo.getClientId(), channelInfo.getName()); }
@When("^I delete all channels from the list \"(.*)\"$") public void deleteAllChannelsFromList(String lstKey) throws KapuaException { Account account = (Account) stepData.get("LastAccount"); ChannelInfoListResult tmpList = (ChannelInfoListResult) stepData.get(lstKey); for (ChannelInfo tmpItem : tmpList.getItems()) { channelInfoRegistryServiceProxy.delete(account.getId(), tmpItem.getId()); } }
@When("^I delete all clients from the list \"(.*)\"$") public void deleteAllClientsFromList(String lstKey) throws KapuaException { Account account = (Account) stepData.get("LastAccount"); ClientInfoListResult tmpList = (ClientInfoListResult) stepData.get(lstKey); for (ClientInfo tmpItem : tmpList.getItems()) { clientInfoRegistryServiceProxy.delete(account.getId(), tmpItem.getId()); } }
@When("^I delete all metrics from the list \"(.*)\"$") public void deleteAllMetricsFromList(String lstKey) throws KapuaException { Account account = (Account) stepData.get("LastAccount"); MetricInfoListResult tmpList = (MetricInfoListResult) stepData.get(lstKey); for (MetricInfo tmpItem : tmpList.getItems()) { metricInfoRegistryServiceProxy.delete(account.getId(), tmpItem.getId()); } }
/** * Get the channel identifier getting parameters from the metricInfoCreator. Then it calls {@link ChannelInfoField#getOrDeriveId(StorableId id, KapuaId scopeId, String clientId, String channel)} * * @param id * @param channelInfoCreator * @return */ public static String getOrDeriveId(StorableId id, ChannelInfoCreator channelInfoCreator) { return getOrDeriveId(id, channelInfoCreator.getScopeId(), channelInfoCreator.getClientId(), channelInfoCreator.getName()); }
/** * Get the client identifier (combining accountName and clientId).<br> * <b>If the id is null then it is generated</b> * * @param id * @param clientInfo * @return */ public static String getOrDeriveId(StorableId id, ClientInfo clientInfo) { return getOrDeriveId(id, clientInfo.getScopeId(), clientInfo.getClientId()); }
@When("^I pick the ID of the channel number (\\d+) in the list \"(.*)\" and remember it as \"(.*)\"$") public void pickAChannelIdFromAList(int index, String lstKey, String idKey) { ChannelInfoListResult tmpLst = (ChannelInfoListResult) stepData.get(lstKey); StorableId tmpId = tmpLst.getItem(index).getId(); stepData.put(idKey, tmpId); }
@When("^I delete client number (\\d+) from the list \"(.*)\"$") public void deleteClientFromList(int index, String lstKey) throws KapuaException { Account account = (Account) stepData.get("LastAccount"); ClientInfoListResult tmpList = (ClientInfoListResult) stepData.get(lstKey); clientInfoRegistryServiceProxy.delete(account.getId(), tmpList.getItem(index).getId()); }
@When("^I pick message number (\\d+) from the list \"(.+)\" and remember it as \"(.+)\"$") public void pickADatastoreMessageFromList(int index, String lstKey, String msgKey) { MessageListResult tmpList = (MessageListResult) stepData.get(lstKey); DatastoreMessage tmpMsg = tmpList.getItem(index); stepData.put(msgKey, tmpMsg); }
@Override public String marshal(StorableId v) throws Exception { return v.toString(); }
@Override public StorableId unmarshal(String v) throws Exception { return STORABLE_ID_FACTORY.newStorableId(v); }