use of org.mockito.invocation.Invocation in project mockito by mockito.
the class AtLeastXNumberOfInvocationsCheckerTest method shouldMarkActualInvocationsAsVerified.
@Test
public void shouldMarkActualInvocationsAsVerified() {
//given
Invocation invocation = new InvocationBuilder().simpleMethod().toInvocation();
Invocation invocationTwo = new InvocationBuilder().differentMethod().toInvocation();
//when
checkAtLeastNumberOfInvocations(asList(invocation, invocationTwo), new InvocationMatcher(invocation), 1);
//then
assertThat(invocation.isVerified()).isTrue();
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class AtLeastXNumberOfInvocationsCheckerTest method shouldReportTooLittleInvocations.
@Test
public void shouldReportTooLittleInvocations() {
//given
Invocation invocation = new InvocationBuilder().simpleMethod().toInvocation();
Invocation invocationTwo = new InvocationBuilder().differentMethod().toInvocation();
exception.expect(TooLittleActualInvocations.class);
exception.expectMessage("iMethods.simpleMethod()");
exception.expectMessage("Wanted *at least* 2 times");
exception.expectMessage("But was 1 time");
//when
checkAtLeastNumberOfInvocations(asList(invocation, invocationTwo), new InvocationMatcher(invocation), 2);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class NumberOfInvocationsCheckerTest method shouldReportNeverWantedButInvoked.
@Test
public void shouldReportNeverWantedButInvoked() throws Exception {
Invocation first = buildSimpleMethod().toInvocation();
invocations = asList(first);
wanted = buildSimpleMethod().toInvocationMatcher();
exception.expect(NeverWantedButInvoked.class);
exception.expectMessage("Never wanted here");
exception.expectMessage("But invoked here");
exception.expectMessage("" + first.getLocation());
NumberOfInvocationsChecker.checkNumberOfInvocations(invocations, wanted, 0);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class NumberOfInvocationsCheckerTest method shouldMarkInvocationsAsVerified.
@Test
public void shouldMarkInvocationsAsVerified() throws Exception {
Invocation invocation = buildSimpleMethod().toInvocation();
assertThat(invocation.isVerified()).isFalse();
invocations = asList(invocation);
wanted = buildSimpleMethod().toInvocationMatcher();
NumberOfInvocationsChecker.checkNumberOfInvocations(invocations, wanted, 1);
assertThat(invocation.isVerified()).isTrue();
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class NumberOfInvocationsInOrderCheckerTest method shouldMarkAsVerifiedInOrder.
@Test
public void shouldMarkAsVerifiedInOrder() throws Exception {
Invocation invocation = buildSimpleMethod().toInvocation();
invocations = asList(invocation);
wanted = buildSimpleMethod().toInvocationMatcher();
assertThat(context.isVerified(invocation)).isFalse();
NumberOfInvocationsChecker.checkNumberOfInvocations(invocations, wanted, 1, context);
assertThat(context.isVerified(invocation)).isTrue();
}
Aggregations