Class Returns

java.lang.Object
org.mockito.internal.stubbing.answers.Returns
All Implemented Interfaces:
Serializable, Answer<Object>, ValidableAnswer

public class Returns extends Object implements Answer<Object>, ValidableAnswer, Serializable
See Also:
  • Field Details

  • Constructor Details

    • Returns

      public Returns(Object value)
  • Method Details

    • answer

      public Object answer(InvocationOnMock invocation) throws Throwable
      Specified by:
      answer in interface Answer<Object>
      Parameters:
      invocation - the invocation on the mock.
      Returns:
      the value to be returned
      Throws:
      Throwable - the throwable to be thrown
    • 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 interface ValidableAnswer
      Parameters:
      invocation - The stubbed invocation
    • printReturnType

      private String printReturnType()
    • returnType

      private Class<?> returnType()
    • returnsNull

      private boolean returnsNull()
    • toString

      public String toString()
      Overrides:
      toString in class Object