コード例 #1
0
 @Test
 public void checkQueryContextImplemented() throws Exception {
   mockMvc
       .perform(
           post("/i/queryContext")
               .content(Util.json(jsonConverter, Util.createQueryContextTemperature()))
               .contentType(MediaType.APPLICATION_JSON)
               .header("Host", "localhost")
               .accept(MediaType.APPLICATION_JSON))
       .andExpect(status().isOk());
 }
コード例 #2
0
 @Test
 public void checkUpdateContextNotImplemented() throws Exception {
   mockMvc
       .perform(
           post("/ni/updateContext")
               .content(Util.json(jsonConverter, Util.createUpdateContextTempSensor(0)))
               .contentType(MediaType.APPLICATION_JSON)
               .header("Host", "localhost")
               .accept(MediaType.APPLICATION_JSON))
       .andExpect(status().isOk())
       .andExpect(
           MockMvcResultMatchers.jsonPath("$.errorCode.code").value(CodeEnum.CODE_403.getLabel()));
 }
コード例 #3
0
 @Test
 public void checkQueryContextImplementedInXml() throws Exception {
   mockMvc
       .perform(
           post("/i/queryContext")
               .content(xmlmapper.writeValueAsString(Util.createQueryContextTemperature()))
               .contentType(MediaType.APPLICATION_XML)
               .header("Host", "localhost")
               .accept(MediaType.APPLICATION_XML))
       .andExpect(status().isOk());
 }
コード例 #4
0
  @Test
  public void missingParameterErrorUpdate() throws Exception {

    UpdateContext updateContext = Util.createUpdateContextTempSensor(0);
    updateContext.setUpdateAction(null);

    mockMvc
        .perform(
            post("/ni/updateContext")
                .content(Util.json(jsonConverter, updateContext))
                .contentType(MediaType.APPLICATION_JSON)
                .header("Host", "localhost")
                .accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isOk())
        .andExpect(
            MockMvcResultMatchers.jsonPath("$.errorCode.code").value(CodeEnum.CODE_471.getLabel()))
        .andExpect(
            MockMvcResultMatchers.jsonPath("$.errorCode.reasonPhrase")
                .value(CodeEnum.CODE_471.getShortPhrase()))
        .andExpect(
            MockMvcResultMatchers.jsonPath("$.errorCode.details")
                .value("The parameter updateAction of type string is missing in the request"));
  }
コード例 #5
0
  @Test
  public void missingParameterErrorQuery() throws Exception {

    QueryContext queryContext = new QueryContext();

    mockMvc
        .perform(
            post("/ni/queryContext")
                .content(Util.json(jsonConverter, queryContext))
                .contentType(MediaType.APPLICATION_JSON)
                .header("Host", "localhost")
                .accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isOk())
        .andExpect(
            MockMvcResultMatchers.jsonPath("$.errorCode.code").value(CodeEnum.CODE_471.getLabel()))
        .andExpect(
            MockMvcResultMatchers.jsonPath("$.errorCode.reasonPhrase")
                .value(CodeEnum.CODE_471.getShortPhrase()))
        .andExpect(
            MockMvcResultMatchers.jsonPath("$.errorCode.details")
                .value("The parameter entities of type List<EntityId> is missing in the request"));
  }
コード例 #6
0
  @Test
  public void missingParameterErrorUnsubscribe() throws Exception {

    UnsubscribeContext unsubscribeContext = new UnsubscribeContext();

    mockMvc
        .perform(
            post("/ni/unsubscribeContext")
                .content(Util.json(jsonConverter, unsubscribeContext))
                .contentType(MediaType.APPLICATION_JSON)
                .header("Host", "localhost")
                .accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isOk())
        .andExpect(
            MockMvcResultMatchers.jsonPath("$.statusCode.code").value(CodeEnum.CODE_471.getLabel()))
        .andExpect(
            MockMvcResultMatchers.jsonPath("$.statusCode.reasonPhrase")
                .value(CodeEnum.CODE_471.getShortPhrase()))
        .andExpect(
            MockMvcResultMatchers.jsonPath("$.statusCode.details")
                .value("The parameter subscriptionId of type String is missing in the request"));
  }