use of org.mockito.invocation.Invocation 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.invocation.Invocation in project mockito by mockito.
the class InvocationsFinderTest method shouldGetLastStackTrace.
@Test
public void shouldGetLastStackTrace() throws Exception {
Location last = InvocationsFinder.getLastLocation(invocations);
assertSame(differentMethodInvocation.getLocation(), last);
assertNull(InvocationsFinder.getLastLocation(Collections.<Invocation>emptyList()));
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationsFinderTest method shouldFindFirstSimilarInvocationByName.
@Test
public void shouldFindFirstSimilarInvocationByName() throws Exception {
Invocation overloadedSimpleMethod = new InvocationBuilder().mock(mock).simpleMethod().arg("test").toInvocation();
Invocation found = InvocationsFinder.findSimilarInvocation(invocations, new InvocationMatcher(overloadedSimpleMethod));
assertSame(found, simpleMethodInvocation);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationsFinderTest method shouldReturnAllChunksWhenModeIsAtLeastOnce.
@Test
public void shouldReturnAllChunksWhenModeIsAtLeastOnce() 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);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InvocationsFinderTest method shouldFindPreviousInOrder.
@Test
public void shouldFindPreviousInOrder() throws Exception {
Invocation previous = InvocationsFinder.findPreviousVerifiedInOrder(invocations, context);
assertNull(previous);
context.markVerified(simpleMethodInvocation);
context.markVerified(simpleMethodInvocationTwo);
previous = InvocationsFinder.findPreviousVerifiedInOrder(invocations, context);
assertSame(simpleMethodInvocationTwo, previous);
}
Aggregations