public void addAnswer(Answer answer, boolean isConsecutive) { Invocation invocation = invocationForStubbing.getInvocation(); mockingProgress.stubbingCompleted(invocation); AnswersValidator answersValidator = new AnswersValidator(); answersValidator.validate(answer, invocation); synchronized (stubbed) { if (isConsecutive) { stubbed.getFirst().addAnswer(answer); } else { stubbed.addFirst(new StubbedInvocationMatcher(invocationForStubbing, answer)); } } }
public void validate(Answer<?> answer, Invocation invocation) { MethodInfo methodInfo = new MethodInfo(invocation); if (answer instanceof ThrowsException) { validateException((ThrowsException) answer, methodInfo); } if (answer instanceof Returns) { validateReturnValue((Returns) answer, methodInfo); } if (answer instanceof DoesNothing) { validateDoNothing((DoesNothing) answer, methodInfo); } if (answer instanceof CallsRealMethods) { validateMockingConcreteClass((CallsRealMethods) answer, methodInfo); } if (answer instanceof ReturnsArgumentAt) { ReturnsArgumentAt returnsArgumentAt = (ReturnsArgumentAt) answer; validateReturnArgIdentity(returnsArgumentAt, invocation); } }
public void validate(Answer<?> answer, Invocation invocation) { if (answer instanceof ThrowsException) { validateException((ThrowsException) answer, invocation); } if (answer instanceof Returns) { validateReturnValue((Returns) answer, invocation); } if (answer instanceof DoesNothing) { validateDoNothing((DoesNothing) answer, invocation); } if (answer instanceof CallsRealMethods) { validateMockingConcreteClass((CallsRealMethods) answer, invocation); } }
public void addAnswer(Answer answer, boolean isConsecutive) { Invocation invocation = invocationForStubbing.getInvocation(); mockingProgress.stubbingCompleted(invocation); AnswersValidator answersValidator = new AnswersValidator(); answersValidator.validate(answer, invocation); synchronized (stubbed) { if (isConsecutive) { stubbed.getFirst().addAnswer(answer); } else { stubbed.addFirst(new StubbedInvocationMatcher(invocationForStubbing, answer)); } } }