I have a get method that takes 3 inputs and that needs to be mocked-
- Request - okhttp3.Request
- JSONUnmarshaler - Generic java object
GSON - com.google.gson.Gson
when(this.okhttpclient.get(any(Request.class), any(JSONUnmarshaler.class), any(Gson.class)).thenReturn(response);
I was able to mock the Request and GSON object but not sure how to mock the JSONUnmarshaler object. It is a Java generics object and here is the interface definition for it.
public interface JSONUnmarshaler<T> {
T fromJSON(Gson gson, JsonElement json);
}
Response type:-
List<Course> course_list = new ArrayList<Course>();
course_list.add(new Course());
UdemyResponse<List<Course>> response = new UdemyResponse<List<Course>>(200,"teststring","raw_data",course_list);