Enum MockNature

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<MockNature>

    @Beta
    public enum MockNature
    extends java.lang.Enum<MockNature>
    A named set of defaults for a mock's configuration options. A mock nature is chosen at mock creation time, typically by selecting the appropriate MockingApi factory method.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      MOCK
      A mock object whose method calls are verified, which instantiates class-based mock objects with Objenesis, and whose strategy for responding to unexpected method calls is ZeroOrNullResponse.
      SPY
      A mock object whose method calls are verified, which instantiates class-based mock objects by calling a real constructor, and whose strategy for responding to unexpected method calls is CallRealMethodResponse.
      STUB
      A mock object whose method calls are not verified, which instantiates class-based mock objects with Objenesis, and whose strategy for responding to unexpected method calls is EmptyOrDummyResponse.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IDefaultResponse getDefaultResponse()
      Returns the strategy for responding to unexpected method calls.
      boolean isUseObjenesis()
      Tells whether class-based mock objects should be instantiated with the Objenesis library (if available), or by calling a real constructor.
      boolean isVerified()
      Tells whether method calls should be verified.
      static MockNature valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static MockNature[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • MOCK

        public static final MockNature MOCK
        A mock object whose method calls are verified, which instantiates class-based mock objects with Objenesis, and whose strategy for responding to unexpected method calls is ZeroOrNullResponse.
      • STUB

        public static final MockNature STUB
        A mock object whose method calls are not verified, which instantiates class-based mock objects with Objenesis, and whose strategy for responding to unexpected method calls is EmptyOrDummyResponse.
      • SPY

        public static final MockNature SPY
        A mock object whose method calls are verified, which instantiates class-based mock objects by calling a real constructor, and whose strategy for responding to unexpected method calls is CallRealMethodResponse.
    • Method Detail

      • values

        public static MockNature[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (MockNature c : MockNature.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static MockNature valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • isVerified

        public boolean isVerified()
        Tells whether method calls should be verified.
        Returns:
        whether method calls should be verified
      • isUseObjenesis

        public boolean isUseObjenesis()
        Tells whether class-based mock objects should be instantiated with the Objenesis library (if available), or by calling a real constructor.
        Returns:
        whether class-based mock objects should be instantiated with the Objenesis library (if available), or by calling a real constructor
      • getDefaultResponse

        public IDefaultResponse getDefaultResponse()
        Returns the strategy for responding to unexpected method calls.
        Returns:
        the strategy for responding to unexpected method calls