use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationMatcherTest method should_not_be_similar_if_is_overloaded_but_used_with_the_same_arg.
@Test
public void should_not_be_similar_if_is_overloaded_but_used_with_the_same_arg() throws Exception {
Method method = IMethods.class.getMethod("simpleMethod", String.class);
Method overloadedMethod = IMethods.class.getMethod("simpleMethod", Object.class);
String sameArg = "test";
InvocationMatcher invocation = new InvocationBuilder().method(method).arg(sameArg).toInvocationMatcher();
Invocation overloadedInvocation = new InvocationBuilder().method(overloadedMethod).arg(sameArg).toInvocation();
assertFalse(invocation.hasSimilarMethod(overloadedInvocation));
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationMatcherTest method should_capture_varargs_as_vararg.
@Test
public void should_capture_varargs_as_vararg() throws Exception {
//given
mock.mixedVarargs(1, "a", "b");
Invocation invocation = getLastInvocation();
CapturingMatcher m = new CapturingMatcher();
InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, Arrays.<ArgumentMatcher>asList(new Equals(1), m));
//when
invocationMatcher.captureArgumentsFrom(invocation);
//then
Assertions.assertThat(m.getAllValues()).containsExactly("a", "b");
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationMatcherTest method should_not_be_similar_if_mocks_are_different.
@Test
public void should_not_be_similar_if_mocks_are_different() throws Exception {
Invocation onDifferentMock = new InvocationBuilder().simpleMethod().mock("different mock").toInvocation();
assertFalse(simpleMethod.hasSimilarMethod(onDifferentMock));
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationMatcherTest method should_create_from_invocations.
@Test
public void should_create_from_invocations() throws Exception {
//given
Invocation i = new InvocationBuilder().toInvocation();
//when
List<InvocationMatcher> out = InvocationMatcher.createFrom(asList(i));
//then
assertEquals(1, out.size());
assertEquals(i, out.get(0).getInvocation());
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationsFinderTest method shouldReturnAllChunksWhenWantedCountDoesntMatch.
@Test
public void shouldReturnAllChunksWhenWantedCountDoesntMatch() throws Exception {
Invocation simpleMethodInvocationThree = new InvocationBuilder().mock(mock).toInvocation();
invocations.add(simpleMethodInvocationThree);
List<Invocation> chunk = InvocationsFinder.findMatchingChunk(invocations, new InvocationMatcher(simpleMethodInvocation), 1, context);
Assertions.assertThat(chunk).containsSequence(simpleMethodInvocation, simpleMethodInvocationTwo, simpleMethodInvocationThree);
}
Aggregations