I am trying to test my controller using mockMvc and mockito. The actual controller case is as follows:
Message createXYZ(@RequestBody XYZ inst){
}
Now for pushing values through the request body, I create JSON using GsonBuilder, by serializing XYZ. Here is the structure for the XYZ class:
class XYZ{
List<Y> listofYs;
}
I create and set the layout for the ListYYY list, and when Gson tries to serialize an XYZ instance that has the mocked listofYs its generating NPE.
Is there a way or is it that I am doing this completely wrong?
source
share