org.jmock.api.Invocation Java Examples
The following examples show how to use
org.jmock.api.Invocation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JUnit4GroovyMockery.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
void will(final Closure cl) { will(new Action() { public void describeTo(Description description) { description.appendText("execute closure"); } public Object invoke(Invocation invocation) throws Throwable { List<Object> params = Arrays.asList(invocation.getParametersAsArray()); Object result; try { List<Object> subParams = params.subList(0, Math.min(invocation.getParametersAsArray().length, cl.getMaximumNumberOfParameters())); result = cl.call(subParams.toArray(new Object[subParams.size()])); } catch (InvokerInvocationException e) { throw e.getCause(); } if (invocation.getInvokedMethod().getReturnType().isInstance(result)) { return result; } return null; } }); }
Example #2
Source File: JUnit4GroovyMockery.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
void will(final Closure cl) { will(new Action() { public void describeTo(Description description) { description.appendText("execute closure"); } public Object invoke(Invocation invocation) throws Throwable { List<Object> params = Arrays.asList(invocation.getParametersAsArray()); Object result; try { List<Object> subParams = params.subList(0, Math.min(invocation.getParametersAsArray().length, cl.getMaximumNumberOfParameters())); result = cl.call(subParams.toArray(new Object[subParams.size()])); } catch (InvokerInvocationException e) { throw e.getCause(); } if (invocation.getInvokedMethod().getReturnType().isInstance(result)) { return result; } return null; } }); }
Example #3
Source File: JUnit4GroovyMockery.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
void will(final Closure cl) { will(new Action() { public void describeTo(Description description) { description.appendText("execute closure"); } public Object invoke(Invocation invocation) throws Throwable { List<Object> params = Arrays.asList(invocation.getParametersAsArray()); Object result; try { List<Object> subParams = params.subList(0, Math.min(invocation.getParametersAsArray().length, cl.getMaximumNumberOfParameters())); result = cl.call(subParams.toArray(new Object[subParams.size()])); } catch (InvokerInvocationException e) { throw e.getCause(); } if (invocation.getInvokedMethod().getReturnType().isInstance(result)) { return result; } return null; } }); }
Example #4
Source File: JUnit4GroovyMockery.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
void will(final Closure cl) { will(new Action() { public void describeTo(Description description) { description.appendText("execute closure"); } public Object invoke(Invocation invocation) throws Throwable { List<Object> params = Arrays.asList(invocation.getParametersAsArray()); Object result; try { List<Object> subParams = params.subList(0, Math.min(invocation.getParametersAsArray().length, cl.getMaximumNumberOfParameters())); result = cl.call(subParams.toArray(new Object[subParams.size()])); } catch (InvokerInvocationException e) { throw e.getCause(); } if (invocation.getInvokedMethod().getReturnType().isInstance(result)) { return result; } return null; } }); }
Example #5
Source File: IndexValueRepository_Test.java From estatio with Apache License 2.0 | 5 votes |
private static Action executeCallableAndReturn() { return new Action() { @Override public Object invoke(Invocation invocation) throws Throwable { Callable<Object> callable = (Callable<Object>) invocation.getParameter(0); return callable.call(); } @Override public void describeTo(Description description) { description.appendText("execute arg 0 as callable and return"); } }; }
Example #6
Source File: LeaseTerm_Test.java From estatio with Apache License 2.0 | 5 votes |
private Action returnLeaseTerm() { return new Action() { @Override public Object invoke(Invocation invocation) throws Throwable { LeaseItem leaseItem = (LeaseItem) invocation.getParameter(0); LeaseTerm leaseTerm = (LeaseTerm) invocation.getParameter(1); LocalDate startDate = (LocalDate) invocation.getParameter(2); LocalDate endDate = (LocalDate) invocation.getParameter(3); LeaseTermForTesting ltt = new LeaseTermForTesting(); // relationships ltt.setLeaseItem(leaseItem); leaseItem.getTerms().add(ltt); ltt.setPrevious(leaseTerm); leaseTerm.setNext(ltt); // set values ltt.modifyStartDate(startDate); ltt.modifyEndDate(endDate); ltt.clockService = mockClockService; return ltt; } @Override public void describeTo(Description description) { description.appendText("new Lease Term under item and with previous term"); } }; }
Example #7
Source File: ArenaJarDownloaderTest.java From intellijcoder with MIT License | 5 votes |
private CustomAction saveLocalFileName() { return new CustomAction("file") { public Object invoke(Invocation invocation) throws Throwable { localFileName = (String) invocation.getParameter(0); return new ByteArrayOutputStream(); } }; }
Example #8
Source File: PathMacroManagerTest.java From consulo with Apache License 2.0 | 5 votes |
@Before public final void setupApplication() throws Exception { // in fact the test accesses extension points so it rather should be converted to a platform one assumeNotNull(ApplicationManager.getApplication()); context = new JUnit4Mockery(); context.setImposteriser(ClassImposteriser.INSTANCE); myApplication = context.mock(ApplicationEx.class, "application"); context.checking(new Expectations() { { allowing(myApplication).isUnitTestMode(); will(returnValue(false)); // some tests leave invokeLater()'s after them allowing(myApplication).invokeLater(with(any(Runnable.class)), with(any(ModalityState.class))); allowing(myApplication).runReadAction(with(any(Runnable.class))); will(new Action() { @Override public void describeTo(final Description description) { description.appendText("runs runnable"); } @Override @javax.annotation.Nullable public Object invoke(final Invocation invocation) throws Throwable { ((Runnable)invocation.getParameter(0)).run(); return null; } }); } }); }
Example #9
Source File: Matchers.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public Object invoke(Invocation invocation) throws Throwable { collector.setValue(invocation.getParameter(0)); return action.invoke(invocation); }
Example #10
Source File: Matchers.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public Object invoke(Invocation invocation) throws Throwable { collector.setValue(invocation.getParameter(0)); return action.invoke(invocation); }
Example #11
Source File: Matchers.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public Object invoke(Invocation invocation) throws Throwable { collector.setValue(invocation.getParameter(0)); return action.invoke(invocation); }
Example #12
Source File: Matchers.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public Object invoke(Invocation invocation) throws Throwable { collector.setValue(invocation.getParameter(0)); return action.invoke(invocation); }
Example #13
Source File: FutureActions.java From c5-replicator with Apache License 2.0 | 4 votes |
public Object invoke(Invocation invocation) { SettableFuture<Object> future = SettableFuture.create(); future.set(futureResult); return future; }
Example #14
Source File: FutureActions.java From c5-replicator with Apache License 2.0 | 4 votes |
public Object invoke(Invocation invocation) { SettableFuture<Object> future = SettableFuture.create(); future.setException(exception); return future; }
Example #15
Source File: C5FuturesTest.java From c5-replicator with Apache License 2.0 | 4 votes |
public Object invoke(Invocation invocation) throws Throwable { ((Runnable) invocation.getParameter(0)).run(); return null; }
Example #16
Source File: StateRepositoryTest.java From estatio with Apache License 2.0 | 4 votes |
@Override public Object invoke(final Invocation invocation) throws Throwable { final Object arg0 = invocation.getParameter(0); finderInteraction[0] = new FinderInteraction( arg0 instanceof Query ? (Query<?>) arg0 : null, finderMethod); return null; }