use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationMatcherTest method should_capture_arguments_when_args_count_does_NOT_match.
// like using several time the captor in the vararg
@Test
public void should_capture_arguments_when_args_count_does_NOT_match() throws Exception {
//given
mock.varargs();
Invocation invocation = getLastInvocation();
//when
InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(ANY));
//then
invocationMatcher.captureArgumentsFrom(invocation);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationMatcherTest method should_match_varargs_using_any_varargs.
@Test
public void should_match_varargs_using_any_varargs() throws Exception {
//given
mock.varargs("1", "2");
Invocation invocation = getLastInvocation();
InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(ANY));
//when
boolean match = invocationMatcher.matches(invocation);
//then
assertTrue(match);
}
use of org.mockito.invocation.Invocation 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.invocation.Invocation in project mockito by mockito.
the class InvocationImplTest method shouldKnowIfIsEqualTo.
@Test
public void shouldKnowIfIsEqualTo() {
Invocation equal = new InvocationBuilder().args(" ").mock("mock").toInvocation();
Invocation nonEqual = new InvocationBuilder().args("X").mock("mock").toInvocation();
Invocation withNewStringInstance = new InvocationBuilder().args(new String(" ")).mock("mock").toInvocation();
assertFalse(invocation.equals(null));
assertFalse(invocation.equals(""));
assertTrue(invocation.equals(equal));
assertFalse(invocation.equals(nonEqual));
assertTrue(invocation.equals(withNewStringInstance));
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationImplTest method shouldEqualToNotConsiderSequenceNumber.
@Test
public void shouldEqualToNotConsiderSequenceNumber() {
Invocation equal = new InvocationBuilder().args(" ").mock("mock").seq(2).toInvocation();
assertTrue(invocation.equals(equal));
assertTrue(invocation.getSequenceNumber() != equal.getSequenceNumber());
}
Aggregations