下面列出了org.mockito.internal.verification.api.VerificationData#getWanted ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void verify(VerificationData verificationData) {
List<Invocation> invocations = verificationData.getAllInvocations();
InvocationMatcher invocationMatcher = verificationData.getWanted();
if (invocations == null || invocations.isEmpty()) {
throw new MockitoException(
"\nNo interactions with "
+ invocationMatcher.getInvocation().getMock()
+ " mock so far");
}
Invocation invocation = invocations.get(invocations.size() - 1);
if (!invocationMatcher.matches(invocation)) {
throw new MockitoException("\nWanted but not invoked:\n" + invocationMatcher);
}
}
public void verify(VerificationData data) {
List<Invocation> invocations = data.getAllInvocations();
InvocationMatcher wanted = data.getWanted();
InvocationsFinder finder = new InvocationsFinder();
List<Invocation> found = finder.findInvocations(invocations, wanted);
int foundSize = found.size();
if (foundSize > maxNumberOfInvocations) {
new Reporter().wantedAtMostX(maxNumberOfInvocations, foundSize);
}
invocationMarker.markVerified(found, wanted);
}
@SuppressWarnings("unchecked")
public void verify(VerificationData data) {
InvocationMatcher wantedMatcher = data.getWanted();
List<Invocation> invocations = data.getAllInvocations();
List<Invocation> chunk = finder.findInvocations(invocations,wantedMatcher);
if (invocations.size() != 1 && chunk.size() > 0) {
Invocation unverified = finder.findFirstUnverified(invocations);
reporter.noMoreInteractionsWanted(unverified, (List) invocations);
} else if (invocations.size() != 1 || chunk.size() == 0) {
reporter.wantedButNotInvoked(wantedMatcher);
}
marker.markVerified(chunk.get(0), wantedMatcher);
}
public void verify(VerificationData data) {
List<Invocation> invocations = data.getAllInvocations();
InvocationMatcher wanted = data.getWanted();
InvocationsFinder finder = new InvocationsFinder();
List<Invocation> found = finder.findInvocations(invocations, wanted);
int foundSize = found.size();
if (foundSize > maxNumberOfInvocations) {
new Reporter().wantedAtMostX(maxNumberOfInvocations, foundSize);
}
invocationMarker.markVerified(found, wanted);
}
@SuppressWarnings("unchecked")
public void verify(VerificationData data) {
InvocationMatcher wantedMatcher = data.getWanted();
List<Invocation> invocations = data.getAllInvocations();
List<Invocation> chunk = finder.findInvocations(invocations,wantedMatcher);
if (invocations.size() != 1 && chunk.size() > 0) {
Invocation unverified = finder.findFirstUnverified(invocations);
reporter.noMoreInteractionsWanted(unverified, (List) invocations);
} else if (invocations.size() != 1 || chunk.size() == 0) {
reporter.wantedButNotInvoked(wantedMatcher);
}
marker.markVerified(chunk.get(0), wantedMatcher);
}
@Override
public void verify(VerificationData data) {
List<Invocation> invocations = data.getAllInvocations();
InvocationMatcher matcher = data.getWanted();
Invocation invocation = invocations.get(invocations.size() - 1);
if (!matcher.matches(invocation)) {
throw new MockitoException("This is not the last interaction with the mock object");
}
}
public void verify(VerificationData data) {
List<Invocation> allInvocations = new AllInvocationsFinder().find(inOrder.getMocksToBeVerifiedInOrder());
VerificationDataInOrderImpl dataInOrder = new VerificationDataInOrderImpl(inOrder, allInvocations, data.getWanted());
mode.verifyInOrder(dataInOrder);
}
public void verify(VerificationData data) {
List<Invocation> invocations = new VerifiableInvocationsFinder().find(inOrder.getMocksToBeVerifiedInOrder());
VerificationDataInOrderImpl dataInOrder = new VerificationDataInOrderImpl(inOrder, invocations, data.getWanted());
mode.verifyInOrder(dataInOrder);
}