Package org.camunda.community.bpmndt.api
Class JobHandler
java.lang.Object
org.camunda.community.bpmndt.api.JobHandler
Fluent API to handle jobs in form of service, script, send or business rule tasks as well as intermediate message throw or message end events.
Please note: a job is not completed by default. The application must run an appropriate worker, which completes relates jobs or throws a BPMN error. If a worker implementation is missing,
Please note: a job is not completed by default. The application must run an appropriate worker, which completes relates jobs or throws a BPMN error. If a worker implementation is missing,
complete(), throwBpmnError(String, String) or execute(BiConsumer) can be used to handle the
job.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Executes an action that completes the job, when the process instance is waiting at the corresponding element, using specified variables.customize(Consumer<JobHandler> customizer) Customizes the handler, using the givenConsumerfunction.voidexecute(BiConsumer<io.camunda.zeebe.client.ZeebeClient, Long> action) Executes a custom action that handles the job, when the process instance is waiting at the corresponding element.voidthrowBpmnError(String errorCode, String errorMessage) Throws an BPMN error using the given error code and message as well as the specified variables.Verifies the job's waiting state.verifyRetries(Integer expectedRetries) Verifies that the job has a specific number of retries.verifyRetries(Consumer<Integer> retriesConsumer) Verifies that the job has a specific number of retries, using a consumer.verifyRetriesExpression(Consumer<String> retriesExpressionConsumer) Verifies that the job has a specific "retries" FEEL expression (see "Task definition" section), using a consumer function.verifyType(String expectedType) Verifies that the job is of the given type.verifyType(Consumer<String> typeConsumer) Verifies that the job is of the given type, using a consumer.verifyTypeExpression(Consumer<String> typeExpressionConsumer) Verifies that the job has a specific type FEEL expression (see "Task definition" section), using a consumer function.voidApplies no action at the wait state.withVariable(String name, Object value) Sets a variable that is used to complete the job.withVariableMap(Map<String, Object> variableMap) Sets variables that are used to complete the job.withVariables(Object variables) Sets an object as variables that is used to complete the job.
-
Constructor Details
-
JobHandler
-
JobHandler
-
-
Method Details
-
complete
public void complete()Executes an action that completes the job, when the process instance is waiting at the corresponding element, using specified variables.- See Also:
-
customize
Customizes the handler, using the givenConsumerfunction. This method can be used to apply a common customization needed for different test cases.tc.handleJob().customize(this::prepare);
- Parameters:
customizer- A function that accepts aJobHandler.- Returns:
- The handler.
-
execute
Executes a custom action that handles the job, when the process instance is waiting at the corresponding element.- Parameters:
action- A specific action that accepts aZeebeClientand the related job key.- See Also:
-
throwBpmnError
Throws an BPMN error using the given error code and message as well as the specified variables.This action can be used, if there is no related registered job worker yet.
- See Also:
-
verify
public JobHandler verify(Consumer<io.camunda.zeebe.process.test.assertions.ProcessInstanceAssert> verifier) Verifies the job's waiting state.Please note: An application specific job worker may have already completed the related job and updated some variables.
- Parameters:
verifier- Verifier that accepts anProcessInstanceAssertinstance.- Returns:
- The handler.
-
verifyRetries
Verifies that the job has a specific number of retries.- Parameters:
expectedRetries- The expected retry count.- Returns:
- The handler.
-
verifyRetries
Verifies that the job has a specific number of retries, using a consumer.- Parameters:
retriesConsumer- A consumer asserting the retry count.- Returns:
- The handler.
-
verifyRetriesExpression
Verifies that the job has a specific "retries" FEEL expression (see "Task definition" section), using a consumer function.- Parameters:
retriesExpressionConsumer- A consumer asserting the "retries" expression.- Returns:
- The handler.
-
verifyType
Verifies that the job is of the given type.- Parameters:
expectedType- The expected type.- Returns:
- The handler.
-
verifyType
Verifies that the job is of the given type, using a consumer.- Parameters:
typeConsumer- A consumer asserting the type.- Returns:
- The handler.
-
verifyTypeExpression
Verifies that the job has a specific type FEEL expression (see "Task definition" section), using a consumer function.- Parameters:
typeExpressionConsumer- A consumer asserting the type expression.- Returns:
- The handler.
-
waitForBoundaryEvent
public void waitForBoundaryEvent()Applies no action at the wait state. This is required when waiting for events (e.g. message, signal or timer events) that are attached as boundary events on the element itself or on the surrounding scope (e.g. embedded subprocess). -
withVariable
Sets a variable that is used to complete the job.- Parameters:
name- The name of the variable.value- The variable's value.- Returns:
- The handler.
- See Also:
-
withVariables
Sets an object as variables that is used to complete the job.- Parameters:
variables- The variables as POJO.- Returns:
- The handler.
- See Also:
-
withVariableMap
Sets variables that are used to complete the job.- Parameters:
variableMap- A map of variables.- Returns:
- The handler.
- See Also:
-