public Calls(int wantedNumberOfInvocations) { if( wantedNumberOfInvocations <= 0 ) { throw new MockitoException( "Negative and zero values are not allowed here" ); } this.wantedCount = wantedNumberOfInvocations; }
public MockitoSerializationIssue(String message, Exception cause) { super(message); initCause(cause); filterStackTrace(); }
public MockitoException(String message, Throwable t) { super(message, t); filterStackTrace(); }
public void verify(VerificationData data) { try { this.delegate.verify(data); } catch (MockitoAssertionError error) { VerificationCollectorImpl.this.append(error.getMessage()); } }
public static MockitoException moreThanOneAnnotationNotAllowed(String fieldName) { return new MockitoException("You cannot have more than one Mockito annotation on a field!\n" + "The field '" + fieldName + "' has multiple Mockito annotations.\n" + "For info how to use annotations see examples in javadoc for MockitoAnnotations class."); }
public MockitoException(String message) { super(message); filterStackTrace(); }
public AtMost(int maxNumberOfInvocations) { if (maxNumberOfInvocations < 0) { throw new MockitoException("Negative value is not allowed here"); } this.maxNumberOfInvocations = maxNumberOfInvocations; }
public AtLeast(int wantedNumberOfInvocations) { if (wantedNumberOfInvocations < 0) { throw new MockitoException("Negative value is not allowed here"); } this.wantedCount = wantedNumberOfInvocations; }
public Times(int wantedNumberOfInvocations) { if (wantedNumberOfInvocations < 0) { throw new MockitoException("Negative value is not allowed here"); } this.wantedCount = wantedNumberOfInvocations; }
@Override public void verify(VerificationData data) { throw new MockitoException( "calls is only intended to work with InOrder" ); }
public static MockitoException unsupportedCombinationOfAnnotations(String undesiredAnnotationOne, String undesiredAnnotationTwo) { return new MockitoException("This combination of annotations is not permitted on a single field:\n" + "@" + undesiredAnnotationOne + " and @" + undesiredAnnotationTwo); }
public static MockitoException methodDoesNotAcceptParameter(String method, String parameter) { return new MockitoException(method + "() does not accept " + parameter + " See the Javadoc."); }
public static MockitoException invocationListenersRequiresAtLeastOneListener() { return new MockitoException("invocationListeners() requires at least one listener"); }
public static MockitoException usingConstructorWithFancySerializable(SerializableMode mode) { return new MockitoException("Mocks instantiated with constructor cannot be combined with " + mode + " serialization mode."); }
public static MockitoException defaultAnswerDoesNotAcceptNullParameter() { return new MockitoException("defaultAnswer() does not accept null parameter"); }
public Calls(int wantedNumberOfInvocations) { if( wantedNumberOfInvocations <= 0 ) { throw new MockitoException( "Negative and zero values are not allowed here" ); } this.wantedCount = wantedNumberOfInvocations; }
public AtMost(int maxNumberOfInvocations) { if (maxNumberOfInvocations < 0) { throw new MockitoException("Negative value is not allowed here"); } this.maxNumberOfInvocations = maxNumberOfInvocations; }
public AtLeast(int wantedNumberOfInvocations) { if (wantedNumberOfInvocations < 0) { throw new MockitoException("Negative value is not allowed here"); } this.wantedCount = wantedNumberOfInvocations; }
private InternalMockHandler cast(MockHandler handler) { if (!(handler instanceof InternalMockHandler)) { throw new MockitoException("At the moment you cannot provide own implementations of MockHandler." + "\nPlease see the javadocs for the MockMaker interface."); } return (InternalMockHandler) handler; }
public static MockitoException onlyVoidMethodsCanBeSetToDoNothing() { return new MockitoException(join( "Only void methods can doNothing()!", "Example of correct use of doNothing():", " doNothing().", " doThrow(new RuntimeException())", " .when(mock).someVoidMethod();", "Above means:", "someVoidMethod() does nothing the 1st time but throws an exception the 2nd time is called" )); }