use of org.mockito.internal.invocation.InvocationBuilder in project mockito by mockito.
the class OnlyTest method shouldMarkAsVerified.
@Test
public void shouldMarkAsVerified() {
//given
Invocation invocation = new InvocationBuilder().toInvocation();
assertFalse(invocation.isVerified());
//when
only.verify(new VerificationDataStub(new InvocationMatcher(invocation), invocation));
//then
assertTrue(invocation.isVerified());
}
use of org.mockito.internal.invocation.InvocationBuilder in project mockito by mockito.
the class VerificationDataImplTest method shouldToStringBeNotVerifiable.
@Test
public void shouldToStringBeNotVerifiable() throws Exception {
InvocationMatcher toString = new InvocationBuilder().method("toString").toInvocationMatcher();
try {
new VerificationDataImpl(null, toString);
fail();
} catch (MockitoException e) {
}
}
use of org.mockito.internal.invocation.InvocationBuilder 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.internal.invocation.InvocationBuilder 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.internal.invocation.InvocationBuilder 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);
}
Aggregations