use of org.mockito.internal.matchers.CapturingMatcher 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.internal.matchers.CapturingMatcher in project mockito by mockito.
the class InvocationMatcherTest method should_capture_arguments_from_invocation.
@Test
public void should_capture_arguments_from_invocation() throws Exception {
//given
Invocation invocation = new InvocationBuilder().args("1", 100).toInvocation();
CapturingMatcher capturingMatcher = new CapturingMatcher();
InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(new Equals("1"), capturingMatcher));
//when
invocationMatcher.captureArgumentsFrom(invocation);
//then
assertEquals(1, capturingMatcher.getAllValues().size());
assertEquals(100, capturingMatcher.getLastValue());
}
Aggregations