public boolean isToString(Method method) { return isToString(new DelegatingMethod(method)); }
public boolean isOut(Invocation invocation) { return new ObjectMethodsGuru().isToString(invocation.getMethod()); } }
public Object answer(InvocationOnMock currentInvocation) throws Throwable { if (new ObjectMethodsGuru().isToString(currentInvocation.getMethod())) { return "SmartNull returned by this unstubbed method call on a mock:\n" + unstubbedInvocation.toString(); } new Reporter().smartNullPointerException(unstubbedInvocation.toString(), location); return null; } }
void assertWantedIsVerifiable() { if (wanted == null) { return; } ObjectMethodsGuru o = new ObjectMethodsGuru(); if (o.isToString(wanted.getMethod())) { new Reporter().cannotVerifyToString(); } } }
public Object answer(InvocationOnMock invocation) { if (methodsGuru.isToString(invocation.getMethod())) { Object mock = invocation.getMock(); MockName name = new MockUtil().getMockName(mock); if (name.isDefault()) { return "Mock for " + ClassNameFinder.classNameForMock(mock) + ", hashCode: " + mock.hashCode(); } else { return name.toString(); } } else if (methodsGuru.isCompareToMethod(invocation.getMethod())) { //see issue 184. //mocks by default should not return 0 for compareTo because they are not the same. Hence we return 1 (anything but 0 is good). //Only for compareTo() method by the Comparable interface return 1; } Class<?> returnType = invocation.getMethod().getReturnType(); return returnValueFor(returnType); }
public boolean isToString(Method method) { return isToString(new DelegatingMethod(method)); }
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { if (new ObjectMethodsGuru().isToString(method)) { return "SmartNull returned by this unstubbed method call on a mock:\n" + invocation.toString(); } new Reporter().smartNullPointerException(invocation.toString(), location); return null; } }
public boolean isToString() { return new ObjectMethodsGuru().isToString(getMethod()); }
void assertWantedIsVerifiable() { if (wanted == null) { return; } ObjectMethodsGuru o = new ObjectMethodsGuru(); if (o.isToString(wanted.getMethod())) { new Reporter().cannotVerifyToString(); } } }
public Object answer(InvocationOnMock invocation) { if (methodsGuru.isToString(invocation.getMethod())) { Object mock = invocation.getMock(); MockName name = new MockUtil().getMockName(mock); if (name.isSurrogate()) { return "Mock for " + ClassNameFinder.classNameForMock(mock) + ", hashCode: " + mock.hashCode(); } else { return name.toString(); } } else if (methodsGuru.isCompareToMethod(invocation.getMethod())) { //see issue 184. //mocks by default should not return 0 for compareTo because they are not the same. Hence we return 1 (anything but 0 is good). //Only for compareTo() method by the Comparable interface return 1; } Class<?> returnType = invocation.getMethod().getReturnType(); return returnValueFor(returnType); }