AsyncResult<Authentication> asyncResultSet = Mockito.mock(AsyncResult.class);
Mockito.doAnswer(new Answer<AsyncResult<Authentication>>() {
@Override
public AsyncResult<Authentication> answer(InvocationOnMock invocation) throws Throwable {
((Handler<AsyncResult<Authentication>>) invocation.getArgument(2)).handle(asyncResultSet);
return null;
}
}).when(apiUtil).doAuthentication(Mockito.any(), Mockito.any(), Mockito.any());
如何模拟静态void方法?如果我在doAnswer()中进行了模拟,给出了空指针异常。