public Object invoke(Invocation invocation) throws Throwable { checkRunningOnTestThread(); return mockObject.invoke(invocation); } };
private Object synchroniseInvocation(Invokable mockObject, Invocation invocation) throws Throwable { synchronized (sync) { try { return mockObject.invoke(invocation); } catch (Error e) { if (firstError == null) { firstError = e; } throw e; } finally { sync.notifyAll(); } } }
@Override public Object invoke(Invocation invocation) throws Throwable { Object cached = cache.get(invocation); if (cached != null) return cached; Object result = next.invoke(invocation); cache.put(invocation, result); return result; } }
@Override public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { return mockObject.invoke(new Invocation(self, thisMethod, args)); } });
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return mockObject.invoke(new Invocation(ExpectationMode.LEGACY, proxy, method, args)); } });
public Object invoke(Object receiver, Method method, Object[] args) throws Throwable { return mockObject.invoke(new Invocation(receiver, method, args)); } },
public Object invoke(Object receiver, Method method, Object[] args) throws Throwable { return mockObject.invoke(new Invocation(receiver, method, args)); } },
@Override public Object invoke(Invocation invocation) throws Throwable { try { Method matchingMethod = methodMatching(invocation); matchingMethod.setAccessible(true); return matchingMethod.invoke(object, invocation.getParametersAsArray()); } catch (Exception x) { return next.invoke(invocation); } }
public Object invoke(Invocation invocation) throws Throwable { if (invocation.getInvokedMethod().getDeclaringClass() == declaringType) { return invocation.applyTo(target); } else { return next.invoke(invocation); } } }
@Override public Object invoke(Invocation invocation) throws Throwable { Method method = invocation.getInvokedMethod(); try { if (method.getParameterTypes().length == 0) { Field field = object.getClass().getDeclaredField(fieldNameForAccessor(method)); field.setAccessible(true); return returnValueFor(field.get(object), method.getGenericReturnType(), method.getName()); } else { Field field = object.getClass().getDeclaredField(fieldNameForMutator(method)); field.setAccessible(true); field.set(object, invocation.getParametersAsArray()[0]); return null; } } catch (NoSuchFieldException e) { return next.invoke(invocation); } }
@RuntimeType static public Object intercept( @This Object receiver, @Origin Method method, @FieldValue(value=JMOCK_KEY) Invokable invokable, @AllArguments Object[] args ) throws Throwable { return invokable.invoke(new Invocation(receiver, method, args)); } }
@RuntimeType static public Object intercept( @This Object receiver, @Origin Method method, @FieldValue(value=JMOCK_KEY) Invokable invokable, @AllArguments Object[] args ) throws Throwable { return invokable.invoke(new Invocation(receiver, method, args)); } }
public Object invoke(Invocation invocation) throws Throwable { Method method = invocation.getInvokedMethod(); if (isMethod(method, int.class, "hashCode")) { return fakeHashCode(invocation.getInvokedObject()); } else if (isMethod(method, String.class, "toString")) { return fakeToString(invocation.getInvokedObject()); } else if (isMethod(method, boolean.class, "equals", Object.class)) { return fakeEquals(invocation.getInvokedObject(), invocation.getParameter(0)); } else if (isMethod(method, void.class, "finalize")) { fakeFinalize(invocation.getInvokedObject()); return null; } else { return next.invoke(invocation); } }