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; }
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); }
ArgumentValidator.notNull(clientInfo, "clientInfo"); ArgumentValidator.notNull(clientInfo.getScopeId(), "clientInfo.scopeId"); ArgumentValidator.notNull(clientInfo.getFirstMessageId(), "clientInfo.firstPublishedMessageId"); ArgumentValidator.notNull(clientInfo.getFirstMessageOn(), "clientInfo.firstPublishedMessageTimestamp");