Package org.camunda.community.bpmndt.api
Class ExternalTaskHandler
java.lang.Object
org.camunda.community.bpmndt.api.ExternalTaskHandler
Fluent API to handle external tasks.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionExternalTaskHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId, String topicName) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapply(org.camunda.bpm.engine.runtime.ProcessInstance pi) voidcomplete()Completes the external task, which is locked for 60 seconds by callingcomplete, using the specified variables and local variables, when the process instance is waiting at the corresponding activity.protected voidcomplete(org.camunda.bpm.engine.externaltask.ExternalTask task) customize(Consumer<ExternalTaskHandler> customizer) Customizes the handler, using the givenConsumerfunction.voidExecutes a custom action that handles the external task, when the process instance is waiting at the corresponding activity.voidexecuteExternalTask(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.voidexecuteLockedExternalTask(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.voidhandleBpmnError(String errorCode, String errorMessage) Continues the execution with an action that callshandleBpmnErrorusing the given error code and message as well as the specified variables.protected voidhandleBpmnError(org.camunda.bpm.engine.externaltask.ExternalTask task) booleanDetermines if the external task is waiting for a boundary message, signal or timer event.verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert, String> verifier) Verifies the external task's waiting state.verifyTask(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ExternalTaskAssert, Map<String, Object>> taskVerifier) Verifies the external task's waiting state.voidApplies no action at the external 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.withLocalVariable(String name, Object value) Sets a local variable, which is passed to the execution when the default behavior is used.withLocalVariables(Map<String, Object> localVariables) Sets local variables, which are passed to the execution when the default behavior is used.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.withVariable(String name, Object value) Sets a variable, which is passed to the execution when a predefined behavior is used.withVariables(Map<String, Object> variables) Sets variables, which are passed to the execution when a predefined behavior 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 is used.protected org.camunda.bpm.engine.externaltask.LockedExternalTaskwrap(org.camunda.bpm.engine.externaltask.ExternalTask task) Wraps the givenExternalTaskinto aLockedExternalTask.
-
Field Details
-
WORKER_ID
- See Also:
-
-
Constructor Details
-
ExternalTaskHandler
-
-
Method Details
-
apply
protected void apply(org.camunda.bpm.engine.runtime.ProcessInstance pi) -
complete
public void complete()Completes the external task, which is locked for 60 seconds by callingcomplete, using the specified variables and local variables, 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.externaltask.ExternalTask task) -
customize
Customizes the handler, using the givenConsumerfunction. This method can be used to apply a common customization needed for different test cases.tc.handleExternalTask().customize(this::prepareExternalTask);
- Parameters:
customizer- A function that accepts aExternalTaskHandler.- Returns:
- The handler.
-
execute
Executes a custom action that handles the external task, when the process instance is waiting at the corresponding activity.- Parameters:
action- A specific action that accepts the related topic name (String).
-
executeExternalTask
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.- Parameters:
action- A specific action that accepts anExternalTask.- See Also:
-
executeLockedExternalTask
public 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.- Parameters:
action- A specific action that accepts anLockedExternalTask.- See Also:
-
handleBpmnError
Continues the execution with an action that callshandleBpmnErrorusing the given error code and message as well as the specified variables.- 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.externaltask.ExternalTask task) -
isWaitingForBoundaryEvent
public boolean isWaitingForBoundaryEvent()Determines if the external 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 ExternalTaskHandler verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert, String> verifier) Verifies the external task's waiting state.- Parameters:
verifier- Verifier that accepts anProcessInstanceAssertinstance and the related topic name (String).- Returns:
- The handler.
-
verifyTask
public ExternalTaskHandler verifyTask(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ExternalTaskAssert, Map<String, Object>> taskVerifier) Verifies the external task's waiting state.- Parameters:
taskVerifier- Verifier that accepts anExternalTaskAssertinstance and the task's local variables.- Returns:
- The handler.
-
waitForBoundaryEvent
public void waitForBoundaryEvent()Applies no action at the external 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.
- See Also:
-
withLocalVariable
Sets a local variable, which is passed to the execution when the default behavior is used.- Parameters:
name- The name of the local variable.value- The local variable's value.- Returns:
- The handler.
- See Also:
-
withLocalVariables
Sets local variables, which are passed to the execution when the default behavior is used.- Parameters:
localVariables- A map of local variables to set.- Returns:
- The handler.
- See Also:
-
withLocalVariableTyped
public 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.- Parameters:
name- The name of the local variable.value- The local variable's typed value.- Returns:
- The handler.
- See Also:
-
withVariable
Sets a variable, which is passed to the execution when a predefined behavior 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 is used.- Parameters:
variables- A map of variables to set.- Returns:
- The handler.
- See Also:
-
withVariableTyped
public 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.- Parameters:
name- The name of the variable.value- The variable's typed value.- Returns:
- The handler.
- See Also:
-
wrap
protected org.camunda.bpm.engine.externaltask.LockedExternalTask wrap(org.camunda.bpm.engine.externaltask.ExternalTask task) Wraps the givenExternalTaskinto aLockedExternalTask.- Parameters:
task- An external task that has been queried by the handler.- Returns:
- The wrapped task.
-