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("^Client \"(.+)\" first message in the list \"(.+)\" is on \"(.+)\"$") public void checkFirstPublishDateForClient(String clientId, String lstKey, String date) throws Exception { ClientInfoListResult cliList = (ClientInfoListResult) stepData.get(lstKey); Date tmpCaptured = KapuaDateUtils.parseDate(date); for (ClientInfo tmpInfo : cliList.getItems()) { if (tmpInfo.getClientId().equals(clientId)) { assertEquals(tmpInfo.getFirstMessageOn(), tmpCaptured); return; } } fail(String.format("No client info item matches the client id [%s]", clientId)); }
messageQuery.setSortFields(sort); RangePredicate messageIdPredicate = new RangePredicateImpl(new StorableFieldImpl(ClientInfoSchema.CLIENT_TIMESTAMP), clientInfo.getFirstMessageOn(), null); TermPredicate clientIdPredicate = storablePredicateFactory.newTermPredicate(MessageField.CLIENT_ID, clientInfo.getClientId());
ArgumentValidator.notNull(clientInfo.getScopeId(), "clientInfo.scopeId"); ArgumentValidator.notNull(clientInfo.getFirstMessageId(), "clientInfo.firstPublishedMessageId"); ArgumentValidator.notNull(clientInfo.getFirstMessageOn(), "clientInfo.firstPublishedMessageTimestamp"); Metadata metadata = mediator.getMetadata(clientInfo.getScopeId(), clientInfo.getFirstMessageOn().getTime()); String kapuaIndexName = metadata.getRegistryIndexName();
private void isClientForFirstMessageInStoreOK(StorableId msgId, Date storedOn) throws KapuaException { KapuaId tmpAccId = ((Account) stepData.get("LastAccount")).getId(); String tmpClId = ((Device) stepData.get("LastDevice")).getClientId(); AndPredicate andPredicate = new AndPredicateImpl(); andPredicate.getPredicates().add(new TermPredicateImpl(ClientInfoField.CLIENT_ID, tmpClId)); ClientInfoQuery clientInfoQuery = DatastoreQueryFactory.createBaseClientInfoQuery(tmpAccId, 100); clientInfoQuery.setPredicate(andPredicate); clientInfoQuery.addFetchAttributes(ClientInfoField.TIMESTAMP.field()); ClientInfoListResult clientInfoList = clientInfoRegistryService.query(clientInfoQuery); assertNotNull("Cannot find the client info registry!", clientInfoList); assertNotEquals("Cannot find the client info registry!", clientInfoList.getSize(), 0); assertNotNull("Cannot find the client info registry!", clientInfoList.getFirstItem()); assertEquals("Wrong client info message id!", clientInfoList.getFirstItem().getFirstMessageId(), msgId); assertEquals("Wrong client info message on!", clientInfoList.getFirstItem().getFirstMessageOn(), storedOn); }