@Override public Object invoke(Invocation invocation) throws Throwable { return (Integer) invocation.getParameter(0);
/** * Fails the test if there are any expectations that have not been met. */ public void assertIsSatisfied() { if (firstError != null) { throw firstError; } else if (!dispatcher.isSatisfied()) { throw expectationErrorTranslator.translate( ExpectationError.notAllSatisfied(this)); } }
public Object dispatch(Invocation invocation) throws Throwable { for (Expectation expectation : expectations) { if (expectation.matches(invocation)) { return expectation.invoke(invocation); } } throw ExpectationError.unexpected("unexpected invocation", invocation); }
@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(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 invokedMethod = invocation.getInvokedMethod(); if (METHOD_OBJECT_FINALIZE.equals(invokedMethod)) { return mockObject.invoke(invocation); } return invokable.invoke(invocation); } };
public Object invoke(Invocation invocation) throws Throwable { invocationCount++; performSideEffects(); final Object result = action.invoke(new Invocation(ExpectationMode.ASSERTING, invocation)); invocation.checkReturnTypeCompatibility(result); return result; }
public Object invoke(Invocation invocation) throws Throwable { Invocation buildingInvocation = new Invocation(ExpectationMode.BUILDING,invocation); capture.createExpectationFrom(buildingInvocation); return defaultAction.invoke(buildingInvocation); } }
public Object invoke(Invocation invocation) throws Throwable { checkRunningOnTestThread(); return mockObject.invoke(invocation); } };
private ExpectationError mismatchDescribing(final ExpectationError e) { ExpectationError filledIn = new ExpectationError(e.getMessage(), new SelfDescribing() { public void describeTo(Description description) { describeMismatch(e.invocation, description); } }, e.invocation); filledIn.setStackTrace(e.getStackTrace()); return filledIn; }
public static <T> T newProxyInstance(Class<T> type, final InvocationHandler handler) { Invokable invokable = new Invokable() { @Override public Object invoke(Invocation invocation) throws Throwable { return handler.invoke(null, invocation.getInvokedMethod(), invocation.getParametersAsArray()); } }; return IMPOSTERISER.imposterise(invokable, type); } }
public Object invoke(Invocation invocation) throws Throwable { if (iterator.hasNext()) { return iterator.next().invoke(invocation); } throw ExpectationError.unexpected("no more actions available", invocation); }
/** * Adds an expected invocation that the object under test will perform upon * objects in its context during the test. * * This method allows a test to define an expectation explicitly, bypassing the * high-level API, if desired. * @param expectation to check */ public void addExpectation(Expectation expectation) { dispatcher.add(expectation); }
public Object invoke(Invocation invocation) throws Throwable { Object result = null; for (int i = 0; i < actions.length; i++) { result = actions[i].invoke(invocation); } return result; }
public boolean isSatisfied() { for (Expectation expectation : expectations) { if (!expectation.isSatisfied()) { return false; } } return true; }
/** * Returns a new state machine that is used to constrain the order in which * expectations can occur. * * @param name * The name of the state machine. * @return * A new state machine with the given name. */ public States states(String name) { return dispatcher.newStateMachine(name); }
public Object invoke(Object receiver, Method method, Object[] args) throws Throwable { return mockObject.invoke(new Invocation(receiver, method, args)); } },
@Override public Object invoke(final Invocation invocation) throws Throwable { return invocation.getParameter(i); }
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)); } },