registeredInvocations.add(invocationMatcher.getInvocation());
mockitoStubber.setInvocationForPotentialStubbing(invocationMatcher);
OngoingStubbingImpl<T> ongoingStubbing = new OngoingStubbingImpl<T>(mockitoStubber, registeredInvocations);
mockingProgress.reportOngoingStubbing(ongoingStubbing);
StubbedInvocationMatcher stubbedInvocation = mockitoStubber.findAnswerFor(invocation);
if (!invocation.isVoid() && stubbedInvocation == null) {
//it is a return-value interaction but not stubbed. This *might* be a problem
mockingProgress.getDebuggingInfo().addPotentiallyUnstubbed(invocationMatcher);
}
if (stubbedInvocation != null) {
mockingProgress.getDebuggingInfo().reportUsedStub(invocationMatcher);
stubbedInvocation.captureArgumentsFrom(invocation);
return stubbedInvocation.answer(invocation);
} else {
Object ret = mockSettings.getDefaultAnswer().answer(invocation);
//redo setting invocation for potential stubbing in case of partial mocks / spies.
//Without it, the real method inside 'when' might have delegated