com.fitbur.mockito.internal.verification.checkers.AtLeastXNumberOfInvocationsInOrderChecker Maven / Gradle / Ivy
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package com.fitbur.mockito.internal.verification.checkers;
import static com.fitbur.mockito.exceptions.Reporter.tooLittleActualInvocationsInOrder;
import static com.fitbur.mockito.internal.invocation.InvocationMarker.markVerifiedInOrder;
import java.util.List;
import com.fitbur.mockito.internal.invocation.InvocationMatcher;
import com.fitbur.mockito.internal.invocation.InvocationsFinder;
import com.fitbur.mockito.internal.verification.api.InOrderContext;
import com.fitbur.mockito.invocation.Invocation;
import com.fitbur.mockito.invocation.Location;
public class AtLeastXNumberOfInvocationsInOrderChecker {
private final InvocationsFinder finder = new InvocationsFinder();
private final InOrderContext orderingContext;
public AtLeastXNumberOfInvocationsInOrderChecker(InOrderContext orderingContext) {
this.orderingContext = orderingContext;
}
public void check(List invocations, InvocationMatcher wanted, int wantedCount) {
List chunk = finder.findAllMatchingUnverifiedChunks(invocations, wanted, orderingContext);
int actualCount = chunk.size();
if (wantedCount > actualCount) {
Location lastLocation = finder.getLastLocation(chunk);
throw tooLittleActualInvocationsInOrder(new AtLeastDiscrepancy(wantedCount, actualCount), wanted, lastLocation);
}
markVerifiedInOrder(chunk, wanted, orderingContext);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy