How to write mock test case for the controller inn java

This is my controller class

public class myClass extends BaseController {

    @RequestMapping(value = "/myList", method = RequestMethod.POST, consumes = "application/json")
    public @ResponseBody MyBaseVO getMyList(@RequestBody MyBaseVO requestObj) throws Exception {
        MyBaseVO response = (MyBaseVO) this.execute(requestObj,LanguageConstant.MY_MODULE_ID);
        return response;


I wanted to write a mock test case but stuck at this point, also i'm not sure i am doing correct or not. Can anyone help me in this.

public class myClassTest{

    myClass spy = Mockito.spy(new myClass ());

I am not sure how to use url myList in testcase and request and response object. I have created a json file of my request and response. Since it is using parent class therefore I am using spy for my testcase.

1 answer