Search in sources :

Example 6 with MatchableInvocation

use of org.mockito.invocation.MatchableInvocation 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());
}
Also used : MatchableInvocation(org.mockito.invocation.MatchableInvocation) Invocation(org.mockito.invocation.Invocation) MatchableInvocation(org.mockito.invocation.MatchableInvocation) MissingInvocationChecker.checkMissingInvocation(org.mockito.internal.verification.checkers.MissingInvocationChecker.checkMissingInvocation)

Example 7 with MatchableInvocation

use of org.mockito.invocation.MatchableInvocation 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);
}
Also used : MatchableInvocation(org.mockito.invocation.MatchableInvocation) Invocation(org.mockito.invocation.Invocation) MatchableInvocation(org.mockito.invocation.MatchableInvocation) MissingInvocationChecker.checkMissingInvocation(org.mockito.internal.verification.checkers.MissingInvocationChecker.checkMissingInvocation)

Example 8 with MatchableInvocation

use of org.mockito.invocation.MatchableInvocation in project mockito by mockito.

the class Times method verifyInOrder.

@Override
public void verifyInOrder(VerificationDataInOrder data) {
    List<Invocation> allInvocations = data.getAllInvocations();
    MatchableInvocation wanted = data.getWanted();
    if (wantedCount > 0) {
        checkMissingInvocation(allInvocations, wanted, data.getOrderingContext());
    }
    checkNumberOfInvocations(allInvocations, wanted, wantedCount, data.getOrderingContext());
}
Also used : MatchableInvocation(org.mockito.invocation.MatchableInvocation) Invocation(org.mockito.invocation.Invocation) MatchableInvocation(org.mockito.invocation.MatchableInvocation) MissingInvocationChecker.checkMissingInvocation(org.mockito.internal.verification.checkers.MissingInvocationChecker.checkMissingInvocation)

Example 9 with MatchableInvocation

use of org.mockito.invocation.MatchableInvocation in project mockito by mockito.

the class AtLeastXNumberOfInvocationsChecker method checkAtLeastNumberOfInvocations.

public static void checkAtLeastNumberOfInvocations(List<Invocation> invocations, MatchableInvocation wanted, int wantedCount, InOrderContext orderingContext) {
    List<Invocation> chunk = findAllMatchingUnverifiedChunks(invocations, wanted, orderingContext);
    int actualCount = chunk.size();
    if (wantedCount > actualCount) {
        Location lastLocation = getLastLocation(chunk);
        throw tooLittleActualInvocationsInOrder(new AtLeastDiscrepancy(wantedCount, actualCount), wanted, lastLocation);
    }
    markVerifiedInOrder(chunk, wanted, orderingContext);
}
Also used : Invocation(org.mockito.invocation.Invocation) MatchableInvocation(org.mockito.invocation.MatchableInvocation) InvocationsFinder.getLastLocation(org.mockito.internal.invocation.InvocationsFinder.getLastLocation) Location(org.mockito.invocation.Location)

Example 10 with MatchableInvocation

use of org.mockito.invocation.MatchableInvocation in project mockito by mockito.

the class MissingInvocationChecker method checkMissingInvocation.

public static void checkMissingInvocation(List<Invocation> invocations, MatchableInvocation wanted, InOrderContext context) {
    List<Invocation> chunk = findAllMatchingUnverifiedChunks(invocations, wanted, context);
    if (!chunk.isEmpty()) {
        return;
    }
    Invocation previousInOrder = findPreviousVerifiedInOrder(invocations, context);
    if (previousInOrder != null) {
        throw wantedButNotInvokedInOrder(wanted, previousInOrder);
    }
    checkMissingInvocation(invocations, wanted);
}
Also used : Invocation(org.mockito.invocation.Invocation) MatchableInvocation(org.mockito.invocation.MatchableInvocation) InvocationsFinder.findSimilarInvocation(org.mockito.internal.invocation.InvocationsFinder.findSimilarInvocation)

Aggregations

Invocation (org.mockito.invocation.Invocation)14 MatchableInvocation (org.mockito.invocation.MatchableInvocation)14 InvocationsFinder.getLastLocation (org.mockito.internal.invocation.InvocationsFinder.getLastLocation)6 Location (org.mockito.invocation.Location)6 Discrepancy (org.mockito.internal.reporting.Discrepancy)4 InvocationsFinder.findFirstMatchingUnverifiedInvocation (org.mockito.internal.invocation.InvocationsFinder.findFirstMatchingUnverifiedInvocation)3 MissingInvocationChecker.checkMissingInvocation (org.mockito.internal.verification.checkers.MissingInvocationChecker.checkMissingInvocation)3 InvocationsFinder.findSimilarInvocation (org.mockito.internal.invocation.InvocationsFinder.findSimilarInvocation)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Test (org.junit.Test)1 SmartPrinter (org.mockito.internal.reporting.SmartPrinter)1