コード例 #1
0
 @Test
 public void checkNotifyContextImplementedInXml() throws Exception {
   mockMvc
       .perform(
           post("/i/notifyContext")
               .content(xmlmapper.writeValueAsString(Util.createNotifyContextTempSensor(0)))
               .contentType(MediaType.APPLICATION_XML)
               .header("Host", "localhost")
               .accept(MediaType.APPLICATION_XML))
       .andExpect(status().isOk());
 }
コード例 #2
0
 @Test
 public void checkNotifyContextImplemented() throws Exception {
   mockMvc
       .perform(
           post("/i/notifyContext")
               .content(Util.json(jsonConverter, Util.createNotifyContextTempSensor(0)))
               .contentType(MediaType.APPLICATION_JSON)
               .header("Host", "localhost")
               .accept(MediaType.APPLICATION_JSON))
       .andExpect(status().isOk());
 }
コード例 #3
0
 @Test
 public void checkNotifyContextNotImplemented() throws Exception {
   mockMvc
       .perform(
           post("/ni/notifyContext")
               .content(Util.json(jsonConverter, Util.createNotifyContextTempSensor(0)))
               .contentType(MediaType.APPLICATION_JSON)
               .header("Host", "localhost")
               .accept(MediaType.APPLICATION_JSON))
       .andExpect(status().isOk())
       .andExpect(
           MockMvcResultMatchers.jsonPath("$.responseCode.code")
               .value(CodeEnum.CODE_403.getLabel()));
 }
コード例 #4
0
  @Test
  public void missingParameterErrorNotify() throws Exception {

    NotifyContext notifyContext = Util.createNotifyContextTempSensor(0);
    notifyContext.setSubscriptionId(null);

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