@Override public void validateFor(final InvocationOnMock invocation) { if (answer instanceof ValidableAnswer) { ((ValidableAnswer) answer).validateFor(invocation); } } }
/** * Decides if the stubbing should be reported as unused. * Lenient stubbings are not reported as unused. */ public static boolean shouldBeReported(Stubbing stubbing) { return !stubbing.wasUsed() && stubbing.getStrictness() != Strictness.LENIENT; } }
public <M> M getMock() { return (M) mockitoOngoingStubbing.getMock(); } }
private <T> HandlerMethodArgumentResolver stubResolver(Mono<Object> stubValue) { HandlerMethodArgumentResolver resolver = mock(HandlerMethodArgumentResolver.class); when(resolver.supportsParameter(any())).thenReturn(true); when(resolver.resolveArgument(any(), any(), any())).thenReturn(stubValue); return resolver; }
public <T> T given(T mock) { return mockitoStubber.when(mock); }
@Override public OngoingStubbing<T> thenThrow(Class<? extends Throwable> toBeThrown, Class<? extends Throwable>... nextToBeThrown) { if (nextToBeThrown == null) { return thenThrow((Class<Throwable>) null); } OngoingStubbing<T> stubbing = thenThrow(toBeThrown); for (Class<? extends Throwable> t : nextToBeThrown) { stubbing = stubbing.thenThrow(t); } return stubbing; }
public Object answer(InvocationOnMock invocation) throws Throwable { return implementation.answer(invocation); } }
@SuppressWarnings("unchecked") public T answer(InvocationOnMock invocation) throws Throwable { return answer.answer((A)invocation.getArgument(0)); } };
@SuppressWarnings("unchecked") public Void answer(InvocationOnMock invocation) throws Throwable { answer.answer((A)invocation.getArgument(0)); return null; } };
@SuppressWarnings("unchecked") public T answer(InvocationOnMock invocation) throws Throwable { return answer.answer( (A)invocation.getArgument(0), (B)invocation.getArgument(1)); } };
@SuppressWarnings("unchecked") public Void answer(InvocationOnMock invocation) throws Throwable { answer.answer( (A)invocation.getArgument(0), (B)invocation.getArgument(1)); return null; } };
@SuppressWarnings("unchecked") public T answer(InvocationOnMock invocation) throws Throwable { return answer.answer( (A)invocation.getArgument(0), (B)invocation.getArgument(1), (C)invocation.getArgument(2)); } };
@SuppressWarnings("unchecked") public Void answer(InvocationOnMock invocation) throws Throwable { answer.answer( (A)invocation.getArgument(0), (B)invocation.getArgument(1), (C)invocation.getArgument(2)); return null; } };
@SuppressWarnings("unchecked") public Void answer(InvocationOnMock invocation) throws Throwable { answer.answer( (A)invocation.getArgument(0), (B)invocation.getArgument(1), (C)invocation.getArgument(2), (D)invocation.getArgument(3)); return null; } };
@SuppressWarnings("unchecked") public T answer(InvocationOnMock invocation) throws Throwable { return answer.answer( (A)invocation.getArgument(0), (B)invocation.getArgument(1), (C)invocation.getArgument(2), (D)invocation.getArgument(3), (E)invocation.getArgument(4)); } };
@SuppressWarnings("unchecked") public Void answer(InvocationOnMock invocation) throws Throwable { answer.answer( (A)invocation.getArgument(0), (B)invocation.getArgument(1), (C)invocation.getArgument(2), (D)invocation.getArgument(3), (E)invocation.getArgument(4)); return null; } };
private HttpInvokerClientConfiguration mockHttpInvokerClientConfiguration(String serviceUrl) { HttpInvokerClientConfiguration config = mock(HttpInvokerClientConfiguration.class); when(config.getServiceUrl()).thenReturn(serviceUrl); return config; }
@Override public Object answer(final InvocationOnMock invocation) throws Throwable { TimeUnit.MILLISECONDS.sleep(sleepyTime); return answer.answer(invocation); }
public void testSize() { when(mock.size()).thenReturn(0L); forward.size(); }
public Object answer(InvocationOnMock invocation) throws Throwable { //see ThreadsShareGenerouslyStubbedMockTest Answer a; synchronized(answers) { a = answers.size() == 1 ? answers.peek() : answers.poll(); } return a.answer(invocation); }