Ejemplo n.º 1
0
  @Test
  public void testGetContextEntityTypes_Error() throws Exception {
    QueryContextResponse response = new QueryContextResponse();
    response.setErrorCode(new StatusCode(CodeEnum.CODE_500));
    when(ngsiController.queryContext(any())).thenReturn(response);

    mockMvc
        .perform(get("/v1/contextEntityTypes/TempSensor").accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isOk())
        .andDo(mvcResult -> System.out.println(mvcResult.getResponse().getContentAsString()))
        .andExpect(jsonPath("$.errorCode.code").value("500"))
        .andExpect(jsonPath("$.contextResponses").doesNotExist());

    verify(ngsiController).queryContext(any());
  }
Ejemplo n.º 2
0
  @Test
  public void testGetContextElement_Error() throws Exception {
    ArgumentCaptor<UpdateContext> updateContextArg = ArgumentCaptor.forClass(UpdateContext.class);

    QueryContextResponse response = new QueryContextResponse();
    response.setErrorCode(new StatusCode(CodeEnum.CODE_400));
    when(ngsiController.queryContext(any())).thenReturn(response);

    mockMvc
        .perform(get("/v1/contextEntities/12345678").accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isOk())
        .andExpect(jsonPath("$.statusCode.code").value("400"))
        .andExpect(jsonPath("$.contextElement").doesNotExist());

    verify(ngsiController).queryContext(any());
  }