public class AnswersWithDelay extends java.lang.Object implements Answer<java.lang.Object>, ValidableAnswer, java.io.Serializable
The sleepyTime
specifies how long, in milliseconds, to pause before
returning the provided answer
.
AdditionalAnswers
,
Serialized FormModifier and Type | Field and Description |
---|---|
private Answer<java.lang.Object> |
answer |
private static long |
serialVersionUID |
private long |
sleepyTime |
Constructor and Description |
---|
AnswersWithDelay(long sleepyTime,
Answer<java.lang.Object> answer) |
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 long sleepyTime
private final Answer<java.lang.Object> answer
public AnswersWithDelay(long sleepyTime, Answer<java.lang.Object> answer)
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