Class FluentMock<T,​P extends org.camunda.bpm.engine.delegate.VariableScope>

  • Type Parameters:
    T - type of mock (JavaDelegate, ExecutionListener, TaskListener)
    P - type of method argument (DelegateExecution, DelegateTask)
    Direct Known Subclasses:
    FluentExecutionListenerMock, FluentJavaDelegateMock, FluentTaskListenerMock

    public abstract class FluentMock<T,​P extends org.camunda.bpm.engine.delegate.VariableScope>
    extends Object
    Common super class for all fluent mocks.
    • Field Detail

      • mock

        protected final T mock
      • parameterType

        protected final Class<P extends org.camunda.bpm.engine.delegate.VariableScope> parameterType
    • Constructor Detail

      • FluentMock

        protected FluentMock​(T mock,
                             Class<P> parameterType)
        Creates a new instance for given mock.
        Parameters:
        mock - the mocked delegate or listener
        parameterType - the parameter type (DelegateExecution, DelegateTask)
    • Method Detail

      • setVariables

        protected void setVariables​(org.camunda.bpm.engine.delegate.VariableScope variableScope,
                                    Map<String,​Object> variables)
      • combineVariableMaps

        protected static org.camunda.bpm.engine.variable.VariableMap[] combineVariableMaps​(org.camunda.bpm.engine.variable.VariableMap variableMap,
                                                                                           org.camunda.bpm.engine.variable.VariableMap... values)
      • setVariablesForMultipleInvocations

        protected void setVariablesForMultipleInvocations​(org.camunda.bpm.engine.variable.VariableMap[] variables,
                                                          String invocationCountVariableName,
                                                          org.camunda.bpm.engine.delegate.VariableScope variableScope)
      • onExecutionSetVariables

        public abstract void onExecutionSetVariables​(org.camunda.bpm.engine.variable.VariableMap variableMap)
        Parameters:
        variableMap - the process variables this delegate sets when executed
      • onExecutionSetVariables

        public abstract void onExecutionSetVariables​(org.camunda.bpm.engine.variable.VariableMap variableMap,
                                                     org.camunda.bpm.engine.variable.VariableMap... values)
        Sets consecutive return values to be returned when the method is called. E.g:
        
         mock.onExecutionSetVariables(variableMap1, variableMap2, variableMap3);
         
        Last return value in the sequence (in example: variableMap3) determines the behavior of further consecutive calls.

        Parameters:
        variableMap - first variables that will be returned
        values - next variables that will be return
      • onExecutionSetVariable

        public void onExecutionSetVariable​(String key,
                                           Object value)
        Parameters:
        key - of the process variables this delegate sets when executed
        value - of the process variables this delegate sets when executed
      • onExecutionSetVariable

        public <V> void onExecutionSetVariable​(io.holunda.camunda.bpm.data.factory.VariableFactory<V> variable,
                                               V value)
        Type Parameters:
        V - the payload type of the variable
        Parameters:
        variable - the VariableFactory declartion (name and type of variable)
        value - the value to set. Type safe.
        See Also:
        onExecutionSetVariable(String, Object)
      • onExecutionSetVariables

        @SafeVarargs
        public final void onExecutionSetVariables​(Map<String,​Object> variables,
                                                  Map<String,​Object>... values)
        Sets consecutive return values to be returned when the method is called. E.g:
        
         mock.onExecutionSetVariables(Map.of("foo", "bar"), Map.of("bar", "foo"));
         
        Last return value in the sequence (in example: Map.of("bar", "foo")) determines the behavior of further consecutive calls.

        Parameters:
        variables - first variables that will be returned
        values - next variables that will be return
      • onExecutionSetVariables

        public void onExecutionSetVariables​(Map<String,​Object> variables)
        Parameters:
        variables - the process variables this delegate sets when executed
      • onExecutionThrowBpmnError

        public void onExecutionThrowBpmnError​(String errorCode)
        The mock will throw a BpmnError with given errorCode.
        Parameters:
        errorCode - the error code
      • onExecutionThrowBpmnError

        public void onExecutionThrowBpmnError​(String errorCode,
                                              String message)
        The mock will throw a BpmnError with given errorCode and message.
        Parameters:
        errorCode - the error code
        message - the error message
      • onExecutionThrowBpmnError

        public abstract void onExecutionThrowBpmnError​(org.camunda.bpm.engine.delegate.BpmnError bpmnError)
        The implementation of throw-bpmn-error depends on the concrete type.
        Parameters:
        bpmnError - the error instance
      • onExecutionThrowException

        public abstract void onExecutionThrowException​(Exception exception)
        The mock will throw the given exception on execution.
        Parameters:
        exception - the exception instance
      • getMock

        public T getMock()
        Returns:
        the internal mock
      • any

        protected P any()
        Returns:
        any(P) for use in Mockito when/doAnswer