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