I am using a Retrier class to retry failed tasks. My code looks something like this. I have mocked Retrier class in my testcase using Mockito
someMethod() {
Callable a = new TestingCall()
Retrier.call(a, arg2, arg3)
.....
}
my test code looks something like this.
testMymethod()
// mock(Retrier.class)
when(Retrier.call(any(Callable.class), anyObject(), anyObject()).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
return true;
}
});
But when I run the test, it throws a null pointer Exception in Retrier.call
Retrier.call uses the passed arguments which is coming as null hence the NPE.
Note: I have tried passing something like this too.
when(Retrier.call(any(Callable.class), any(arg2.Class), any(arg3.Class) where arg2 and arg3 are mocked too.
Any thoughts about this error? Or another way of doing it successfully?