use of org.mockito.invocation.Location in project mockito by mockito.
the class AtLeastXNumberOfInvocationsChecker method checkAtLeastNumberOfInvocations.
public static void checkAtLeastNumberOfInvocations(List<Invocation> invocations, MatchableInvocation wanted, int wantedCount) {
List<Invocation> actualInvocations = findInvocations(invocations, wanted);
int actualCount = actualInvocations.size();
if (wantedCount > actualCount) {
Location lastLocation = getLastLocation(actualInvocations);
throw tooLittleActualInvocations(new AtLeastDiscrepancy(wantedCount, actualCount), wanted, lastLocation);
}
markVerified(actualInvocations, wanted);
}
use of org.mockito.invocation.Location in project mockito by mockito.
the class NumberOfInvocationsInOrderChecker method check.
public void check(List<Invocation> invocations, MatchableInvocation wanted, int wantedCount, InOrderContext context) {
List<Invocation> chunk = findMatchingChunk(invocations, wanted, wantedCount, context);
int actualCount = chunk.size();
if (wantedCount > actualCount) {
Location lastInvocation = getLastLocation(chunk);
throw tooLittleActualInvocationsInOrder(new Discrepancy(wantedCount, actualCount), wanted, lastInvocation);
}
if (wantedCount < actualCount) {
Location firstUndesired = chunk.get(wantedCount).getLocation();
throw tooManyActualInvocationsInOrder(wantedCount, actualCount, wanted, firstUndesired);
}
markVerifiedInOrder(chunk, wanted, context);
}
use of org.mockito.invocation.Location in project mockito by mockito.
the class MockingProgressImpl method validateMostStuff.
private void validateMostStuff() {
//State is cool when GlobalConfiguration is already loaded
//this cannot really be tested functionally because I cannot dynamically mess up org.mockito.configuration.MockitoConfiguration class
GlobalConfiguration.validate();
if (verificationMode != null) {
Location location = verificationMode.getLocation();
verificationMode = null;
throw unfinishedVerificationException(location);
}
getArgumentMatcherStorage().validateState();
}
use of org.mockito.invocation.Location in project mockito by mockito.
the class MockingProgressImpl method validateState.
public void validateState() {
validateMostStuff();
//validate stubbing:
if (stubbingInProgress != null) {
Location temp = stubbingInProgress;
stubbingInProgress = null;
throw unfinishedStubbing(temp);
}
}
use of org.mockito.invocation.Location in project mockito by mockito.
the class InvocationsFinderTest method shouldGetLastStackTrace.
@Test
public void shouldGetLastStackTrace() throws Exception {
Location last = InvocationsFinder.getLastLocation(invocations);
assertSame(differentMethodInvocation.getLocation(), last);
assertNull(InvocationsFinder.getLastLocation(Collections.<Invocation>emptyList()));
}
Aggregations