use of org.mockito.invocation.Invocation in project mockito by mockito.
the class MockitoCore method ignoreStubs.
public Object[] ignoreStubs(Object... mocks) {
for (Object m : mocks) {
InvocationContainer invocationContainer = getMockHandler(m).getInvocationContainer();
List<Invocation> ins = invocationContainer.getInvocations();
for (Invocation in : ins) {
if (in.stubInfo() != null) {
in.ignoreForVerification();
}
}
}
return mocks;
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class WarningsFinderTest method shouldPrintStubWasUsedWithDifferentArgs.
@Test
public void shouldPrintStubWasUsedWithDifferentArgs() {
// given
Invocation stub = new InvocationBuilder().arg("foo").mock(mock).toInvocation();
InvocationMatcher wrongArg = new InvocationBuilder().arg("bar").mock(mock).toInvocationMatcher();
// when
WarningsFinder finder = new WarningsFinder(Arrays.<Invocation>asList(stub), Arrays.<InvocationMatcher>asList(wrongArg));
finder.find(listener);
// then
verify(listener, only()).foundStubCalledWithDifferentArgs(stub, wrongArg);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class WarningsFinderTest method shouldPrintUnusedStub.
@Test
public void shouldPrintUnusedStub() {
// given
Invocation unusedStub = new InvocationBuilder().simpleMethod().toInvocation();
// when
WarningsFinder finder = new WarningsFinder(asList(unusedStub), Arrays.<InvocationMatcher>asList());
finder.find(listener);
// then
verify(listener, only()).foundUnusedStub(unusedStub);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class ReporterTest method can_use_print_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_delegate_method_has_wrong_return_type.
@Test(expected = MockitoException.class)
public void can_use_print_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_delegate_method_has_wrong_return_type() throws Exception {
Invocation dumb_invocation = new InvocationBuilder().toInvocation();
IMethods mock_with_bogus_default_answer = mock(IMethods.class, new Returns(false));
throw Reporter.delegatedMethodHasWrongReturnType(dumb_invocation.getMethod(), dumb_invocation.getMethod(), mock_with_bogus_default_answer, String.class);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class ReporterTest method can_use_print_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_delegate_method_dont_exists.
@Test(expected = MockitoException.class)
public void can_use_print_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_delegate_method_dont_exists() throws Exception {
Invocation dumb_invocation = new InvocationBuilder().toInvocation();
IMethods mock_with_bogus_default_answer = mock(IMethods.class, new Returns(false));
throw Reporter.delegatedMethodDoesNotExistOnDelegate(dumb_invocation.getMethod(), mock_with_bogus_default_answer, String.class);
}
Aggregations