@Test public void testUpdateContextAttribute_MismatchAttrError() throws Exception { UpdateContextAttribute updateContextAttribute = new UpdateContextAttribute(); updateContextAttribute.setAttribute(new ContextAttribute("temp", "float", "15.5")); mockMvc .perform( put("/v1/contextEntities/12345678/attributes/BAD_ATTR") .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON) .content(json(mapper, updateContextAttribute))) .andExpect(jsonPath("$.code").value(CodeEnum.CODE_472.getLabel())); verify(ngsiController, never()).updateContext(any()); }
@Test public void testAppendContextAttribute_EmptyAttrError() throws Exception { UpdateContextAttribute updateContextAttribute = new UpdateContextAttribute(); updateContextAttribute.setAttribute(null); mockMvc .perform( post("/v1/contextEntities/12345678/attributes/temp") .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON) .content(json(mapper, updateContextAttribute))) .andExpect(jsonPath("$.code").value(CodeEnum.CODE_472.getLabel())); verify(ngsiController, never()).updateContext(any()); }