public class ThrowsException extends java.lang.Object implements Answer<java.lang.Object>, ValidableAnswer, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private ConditionalStackTraceFilter |
filter |
private static long |
serialVersionUID |
private java.lang.Throwable |
throwable |
Constructor and Description |
---|
ThrowsException(java.lang.Throwable throwable)
Creates a new answer always throwing the given throwable.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
answer(InvocationOnMock invocation) |
void |
validateFor(InvocationOnMock invocation)
Validation of the answer at stub time for the given invocation.
|
private static final long serialVersionUID
private final java.lang.Throwable throwable
private final ConditionalStackTraceFilter filter
public ThrowsException(java.lang.Throwable throwable)
public java.lang.Object answer(InvocationOnMock invocation) throws java.lang.Throwable
public void validateFor(InvocationOnMock invocation)
ValidableAnswer
This method will be called by Mockito.
The implementation must throw an MockitoException to indicate that this answer is not valid for the given invocation. If the validation succeed the implementation must simply return without throwing.
validateFor
in interface ValidableAnswer
invocation
- The stubbed invocation