Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2007 Mockito contributors
  * This program is made available under the terms of the MIT License.
  */
 package org.mockito.internal.verification.checkers;
 
 import java.util.List;
 
    
    private final Reporter reporter;
    private final InvocationsFinder finder;
    private final InvocationMarker invocationMarker = new InvocationMarker();
    public NumberOfInvocationsChecker() {
        this(new Reporter(), new InvocationsFinder());
    }
    
        this. = reporter;
        this. = finder;
    }
    
    public void check(List<InvocationinvocationsInvocationMatcher wantedint wantedCount) {
        List<InvocationactualInvocations = .findInvocations(invocationswanted);
        
        int actualCount = actualInvocations.size();
        if (wantedCount > actualCount) {
            Location lastInvocation = .getLastLocation(actualInvocations);
            .tooLittleActualInvocations(new Discrepancy(wantedCountactualCount), wantedlastInvocation);
        } else if (wantedCount == 0 && actualCount > 0) {
            Location firstUndesired = actualInvocations.get(wantedCount).getLocation();
            .neverWantedButInvoked(wantedfirstUndesired); 
        } else if (wantedCount < actualCount) {
            Location firstUndesired = actualInvocations.get(wantedCount).getLocation();
            .tooManyActualInvocations(wantedCountactualCountwantedfirstUndesired);
        }
        
        .markVerified(actualInvocationswanted);
    }
New to GrepCode? Check out our FAQ X