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:
Serializable, org.mockito.stubbing.Answer<Object>

public class LambdaAnswer<T> extends org.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
An Answer to optionally call the real method and allow returning a custom result. Captures any exceptions thrown.
Since:
1.6
Author:
Gary Russell
See Also:
  • Constructor Details

    • LambdaAnswer

      public LambdaAnswer(boolean callRealMethod, LambdaAnswer.ValueToReturn<T> callback, @Nullable 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 Details

    • answer

      public T answer(org.mockito.invocation.InvocationOnMock invocation) throws Throwable
      Specified by:
      answer in interface org.mockito.stubbing.Answer<T>
      Overrides:
      answer in class org.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
      Throws:
      Throwable
    • getExceptions

      public Collection<Exception> getExceptions()
      Return the exceptions thrown, if any.
      Returns:
      the exceptions.
      Since:
      2.2.3