Class AnswersWithDelay
- java.lang.Object
-
- org.mockito.internal.stubbing.answers.AnswersWithDelay
-
- All Implemented Interfaces:
java.io.Serializable
,Answer<java.lang.Object>
,ValidableAnswer
public class AnswersWithDelay extends java.lang.Object implements Answer<java.lang.Object>, ValidableAnswer, java.io.Serializable
Returns as the provided answer would return, after delaying the specified amount.The
sleepyTime
specifies how long, in milliseconds, to pause before returning the providedanswer
.- Since:
- 2.8.44
- See Also:
AdditionalAnswers
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Answer<java.lang.Object>
answer
private static long
serialVersionUID
private long
sleepyTime
-
Constructor Summary
Constructors Constructor Description AnswersWithDelay(long sleepyTime, Answer<java.lang.Object> answer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
answer(InvocationOnMock invocation)
void
validateFor(InvocationOnMock invocation)
Validation of the answer at stub time for the given invocation.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
sleepyTime
private final long sleepyTime
-
answer
private final Answer<java.lang.Object> answer
-
-
Constructor Detail
-
AnswersWithDelay
public AnswersWithDelay(long sleepyTime, Answer<java.lang.Object> answer)
-
-
Method Detail
-
answer
public java.lang.Object answer(InvocationOnMock invocation) throws java.lang.Throwable
-
validateFor
public void validateFor(InvocationOnMock invocation)
Description copied from interface:ValidableAnswer
Validation of the answer at stub time for the given invocation.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.
- Specified by:
validateFor
in interfaceValidableAnswer
- Parameters:
invocation
- The stubbed invocation
-
-