In a class I'm testing, there is a private method that instantiates the GetRequest class in Unirest. How do I use Mockito so that the instantiation of GetRequest class in getResponse() results in a mock object that I use in my JUnit test?
public ClassUnderTest {
public String methodToTest() {
String url = "http://localhost:8080";
String result = getResponse(url);
return result;
}
private String getResponse(String url) {
GetRequest getRequest = new GetRequest(HttpMethod.GET, url);
... = getRequest.header(...).headers(...).asJson();
...etc...
}
}
Thank you, Rico