【发布时间】:2017-12-25 21:25:42
【问题描述】:
这是我的终点:
@PostMapping("/email/registration")
public Data registration(@RequestBody Data data, HttpServletRequest
httpServletRequest) throws Exception {
emailSenderService.pushEmail(httpServletRequest.getRequestURI(),
emailSenderService.sendConfirmationEmail(httpServletRequest.getRequestURI(), data));
emailSenderService.consumeEmail(httpServletRequest.getRequestURI());
return data;
}
这是我的测试(当然它不起作用):
@Test
public void testRegistrationConfirmation() throws Exception {
Data testData = new Data();
when(testData).thenReturn(testData);
mockMvc.perform(
post("/email/registration")
.contentType(MediaType.APPLICATION_JSON)
.content(asJsonString(testData)))
.andExpect(status().isOk())
.andExpect(testData);
}
我想看看给定对象是否与返回对象相同,最好不要用值填充所有字段。
感谢您的回答!
【问题讨论】:
标签: java spring rest post mockito