控制器类:
@GetMapping(value = "/isverified/{msisdn}", produces = {
MediaType.APPLICATION_JSON_UTF8_VALUE,
MediaType.APPLICATION_ATOM_XML_VALUE }
)
@ApiOperation(value = "Is Verified", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> isVerified(@PathVariable(value = "msisdn") String msisdn)
throws Exception
GcInitResponse verifiedResponse = gcinitService.isVerified(msisdn);
return new ResponseEntity<Object>(verifiedResponse, HttpStatus.OK);
}
测试类:
public void testIsVerified() throws Exception {
//fail("Not yet implemented");
String msisdn = "212361253";
mockMvc.perform(get("/gcinit/v1/isverified/{msisdn}",msisdn))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.verified", is("true")))
.andDo(print());
}
错误
org.springframework.web.util.NestedServletException:请求处理失败; >嵌套异常为java.lang.IllegalStateException:缓存值不是必需的类型[java.lang.String]:null