use of org.mockito.invocation.Invocation in project mockito by mockito.
the class StubbingArgMismatchesTest method multiple_matching_invocations_per_stub_plus_some_other_invocation.
@Test
public void multiple_matching_invocations_per_stub_plus_some_other_invocation() throws Exception {
//given
Invocation stubbing = new InvocationBuilder().args("a").location("-> at A.java").toInvocation();
mismatches.add(new InvocationBuilder().args("x").location("-> at X.java").toInvocation(), stubbing);
mismatches.add(new InvocationBuilder().args("y").location("-> at Y.java").toInvocation(), stubbing);
mismatches.add(new InvocationBuilder().method("differentMethod").args("n").location("-> at N.java").toInvocation(), new InvocationBuilder().method("differentMethod").args("m").location("-> at M.java").toInvocation());
//when
mismatches.format("MyTest.myTestMethod", logger);
//then
assertEquals("[MockitoHint] MyTest.myTestMethod (see javadoc for MockitoHint):\n" + "[MockitoHint] 1. Unused... -> at A.java\n" + "[MockitoHint] ...args ok? -> at X.java\n" + "[MockitoHint] ...args ok? -> at Y.java\n" + "[MockitoHint] 2. Unused... -> at M.java\n" + "[MockitoHint] ...args ok? -> at N.java\n", logger.getLoggedInfo());
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class AtMost method verify.
public void verify(VerificationData data) {
List<Invocation> invocations = data.getAllInvocations();
MatchableInvocation wanted = data.getTarget();
List<Invocation> found = findInvocations(invocations, wanted);
int foundSize = found.size();
if (foundSize > maxNumberOfInvocations) {
throw wantedAtMostX(maxNumberOfInvocations, foundSize);
}
removeAlreadyVerified(found);
markVerified(found, wanted);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class Calls method verifyInOrder.
@Override
public void verifyInOrder(VerificationDataInOrder data) {
List<Invocation> allInvocations = data.getAllInvocations();
MatchableInvocation wanted = data.getWanted();
checkMissingInvocation(allInvocations, wanted, data.getOrderingContext());
checkNumberOfInvocationsNonGreedy(allInvocations, wanted, wantedCount, data.getOrderingContext());
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class InOrderWrapper method verify.
public void verify(VerificationData data) {
List<Invocation> invocations = VerifiableInvocationsFinder.find(inOrder.getMocksToBeVerifiedInOrder());
VerificationDataInOrderImpl dataInOrder = new VerificationDataInOrderImpl(inOrder, invocations, data.getTarget());
mode.verifyInOrder(dataInOrder);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class Times method verify.
@Override
public void verify(VerificationData data) {
List<Invocation> invocations = data.getAllInvocations();
MatchableInvocation wanted = data.getTarget();
if (wantedCount > 0) {
checkMissingInvocation(data.getAllInvocations(), data.getTarget());
}
checkNumberOfInvocations(invocations, wanted, wantedCount);
}
Aggregations