public class ExternalTaskHandler extends Object
| Constructor and Description |
|---|
ExternalTaskHandler(org.camunda.bpm.engine.ProcessEngine processEngine,
String activityId,
String topicName) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
apply(org.camunda.bpm.engine.runtime.ProcessInstance pi) |
void |
complete()
Completes the external task, which is locked for 60 seconds by calling
complete, using
the specified variables and local variables, when the process instance is waiting at the
corresponding activity. |
protected void |
complete(org.camunda.bpm.engine.externaltask.ExternalTask task) |
ExternalTaskHandler |
customize(Consumer<ExternalTaskHandler> customizer)
Customizes the handler, using the given
Consumer function. |
void |
execute(Consumer<String> action)
Executes a custom action that handles the external task, when the process instance is waiting at
the corresponding activity.
|
void |
executeExternalTask(Consumer<org.camunda.bpm.engine.externaltask.ExternalTask> action)
Executes a custom action that handles the external task, which has been queried (by process
instance ID, activity ID and topic name) and locked before, when the process instance is waiting
at the corresponding activity.
|
void |
executeLockedExternalTask(Consumer<org.camunda.bpm.engine.externaltask.LockedExternalTask> action)
Executes a custom action that handles the external task, which has been queried (by process
instance ID, activity ID and topic name) and locked before, when the process instance is waiting
at the corresponding activity.
|
protected void |
handleBpmnError(org.camunda.bpm.engine.externaltask.ExternalTask task) |
void |
handleBpmnError(String errorCode,
String errorMessage)
Continues the execution with an action that calls
handleBpmnError using the given error
code and message as well as the specified variables. |
boolean |
isWaitingForBoundaryEvent()
Determines if the external task is waiting for a boundary message, signal or timer event.
|
ExternalTaskHandler |
verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert,String> verifier)
Verifies the external task's waiting state.
|
void |
waitForBoundaryEvent()
Applies no action at the external task's wait state.
|
ExternalTaskHandler |
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. |
ExternalTaskHandler |
withLocalVariable(String name,
Object value)
Sets a local variable, which is passed to the execution when the default behavior is used.
|
ExternalTaskHandler |
withLocalVariables(Map<String,Object> localVariables)
Sets local variables, which are passed to the execution when the default behavior is used.
|
ExternalTaskHandler |
withLocalVariableTyped(String name,
org.camunda.bpm.engine.variable.value.TypedValue value)
Sets a typed local variable, which is passed to the execution when the default behavior is used.
|
ExternalTaskHandler |
withVariable(String name,
Object value)
Sets a variable, which is passed to the execution when a predefined behavior is used.
|
ExternalTaskHandler |
withVariables(Map<String,Object> variables)
Sets variables, which are passed to the execution when a predefined behavior is used.
|
ExternalTaskHandler |
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 is used.
|
protected org.camunda.bpm.engine.externaltask.LockedExternalTask |
wrap(org.camunda.bpm.engine.externaltask.ExternalTask task)
Wraps the given
ExternalTask into a LockedExternalTask. |
protected static final String WORKER_ID
protected void apply(org.camunda.bpm.engine.runtime.ProcessInstance pi)
public void complete()
complete, using
the specified variables and local variables, when the process instance is waiting at the
corresponding activity. Please note: this is the default behavior.ExternalTaskService.complete(String, String, java.util.Map, java.util.Map)protected void complete(org.camunda.bpm.engine.externaltask.ExternalTask task)
public ExternalTaskHandler customize(Consumer<ExternalTaskHandler> customizer)
Consumer function. This method can be used to
apply a common customization needed for different test cases.
tc.handleExternalTask().customize(this::prepareExternalTask);
customizer - A function that accepts a ExternalTaskHandler.public void execute(Consumer<String> action)
action - A specific action that accepts the related topic name (String).public void executeExternalTask(Consumer<org.camunda.bpm.engine.externaltask.ExternalTask> action)
action - A specific action that accepts an ExternalTask.ExternalTaskService.lock(String, String, long)public void executeLockedExternalTask(Consumer<org.camunda.bpm.engine.externaltask.LockedExternalTask> action)
action - A specific action that accepts an LockedExternalTask.ExternalTaskService.lock(String, String, long)public void handleBpmnError(String errorCode, String errorMessage)
handleBpmnError using the given error
code and message as well as the specified variables.errorCode - The error code of the attached boundary error event.errorMessage - An error message or null.ExternalTaskService.handleBpmnError(String, String, String, String, java.util.Map)protected void handleBpmnError(org.camunda.bpm.engine.externaltask.ExternalTask task)
public boolean isWaitingForBoundaryEvent()
true, if it is waiting for a boundary event. false, if not.public ExternalTaskHandler verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert,String> verifier)
verifier - Verifier that accepts an ProcessInstanceAssert instance and the related
topic name (String).public void waitForBoundaryEvent()
public ExternalTaskHandler withErrorMessage(String errorMessage)
handleBpmnError.errorMessage - An error message or null.handleBpmnError(String, String)public ExternalTaskHandler withLocalVariable(String name, Object value)
name - The name of the local variable.value - The local variable's value.complete()public ExternalTaskHandler withLocalVariables(Map<String,Object> localVariables)
localVariables - A map of local variables to set.complete()public ExternalTaskHandler withLocalVariableTyped(String name, org.camunda.bpm.engine.variable.value.TypedValue value)
name - The name of the local variable.value - The local variable's typed value.complete()public ExternalTaskHandler withVariable(String name, Object value)
name - The name of the variable.value - The variable's value.complete(),
handleBpmnError(String, String)public ExternalTaskHandler withVariables(Map<String,Object> variables)
variables - A map of variables to set.complete(),
handleBpmnError(String, String)public ExternalTaskHandler withVariableTyped(String name, org.camunda.bpm.engine.variable.value.TypedValue value)
name - The name of the variable.value - The variable's typed value.complete(),
handleBpmnError(String, String)protected org.camunda.bpm.engine.externaltask.LockedExternalTask wrap(org.camunda.bpm.engine.externaltask.ExternalTask task)
ExternalTask into a LockedExternalTask.task - An external task that has been queried by the handler.Copyright © 2023 Camunda. All rights reserved.