Package org.camunda.community.bpmndt.api
Class UserTaskHandler
java.lang.Object
org.camunda.community.bpmndt.api.UserTaskHandler
Fluent API to handle user tasks.
-
Constructor Summary
ConstructorsConstructorDescriptionUserTaskHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapply(org.camunda.bpm.engine.runtime.ProcessInstance pi) voidcomplete()Completes the user task with an action that callscomplete, when the process instance is waiting at the corresponding activity.protected voidcomplete(org.camunda.bpm.engine.task.Task task) customize(Consumer<UserTaskHandler> customizer) Customizes the handler, using the givenConsumerfunction.voidExecutes a custom action that handles the user task, when the process instance is waiting at the corresponding activity.voidhandleBpmnError(String errorCode, String errorMessage) Continues the execution with an action that callshandleBpmnErrorusing the given error code and message, when the process instance is waiting at the corresponding activity.protected voidhandleBpmnError(org.camunda.bpm.engine.task.Task task) voidhandleEscalation(String escalationCode) Continues the execution with an action that callshandleEscalationusing the given escalation code, when the process instance is waiting at the corresponding activity.protected voidhandleEscalation(org.camunda.bpm.engine.task.Task task) booleanDetermines 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.voidApplies 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 ishandleBpmnError.withVariable(String name, Object value) Sets a variable, which is passed to the execution when a predefined behavior (complete,handleBpmnError, orhandleEscalation) is used.withVariables(Map<String, Object> variables) Sets variables, which are passed to the execution when a predefined behavior (complete,handleBpmnError, orhandleEscalation) 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, orhandleEscalation) is used.
-
Constructor Details
-
UserTaskHandler
-
-
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 callscomplete, when the process instance is waiting at the corresponding activity. Please note: this is the default behavior.- See Also:
-
complete
protected void complete(org.camunda.bpm.engine.task.Task task) -
customize
Customizes the handler, using the givenConsumerfunction. 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 aUserTaskHandler.- Returns:
- The handler.
-
execute
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 relatedTask.
-
handleBpmnError
Continues the execution with an action that callshandleBpmnErrorusing 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 ornull.- See Also:
-
handleBpmnError
protected void handleBpmnError(org.camunda.bpm.engine.task.Task task) -
handleEscalation
Continues the execution with an action that callshandleEscalationusing 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:
-
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 anProcessInstanceAssertand anTaskAssertinstance.- 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
Sets the error message, which is used when the next activity is an error boundary event - in this case the handler's action ishandleBpmnError.- Parameters:
errorMessage- An error message ornull.- Returns:
- The handler.
-
withVariable
Sets a variable, which is passed to the execution when a predefined behavior (complete,handleBpmnError, orhandleEscalation) is used.- Parameters:
name- The name of the variable.value- The variable's value.- Returns:
- The handler.
- See Also:
-
withVariables
Sets variables, which are passed to the execution when a predefined behavior (complete,handleBpmnError, orhandleEscalation) 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, orhandleEscalation) is used.- Parameters:
name- The name of the variable.value- The variable's typed value.- Returns:
- The handler.
- See Also:
-