NgsiRestClient extends NgsiClient { public ListenableFuture<AppendContextElementResponse> appendContextElement(String url, HttpHeaders httpHeaders, String entityID, AppendContextElement appendContextElement) { return request(HttpMethod.POST, url + entitiesPath + entityID, httpHeaders, appendContextElement, AppendContextElementResponse.class); }  ListenableFuture<AppendContextElementResponse> appendContextElement(String url, HttpHeaders httpHeaders, String entityID, AppendContextElement appendContextElement); ListenableFuture<UpdateContextElementResponse> updateContextElement(String url, HttpHeaders httpHeaders, String entityID, UpdateContextElement updateContextElement); ListenableFuture<ContextElementResponse> getContextElement(String url, HttpHeaders httpHeaders, String entityID); ListenableFuture<StatusCode> deleteContextElement(String url, HttpHeaders httpHeaders, String entityID); ListenableFuture<StatusCode> appendContextAttribute(String url, HttpHeaders httpHeaders, String entityID, String attributeName, UpdateContextAttribute updateContextAttribute); ListenableFuture<StatusCode> updateContextAttribute(String url, HttpHeaders httpHeaders, String entityID, String attributeName, UpdateContextAttribute updateContextAttribute); ListenableFuture<ContextAttributeResponse> getContextAttribute(String url, HttpHeaders httpHeaders, String entityID, String attributeName); ListenableFuture<StatusCode> deleteContextAttribute(String url, HttpHeaders httpHeaders, String entityID, String attributeName); ListenableFuture<StatusCode> updateContextAttributeValue(String url, HttpHeaders httpHeaders, String entityID, String attributeName, String valueID, UpdateContextAttribute updateContextAttribute); ListenableFuture<ContextAttributeResponse> getContextAttributeValue(String url, HttpHeaders httpHeaders, String entityID, String attributeName, String valueID); ListenableFuture<StatusCode> deleteContextAttributeValue(String url, HttpHeaders httpHeaders, String entityID, String attributeName, String valueID); ListenableFuture<QueryContextResponse> getContextEntityType(String url, HttpHeaders httpHeaders, String typeName); ListenableFuture<QueryContextResponse> getContextEntityTypeAttribute(String url, HttpHeaders httpHeaders, String typeName, String attributeName); ListenableFuture<SubscribeContextResponse> appendContextSubscription(String url, HttpHeaders httpHeaders, SubscribeContext subscribeContext); ListenableFuture<UpdateContextSubscriptionResponse> updateContextSubscription(String url, HttpHeaders httpHeaders, String subscriptionID, UpdateContextSubscription updateContextSubscription); ListenableFuture<UnsubscribeContextResponse> deleteContextSubscription(String url, HttpHeaders httpHeaders, String subscriptionID);  }
@Test public void testAppendContextElement_JSON() throws Exception { String responseBody = json(jsonConverter, createAppendContextElementResponseTemperature()); mockServer.expect(requestTo(baseUrl+"/ngsi10/contextEntities/123")) .andExpect(method(HttpMethod.POST)) .andExpect(jsonPath("$.attributes").isArray()) .andExpect(jsonPath("$.attributes[0].name").value("temp")) .andExpect(jsonPath("$.attributes[0].type").value("float")) .andExpect(jsonPath("$.attributes[0].value").value("15.5")) .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); AppendContextElementResponse response = ngsiRestClient.appendContextElement(baseUrl, null, "123", Util.createAppendContextElementTemperature()).get(); this.mockServer.verify(); assertNull(response.getErrorCode()); assertNotNull(response.getContextAttributeResponses()); assertEquals(1, response.getContextAttributeResponses().size()); assertNotNull(response.getContextAttributeResponses().get(0).getContextAttributeList()); assertEquals(1, response.getContextAttributeResponses().get(0).getContextAttributeList().size()); assertNotNull(response.getContextAttributeResponses().get(0).getContextAttributeList().get(0)); assertEquals("temp", response.getContextAttributeResponses().get(0).getContextAttributeList().get(0).getName()); assertEquals("float", response.getContextAttributeResponses().get(0).getContextAttributeList().get(0).getType()); assertEquals("15.5", response.getContextAttributeResponses().get(0).getContextAttributeList().get(0).getValue()); assertEquals(CodeEnum.CODE_200.getLabel(), response.getContextAttributeResponses().get(0).getStatusCode().getCode()); }