Ngsi2Client { public ListenableFuture<Paginated<Entity>> bulkQuery(BulkQueryRequest bulkQueryRequest, Collection<String> orderBy, int offset, int limit, boolean count) { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseURL); builder.path("v2/op/query"); addPaginationParams(builder, offset, limit); addParam(builder, "orderBy", orderBy); if (count) { addParam(builder, "options", "count"); } return adaptPaginated(request(HttpMethod.POST, builder.toUriString(), bulkQueryRequest, Entity[].class), offset, limit); } private  Ngsi2Client();  Ngsi2Client(AsyncRestTemplate asyncRestTemplate, String baseURL); ListenableFuture<Map<String, String>> getV2(); ListenableFuture<Paginated<Entity>> getEntities(Collection<String> ids, String idPattern,
            Collection<String> types, Collection<String> attrs,
            int offset, int limit, boolean count); ListenableFuture<Paginated<Entity>> getEntities(Collection<String> ids, String idPattern,
                                                           Collection<String> types, Collection<String> attrs,
                                                           String query, GeoQuery geoQuery,
                                                           Collection<String> orderBy,
                                                           int offset, int limit, boolean count); ListenableFuture<Void> addEntity(Entity entity); ListenableFuture<Entity> getEntity(String entityId, String type, Collection<String> attrs); ListenableFuture<Void> updateEntity(String entityId, String type, Map<String, Attribute> attributes, boolean append); ListenableFuture<Void> replaceEntity(String entityId, String type, Map<String, Attribute> attributes); ListenableFuture<Void> deleteEntity(String entityId, String type); ListenableFuture<Attribute> getAttribute(String entityId, String type, String attributeName); ListenableFuture<Void> updateAttribute(String entityId, String type, String attributeName, Attribute attribute); ListenableFuture<Attribute> deleteAttribute(String entityId, String type, String attributeName); ListenableFuture<Object> getAttributeValue(String entityId, String type, String attributeName); ListenableFuture<String> getAttributeValueAsString(String entityId, String type, String attributeName); ListenableFuture<Paginated<EntityType>> getEntityTypes(int offset, int limit, boolean count); ListenableFuture<EntityType> getEntityType(String entityType); ListenableFuture<List<Registration>> getRegistrations(); ListenableFuture<Void> addRegistration(Registration registration); ListenableFuture<Registration> getRegistration(String registrationId); ListenableFuture<Void> updateRegistration(String registrationId, Registration registration); ListenableFuture<Void> deleteRegistration(String registrationId); ListenableFuture<Paginated<Subscription>> getSubscriptions(int offset, int limit, boolean count); ListenableFuture<String> addSubscription(Subscription subscription); ListenableFuture<Subscription> getSubscription(String subscriptionId); ListenableFuture<Void> updateSubscription(String subscriptionId, Subscription subscription); ListenableFuture<Void> deleteSubscription(String subscriptionId); ListenableFuture<Void> bulkUpdate(BulkUpdateRequest bulkUpdateRequest); ListenableFuture<Paginated<Entity>> bulkQuery(BulkQueryRequest bulkQueryRequest, Collection<String> orderBy, int offset, int limit, boolean count); ListenableFuture<String[]> bulkRegister(BulkRegisterRequest bulkRegisterRequest); ListenableFuture<Paginated<Registration>> bulkDiscover(BulkQueryRequest bulkQueryRequest, int offset, int limit, boolean count); HttpHeaders getHttpHeaders();  }
@Test public void testBulkQuery_OK() throws Exception { mockServer.expect(requestTo(baseURL + "/v2/op/query?offset=20&limit=40&orderBy=temp&options=count")) .andExpect(method(HttpMethod.POST)) .andExpect(header("Content-Type", MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.entities[0].id").value("room1")) .andExpect(jsonPath("$.entities[0].type").value("Room")) .andExpect(jsonPath("$.attributes[0]").value("temp")) .andExpect(jsonPath("$.scopes[0].type").value("FIWARE::Geo::Distance")) .andExpect(jsonPath("$.scopes[0].value").value("2.23,43.56")) .andRespond(withSuccess(Utils.loadResource("json/postQueryResponse.json"), MediaType.APPLICATION_JSON)); SubjectEntity subjectEntity = new SubjectEntity(); subjectEntity.setId(Optional.of("room1")); subjectEntity.setType(Optional.of("Room")); BulkQueryRequest request = new BulkQueryRequest(); request.setEntities(Collections.singletonList(subjectEntity)); request.setAttributes(Collections.singletonList("temp")); request.setScopes(Collections.singletonList(new Scope("FIWARE::Geo::Distance", "2.23,43.56"))); Paginated<Entity> results = ngsiClient.bulkQuery(request, Collections.singletonList("temp"), 20, 40, true).get(); assertNotNull(results); assertNotNull(results.getItems()); assertEquals(3, results.getItems().size()); assertNotNull(results.getItems().get(0)); assertEquals(35.6, results.getItems().get(0).getAttributes().get("temperature").getValue()); }