I want to unit test my code below with Mockito, could anyone let me know how I can mock the response from the callback, which is anonymous in my code? Particularly, how can I verify if doSomethingOnResponse() gets called with the mocked response?
public void runTask() {
Data data = null;
ClassA objA = new ClassA(new Callback() {
@Override
public void onResponse(Response response) {
data = getSomethingFromResponse(response);
}
};
//this is a synchronous call
objA.run();
doSomethingElse(data); //data gets assigned from the callback
}
Thanks a lot in advance!