@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()); }
@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()); }
@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())); }
@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")); }