I want to do an unit test that verifies if function1()
or function2()
were called. I haven't work with callbacks before, can you give me any idea about how to do it?
public void sendData(HttpService service, Document userData) {
Call<String> call = service.updateDocument(getId(), userData);
call.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
function1(response.code());
}
@Override
public void onFailure(Call<String> call, Throwable t) {
function2();
}
});
}