use of org.mockito.invocation.Invocation in project mockito by mockito.
the class NumberOfInvocationsInOrderCheckerTest method shouldReportTooManyActual.
@Test
public void shouldReportTooManyActual() throws Exception {
Invocation first = buildSimpleMethod().toInvocation();
Invocation second = buildSimpleMethod().toInvocation();
invocations = asList(first, second);
wanted = buildSimpleMethod().toInvocationMatcher();
exception.expectMessage("Wanted 1 time");
exception.expectMessage("But was 2 times");
NumberOfInvocationsChecker.checkNumberOfInvocations(invocations, wanted, 1, context);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class NumberOfInvocationsInOrderCheckerTest method shouldReportNeverWantedButInvoked.
@Test
public void shouldReportNeverWantedButInvoked() throws Exception {
Invocation first = buildSimpleMethod().toInvocation();
invocations = asList(first);
wanted = buildSimpleMethod().toInvocationMatcher();
exception.expect(VerificationInOrderFailure.class);
exception.expectMessage("mock.simpleMethod()");
exception.expectMessage("Wanted 0 times");
exception.expectMessage("But was 1 time. Undesired invocation");
exception.expectMessage("" + first.getLocation());
NumberOfInvocationsChecker.checkNumberOfInvocations(invocations, wanted, 0, context);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class NumberOfInvocationsInOrderCheckerTest 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, context);
assertThat(invocation.isVerified()).isTrue();
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class NoMoreInteractionsTest method shouldVerifyInOrderMultipleInvoctionsAndThrow.
@Test
public void shouldVerifyInOrderMultipleInvoctionsAndThrow() {
//given
NoMoreInteractions n = new NoMoreInteractions();
Invocation i = new InvocationBuilder().seq(1).toInvocation();
Invocation i2 = new InvocationBuilder().seq(2).toInvocation();
try {
//when
n.verifyInOrder(new VerificationDataInOrderImpl(context, asList(i, i2), null));
fail();
} catch (VerificationInOrderFailure e) {
}
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class OnlyTest method shouldNotMarkAsVerifiedWhenAssertionFailed.
@Test
public void shouldNotMarkAsVerifiedWhenAssertionFailed() {
//given
Invocation invocation = new InvocationBuilder().toInvocation();
assertFalse(invocation.isVerified());
//when
try {
only.verify(new VerificationDataStub(new InvocationBuilder().toInvocationMatcher(), invocation));
fail();
} catch (MockitoAssertionError e) {
}
//then
assertFalse(invocation.isVerified());
}
Aggregations