/** * Performs verification using the wrapped verification mode implementation. * Prepends the custom failure message if verification fails. * @param data the data to be verified */ @Override public void verify(VerificationData data) { try { verification.verify(data); } catch (MockitoAssertionError e) { throw new MockitoAssertionError(e, description); } }
public void wantedAtMostX(int maxNumberOfInvocations, int foundSize) { throw new MockitoAssertionError(join("Wanted at most " + pluralize(maxNumberOfInvocations) + " but was " + foundSize)); }
public void collectAndReport() throws MockitoAssertionError { mockingProgress().setVerificationStrategy(MockingProgressImpl.getDefaultVerificationStrategy()); if (this.numberOfFailures > 0) { String error = this.builder.toString(); this.resetBuilder(); throw new MockitoAssertionError(error); } }
@Override public void verifyInOrder(VerificationDataInOrder data) { Invocation firstUnverifiedInvocation = finder.findFirstUnverifiedInOrder(data.getOrderingContext(), data.getAllInvocations()); if (firstUnverifiedInvocation == null) { Invocation previouslyVerified = finder.findPreviousVerifiedInOrder(data.getAllInvocations(), data.getOrderingContext()); new Reporter().wantedButNotInvokedInOrder(data.getWanted(), previouslyVerified); } if (!data.getWanted().matches(firstUnverifiedInvocation)) { StringBuilder sb = new StringBuilder(); sb.append("Expected next invocation specified here: \n"); sb.append(data.getWanted().getLocation()); sb.append("\n"); sb.append("but next invocation was: \n"); sb.append(firstUnverifiedInvocation.getLocation()); sb.append("\n"); throw new MockitoAssertionError(sb.toString()); } }
public void wantedAtMostX(int maxNumberOfInvocations, int foundSize) { throw new MockitoAssertionError(join("Wanted at most " + pluralize(maxNumberOfInvocations) + " but was " + foundSize)); }