Enum Class Expressions

java.lang.Object
java.lang.Enum<Expressions>
org.camunda.community.mockito.Expressions
All Implemented Interfaces:
Serializable, Comparable<Expressions>, Constable

public enum Expressions extends Enum<Expressions>
Util class that delegates to Mocks.register(String, Object) and Mocks.get(Object) in a type-safe way.

When mocking JavaDelegate, ExecutionListener or TaskListener, use DelegateExpressions instead.

  • Method Details

    • values

      public static Expressions[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Expressions valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • registerMockInstancesForNestedTypes

      public static void registerMockInstancesForNestedTypes(Class<?> parentClass)
      Registers mock instances for every public static nested class found in parentClass.
      Parameters:
      parentClass - the parentClass to scan for nested public static types
    • registerInstancesForFields

      public static void registerInstancesForFields(Object instance)
      Registers mocks via Mocks.register(String, Object) for all attributes with Named-types.
      Parameters:
      instance - instance who's fields are registered (maybe Junit test or jbehave steps).
    • registerNewInstancesForNestedTypes

      public static void registerNewInstancesForNestedTypes(Class<?> parentClass)
      Registers new instances for every public static nested class found in parentClass.
      Parameters:
      parentClass - the parentClass to scan for nested public static types
    • registerMockInstances

      public static void registerMockInstances(Class<?>... types)
      Creates and registers mock instance for every given type.
      Parameters:
      types - collection of types to mock and register
      See Also:
    • registerMockInstances

      public static void registerMockInstances(Collection<Class<?>> types)
      Creates and registers mock instance for every given type.
      Parameters:
      types - collection of types to mock and register
    • registerMockInstance

      public static <T> T registerMockInstance(String name, Class<T> type)
      Creates a mock for the given type and registers it.
      Parameters:
      name - the juel name under which the mock is registered
      type - the type of the mock to create
      Returns:
      the registered mock instance
    • registerMockInstance

      public static <T> T registerMockInstance(Class<T> type)
      Creates a mock for the given type and registers it.
      Parameters:
      type - the type of the mock to create
      Returns:
      the registered mock instance
    • registerNewInstance

      public static <T> T registerNewInstance(String name, Class<T> type)
      Creates a new instance for the given type and registers it under the given name.
      Parameters:
      name - the name for the registered instance
      type - the type of the instance to create
      Returns:
      the registered instance
    • registerNewInstance

      public static <T> T registerNewInstance(Class<T> type)
      Creates a new instance for the given type using the default constructor and registers it.
      Parameters:
      type - the type of the instance to create
      Returns:
      the registered instance
      See Also:
    • registerInstance

      public static <T> T registerInstance(T instance)
      If you already have the instance, register it directly. Name is guessed via NameForType.
      Parameters:
      instance - the instance or mock to register
      Returns:
      the registered instance
    • registerInstance

      public static <T> T registerInstance(String name, T instance)
      Delegates to Mocks.register(String, Object)
      Parameters:
      name - the juel name for the registered instance
      instance - the instance to register
      Returns:
      the registered instance
    • getRegistered

      public static <T> T getRegistered(String name)
      Parameters:
      name - juel name of the registered instance or mock
      Returns:
      registered instance or mock of type
    • getRegistered

      public static <T> T getRegistered(Class<?> type)
      Parameters:
      type - the type of the registered instance or mock
      Returns:
      registered instance or mock for type
    • reset

      public static void reset()
      See Also:
      • Mocks.reset()