如何使用请求参数作为字符串检查controllerTest中的NullvalueException(Spring mvc)

时间:2016-11-29 05:56:00

标签: java spring-mvc

我必须检查ControllerTest中的NullvalueException(spring,java)。 在函数@requestParam中是一个String。 我以这种方式测试Controller,但它失败了

when(ServiceImpl.getAllByName(null)).thenThrow(new NullValueException(message)); mockMvc.perform(get("/tag/tag?name=null"). contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(status().isOk()).andExpect(jsonPath("$.fetchresponseList", IsNull.nullValue()))

错误: java.lanag.assertionFailure 状态预计为200但是400

任何人都可以告诉我它失败的原因吗?

0 个答案:

没有答案