@Override public void validateFor(InvocationOnMock invocation) { if (!new InvocationInfo(invocation).isVoid()) { throw onlyVoidMethodsCanBeSetToDoNothing(); } } }
@Override public void validateFor(InvocationOnMock invocation) { InvocationInfo invocationInfo = new InvocationInfo(invocation); if (invocationInfo.isVoid()) { throw cannotStubVoidMethodWithAReturnValue(invocationInfo.getMethodName()); } if (returnsNull() && invocationInfo.returnsPrimitive()) { throw wrongTypeOfReturnValue(invocationInfo.printMethodReturnType(), "null", invocationInfo.getMethodName()); } if (!returnsNull() && !invocationInfo.isValidReturnType(returnType())) { throw wrongTypeOfReturnValue(invocationInfo.printMethodReturnType(), printReturnType(), invocationInfo.getMethodName()); } }