コード例 #1
0
  @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());
  }
コード例 #2
0
  @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());
  }