I am in process of writing a junit for one of the controller methods with method signature as below:
@RequestMapping(value="/getTokenizedURL.json",method=RequestMethod.POST)
@ResponseBody
public ResponseData getTokenizedURL(@RequestBody final RequestData requestData, final HttpServletRequest request) throws CustomException
I need to call this method using MockMvc and I am able to call using below:
mockMvc.perform(post("/user/getTokenizedURL.json")
.contentType(MediaType.APPLICATION_JSON)
.content(json))
.andDo(print())
.andExpect(status().isOk());
But the problem is I am unable to setup HttpServletRequest
Parameter while calling the original method using mock mvc. Without setting HttpServletRequest
argument, my test is giving issues since it is something required and used with in original method.
Please let me know how should I setup the same. Thanks!