Class LambdaAnswer<T>
- java.lang.Object
-
- org.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
-
- org.springframework.amqp.rabbit.test.mockito.LambdaAnswer<T>
-
- Type Parameters:
T
- the return type.
- All Implemented Interfaces:
java.io.Serializable
,org.mockito.stubbing.Answer<java.lang.Object>
public class LambdaAnswer<T> extends org.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
AnAnswer
to optionally call the real method and allow returning a custom result. Captures any exceptions thrown.- Since:
- 1.6
- Author:
- Gary Russell
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LambdaAnswer.ValueToReturn<T>
-
Constructor Summary
Constructors Constructor Description LambdaAnswer(boolean callRealMethod, LambdaAnswer.ValueToReturn<T> callback)
Deprecated.in favor ofLambdaAnswer(boolean, ValueToReturn, Object)
.LambdaAnswer(boolean callRealMethod, LambdaAnswer.ValueToReturn<T> callback, java.lang.Object delegate)
Construct an instance with the provided properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
answer(org.mockito.invocation.InvocationOnMock invocation)
java.util.Collection<java.lang.Exception>
getExceptions()
Return the exceptions thrown, if any.
-
-
-
Constructor Detail
-
LambdaAnswer
@Deprecated public LambdaAnswer(boolean callRealMethod, LambdaAnswer.ValueToReturn<T> callback)
Deprecated.in favor ofLambdaAnswer(boolean, ValueToReturn, Object)
.Deprecated.- Parameters:
callRealMethod
- true to call the real method.callback
- the callback.
-
LambdaAnswer
public LambdaAnswer(boolean callRealMethod, LambdaAnswer.ValueToReturn<T> callback, @Nullable java.lang.Object delegate)
Construct an instance with the provided properties. Use the test harness to get an instance with the proper delegate.- Parameters:
callRealMethod
- true to call the real method.callback
- the call back to receive the result.delegate
- the delegate.
-
-
Method Detail
-
answer
public T answer(org.mockito.invocation.InvocationOnMock invocation) throws java.lang.Throwable
- Specified by:
answer
in interfaceorg.mockito.stubbing.Answer<T>
- Overrides:
answer
in classorg.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
- Throws:
java.lang.Throwable
-
getExceptions
public java.util.Collection<java.lang.Exception> getExceptions()
Return the exceptions thrown, if any.- Returns:
- the exceptions.
- Since:
- 2.2.3
-
-