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_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);
}
use of org.mockito.internal.invocation.InvocationBuilder in project mockito by mockito.
the class ScenarioPrinterTest method shouldPrintInvocations.
@Test
public void shouldPrintInvocations() {
//given
Invocation verified = new InvocationBuilder().simpleMethod().verified().toInvocation();
Invocation unverified = new InvocationBuilder().differentMethod().toInvocation();
//when
String out = sp.print((List) asList(verified, unverified));
//then
assertThat(out).contains("1. -> at").contains("2. [?]-> at");
}
use of org.mockito.internal.invocation.InvocationBuilder in project mockito by mockito.
the class StubbingArgMismatchesTest method multiple_matching_invocations_per_stub_plus_some_other_invocation.
@Test
public void multiple_matching_invocations_per_stub_plus_some_other_invocation() throws Exception {
//given
Invocation stubbing = new InvocationBuilder().args("a").location("-> at A.java").toInvocation();
mismatches.add(new InvocationBuilder().args("x").location("-> at X.java").toInvocation(), stubbing);
mismatches.add(new InvocationBuilder().args("y").location("-> at Y.java").toInvocation(), stubbing);
mismatches.add(new InvocationBuilder().method("differentMethod").args("n").location("-> at N.java").toInvocation(), new InvocationBuilder().method("differentMethod").args("m").location("-> at M.java").toInvocation());
//when
mismatches.format("MyTest.myTestMethod", logger);
//then
assertEquals("[MockitoHint] MyTest.myTestMethod (see javadoc for MockitoHint):\n" + "[MockitoHint] 1. Unused... -> at A.java\n" + "[MockitoHint] ...args ok? -> at X.java\n" + "[MockitoHint] ...args ok? -> at Y.java\n" + "[MockitoHint] 2. Unused... -> at M.java\n" + "[MockitoHint] ...args ok? -> at N.java\n", logger.getLoggedInfo());
}
use of org.mockito.internal.invocation.InvocationBuilder in project mockito by mockito.
the class MockHandlerImplTest method should_remove_verification_mode_even_when_invalid_matchers.
@Test
public void should_remove_verification_mode_even_when_invalid_matchers() throws Throwable {
// given
Invocation invocation = new InvocationBuilder().toInvocation();
@SuppressWarnings("rawtypes") MockHandlerImpl<?> handler = new MockHandlerImpl(new MockSettingsImpl());
mockingProgress().verificationStarted(VerificationModeFactory.atLeastOnce());
handler.matchersBinder = new MatchersBinder() {
public InvocationMatcher bindMatchers(ArgumentMatcherStorage argumentMatcherStorage, Invocation invocation) {
throw new InvalidUseOfMatchersException();
}
};
try {
// when
handler.handle(invocation);
// then
fail();
} catch (InvalidUseOfMatchersException ignored) {
}
assertNull(mockingProgress().pullVerificationMode());
}
use of org.mockito.internal.invocation.InvocationBuilder in project mockito by mockito.
the class InOrderImplTest method shouldMarkVerifiedInOrder.
@Test
public void shouldMarkVerifiedInOrder() throws Exception {
//given
InOrderImpl impl = new InOrderImpl(singletonList(mock));
Invocation i = new InvocationBuilder().toInvocation();
assertFalse(impl.isVerified(i));
//when
impl.markVerified(i);
//then
assertTrue(impl.isVerified(i));
}
Aggregations