运行单元测试用例时的错误日志。如何使用Mockito测试ehcache?

时间:2018-07-17 19:46:44

标签: java spring mockito

控制器类:

@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

0 个答案:

没有答案