【发布时间】:2019-10-22 14:07:49
【问题描述】:
我正在使用 Spring MVC 开发 REST 服务,该服务将对象列表作为请求参数。
@RequestMapping(value="/test", method=RequestMethod.PUT)
public String updateActiveStatus(ArrayList<Test> testList, BindingResult result) throws Exception {
if(testList.isEmpty()) {
throw new BadRequestException();
}
return null;
}
当我尝试对上述服务进行集成测试时,我无法在请求参数中发送测试对象列表。
以下代码对我不起作用。
List<Test> testList = Arrays.asList(new Test(), new Test());
mockMvc.perform(put(ApplicationConstants.UPDATE_ACTIVE_STATUS)
.content(objectMapper.writeValueAsString(testList)))
.andDo(print());
谁能帮忙解决这个问题!
【问题讨论】:
标签: spring-mvc integration-testing spring-test mockmvc spring-test-mvc