Class UserTaskHandler

java.lang.Object
org.camunda.community.bpmndt.api.UserTaskHandler

public class UserTaskHandler extends Object
Fluent API to handle user tasks.
  • Constructor Summary

    Constructors
    Constructor
    Description
    UserTaskHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    apply(org.camunda.bpm.engine.runtime.ProcessInstance pi)
     
    void
    Completes the user task with an action that calls complete, when the process instance is waiting at the corresponding activity.
    protected void
    complete(org.camunda.bpm.engine.task.Task task)
     
    Customizes the handler, using the given Consumer function.
    void
    execute(Consumer<org.camunda.bpm.engine.task.Task> action)
    Executes a custom action that handles the user task, when the process instance is waiting at the corresponding activity.
    void
    handleBpmnError(String errorCode, String errorMessage)
    Continues the execution with an action that calls handleBpmnError using the given error code and message, when the process instance is waiting at the corresponding activity.
    protected void
    handleBpmnError(org.camunda.bpm.engine.task.Task task)
     
    void
    handleEscalation(String escalationCode)
    Continues the execution with an action that calls handleEscalation using the given escalation code, when the process instance is waiting at the corresponding activity.
    protected void
    handleEscalation(org.camunda.bpm.engine.task.Task task)
     
    boolean
    Determines if the user task is waiting for a boundary message, signal or timer event.
    verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert,org.camunda.bpm.engine.test.assertions.bpmn.TaskAssert> verifier)
    Verifies the user task's waiting state.
    void
    Applies no action at the user task's wait state.
    withErrorMessage(String errorMessage)
    Sets the error message, which is used when the next activity is an error boundary event - in this case the handler's action is handleBpmnError.
    withVariable(String name, Object value)
    Sets a variable, which is passed to the execution when a predefined behavior (complete, handleBpmnError, or handleEscalation) is used.
    Sets variables, which are passed to the execution when a predefined behavior (complete, handleBpmnError, or handleEscalation) is used.
    withVariableTyped(String name, org.camunda.bpm.engine.variable.value.TypedValue value)
    Sets a typed variable, which is passed to the execution when a predefined behavior (complete, handleBpmnError, or handleEscalation) is used.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UserTaskHandler

      public UserTaskHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId)
  • Method Details

    • apply

      protected void apply(org.camunda.bpm.engine.runtime.ProcessInstance pi)
    • complete

      public void complete()
      Completes the user task with an action that calls complete, when the process instance is waiting at the corresponding activity. Please note: this is the default behavior.
      See Also:
      • TaskService.complete(String, java.util.Map)
    • complete

      protected void complete(org.camunda.bpm.engine.task.Task task)
    • customize

      public UserTaskHandler customize(Consumer<UserTaskHandler> customizer)
      Customizes the handler, using the given Consumer function. This method can be used to apply a common customization needed for different test cases.
       tc.handleUserTask().customize(this::prepareUserTask);
       
      Parameters:
      customizer - A function that accepts a UserTaskHandler.
      Returns:
      The handler.
    • execute

      public void execute(Consumer<org.camunda.bpm.engine.task.Task> action)
      Executes a custom action that handles the user task, when the process instance is waiting at the corresponding activity.
      Parameters:
      action - A specific action that accepts the related Task.
    • handleBpmnError

      public void handleBpmnError(String errorCode, String errorMessage)
      Continues the execution with an action that calls handleBpmnError using the given error code and message, when the process instance is waiting at the corresponding activity.
      Parameters:
      errorCode - The error code of the attached boundary error event.
      errorMessage - An error message or null.
      See Also:
      • TaskService.handleBpmnError(String, String, String, java.util.Map)
    • handleBpmnError

      protected void handleBpmnError(org.camunda.bpm.engine.task.Task task)
    • handleEscalation

      public void handleEscalation(String escalationCode)
      Continues the execution with an action that calls handleEscalation using the given escalation code, when the process instance is waiting at the corresponding activity.
      Parameters:
      escalationCode - The escalation code of the attached boundary escalation event.
      See Also:
      • TaskService.handleEscalation(String, String, java.util.Map)
    • handleEscalation

      protected void handleEscalation(org.camunda.bpm.engine.task.Task task)
    • isWaitingForBoundaryEvent

      public boolean isWaitingForBoundaryEvent()
      Determines if the user task is waiting for a boundary message, signal or timer event.
      Returns:
      true, if it is waiting for a boundary event. false, if not.
    • verify

      public UserTaskHandler verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert,org.camunda.bpm.engine.test.assertions.bpmn.TaskAssert> verifier)
      Verifies the user task's waiting state.
      Parameters:
      verifier - Verifier that accepts an ProcessInstanceAssert and an TaskAssert instance.
      Returns:
      The handler.
    • waitForBoundaryEvent

      public void waitForBoundaryEvent()
      Applies no action at the user task's wait state. This is required to wait for events (e.g. message, signal or timer events) that are attached as boundary events on the activity itself or on the surrounding scope (e.g. embedded subprocess).
    • withErrorMessage

      public UserTaskHandler withErrorMessage(String errorMessage)
      Sets the error message, which is used when the next activity is an error boundary event - in this case the handler's action is handleBpmnError.
      Parameters:
      errorMessage - An error message or null.
      Returns:
      The handler.
    • withVariable

      public UserTaskHandler withVariable(String name, Object value)
      Sets a variable, which is passed to the execution when a predefined behavior (complete, handleBpmnError, or handleEscalation) is used.
      Parameters:
      name - The name of the variable.
      value - The variable's value.
      Returns:
      The handler.
      See Also:
    • withVariables

      public UserTaskHandler withVariables(Map<String,Object> variables)
      Sets variables, which are passed to the execution when a predefined behavior (complete, handleBpmnError, or handleEscalation) is used.
      Parameters:
      variables - A map of variables to set.
      Returns:
      The handler.
      See Also:
    • withVariableTyped

      public UserTaskHandler withVariableTyped(String name, org.camunda.bpm.engine.variable.value.TypedValue value)
      Sets a typed variable, which is passed to the execution when a predefined behavior (complete, handleBpmnError, or handleEscalation) is used.
      Parameters:
      name - The name of the variable.
      value - The variable's typed value.
      Returns:
      The handler.
      See Also: