Package org.camunda.community.bpmndt.api
Class TestCaseExecutor
java.lang.Object
org.camunda.community.bpmndt.api.TestCaseExecutor
Fluent API to prepare and start the actual test case execution.
-
Constructor Summary
ConstructorsConstructorDescriptionTestCaseExecutor(AbstractTestCase testCase, io.camunda.zeebe.process.test.api.ZeebeTestEngine engine, String simulateSubProcessResource) -
Method Summary
Modifier and TypeMethodDescriptioncustomize(Consumer<TestCaseExecutor> customizer) Customizes the executor, using the givenConsumerfunction.longexecute()Create a new process instance, executes the actual test case and verifies the state after.voidexecute(long processInstanceKey) Executes the actual test case and verifies the state after, using the process instance, identified by the given key.voidexecute(io.camunda.zeebe.client.api.response.ProcessInstanceEvent processInstanceEvent) Executes the actual test case and verifies the state after, using the given event.longExecutes the actual test case and verifies the state after, using a runnable that starts a new process instance.simulateProcess(String processId) Simulates the process with the given ID by adding a stub process to the resource deployment.simulateVersionedProcess(String processId, String versionTag) Simulates the process with the given ID by adding a stub process to a separate versioned resource deployment.Verifies the state after the test case execution has finished.withAdditionalClasspathResource(String classpathResourceName) Adds a classpath resource to the resource deployment (ZeebeClient.newDeployResourceCommand()).withAdditionalResource(String resourceName, String resource) Adds a resource to the resource deployment (ZeebeClient.newDeployResourceCommand()).withAdditionalVersionedClasspathResource(String classpathResourceName, String versionTag) Adds a classpath resource to a separate versioned resource deployment (ZeebeClient.newDeployResourceCommand()).withAdditionalVersionedResource(String resourceName, String resource, String versionTag) Adds a resource to a separate versioned resource deployment (ZeebeClient.newDeployResourceCommand()).withObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Sets the object mapper that is used by theZeebeClient.withPrintRecordStreamEnabled(boolean printRecordStreamEnabled) Enables record streaming printing to stdout.withTaskTimeout(long taskTimeout) Deprecated.withTenantId(String tenantId) Sets the tenant ID to be used for the automatic process deployment.withVariable(String name, Object value) Sets a variable that is used for the process instance creation.withVariableMap(Map<String, Object> variableMap) Sets variables that are used for the process instance creation.withVariables(Object variables) Sets an object as variables that is used for the process instance creation.withWaitTimeout(long waitTimeout) Specifies a timeout in milliseconds for tasks that audit the test engine's record stream (e.g.
-
Constructor Details
-
TestCaseExecutor
public TestCaseExecutor(AbstractTestCase testCase, io.camunda.zeebe.process.test.api.ZeebeTestEngine engine, String simulateSubProcessResource)
-
-
Method Details
-
customize
Customizes the executor, using the givenConsumerfunction. This method can be used to apply a common customization needed for different test cases.tc.createExecutor().customize(this::prepareVariables).execute();
- Parameters:
customizer- A function that accepts aTestCaseExecutor.- Returns:
- The executor.
-
execute
public long execute()Create a new process instance, executes the actual test case and verifies the state after.- Returns:
- The key of the newly created process instance.
-
execute
Executes the actual test case and verifies the state after, using a runnable that starts a new process instance.
This method is suitable for testing process starts with custom code, but not self-managing a process deployment.- Parameters:
startProcessInstance- A runnable that starts a process instance.- Returns:
- The key of the started process instance.
-
execute
public void execute(io.camunda.zeebe.client.api.response.ProcessInstanceEvent processInstanceEvent) Executes the actual test case and verifies the state after, using the given event.- Parameters:
processInstanceEvent- The event related to an existing process instance, used to execute the test case.
-
execute
public void execute(long processInstanceKey) Executes the actual test case and verifies the state after, using the process instance, identified by the given key.- Parameters:
processInstanceKey- The key of an existing process instance.
-
simulateProcess
Simulates the process with the given ID by adding a stub process to the resource deployment.- Parameters:
processId- The ID of the process to simulate.- Returns:
- The executor.
- See Also:
-
simulateVersionedProcess
Simulates the process with the given ID by adding a stub process to a separate versioned resource deployment.- Parameters:
processId- The ID of the process to simulate.versionTag- A version tag, corresponding to a call activity's version tag.- Returns:
- The executor.
- See Also:
-
verify
public TestCaseExecutor verify(Consumer<io.camunda.zeebe.process.test.assertions.ProcessInstanceAssert> verifier) Verifies the state after the test case execution has finished.- Parameters:
verifier- Verifier that accepts anProcessInstanceAssertinstance.- Returns:
- The executor.
-
withAdditionalClasspathResource
Adds a classpath resource to the resource deployment (ZeebeClient.newDeployResourceCommand()).- Parameters:
classpathResourceName- Name of the classpath resource - e.g. "bpmn/my-process.bpmn", if the resource is under src/main/resources/bpmn/my-process.bpmn.- Returns:
- The executor.
- See Also:
-
withAdditionalResource
Adds a resource to the resource deployment (ZeebeClient.newDeployResourceCommand()).- Parameters:
resourceName- Name of the resource.resource- The resource as UTF-8 string.- Returns:
- The executor.
- See Also:
-
withAdditionalVersionedClasspathResource
public TestCaseExecutor withAdditionalVersionedClasspathResource(String classpathResourceName, String versionTag) Adds a classpath resource to a separate versioned resource deployment (ZeebeClient.newDeployResourceCommand()). Versioned resources are needed to test business rule tasks with a DMN decision or user tasks with a form that have the binding type "version tag".- Parameters:
classpathResourceName- Name of the classpath resource - e.g. "bpmn/my-process.bpmn", if the resource is under src/main/resources/bpmn/my-process.bpmn.versionTag- A specific version tag.- Returns:
- The executor.
- See Also:
-
withAdditionalVersionedResource
public TestCaseExecutor withAdditionalVersionedResource(String resourceName, String resource, String versionTag) Adds a resource to a separate versioned resource deployment (ZeebeClient.newDeployResourceCommand()). Versioned resources are needed to test business rule tasks with a DMN decision or user tasks with a form that have the binding type "version tag".- Parameters:
resourceName- Name of the resource.resource- The resource as UTF-8 string.versionTag- A specific version tag.- Returns:
- The executor.
- See Also:
-
withObjectMapper
Sets the object mapper that is used by theZeebeClient.- Parameters:
objectMapper- A specific object mapper.- Returns:
- The executor.
-
withPrintRecordStreamEnabled
Enables record streaming printing to stdout. This is useful for debugging or reporting bugs.- Parameters:
printRecordStreamEnabled- Enable or disable the printing of records.- Returns:
- The executor.
-
withTaskTimeout
Deprecated.usewithWaitTimeout(long)instead.Specifies a timeout in milliseconds for tasks that audit the test engine's record stream - e.g. tasks that check process instance is waiting at or has passed a certain BPMN element.- Parameters:
taskTimeout- The audit task timeout in milliseconds - the default value is5000- Returns:
- The executor.
-
withTenantId
Sets the tenant ID to be used for the automatic process deployment.- Parameters:
tenantId- A specific tenant ID.- Returns:
- The executor.
-
withVariable
Sets a variable that is used for the process instance creation.- Parameters:
name- The name of the variable.value- The variable's value.- Returns:
- The executor.
-
withVariables
Sets an object as variables that is used for the process instance creation.- Parameters:
variables- The variables as POJO.- Returns:
- The executor.
-
withVariableMap
Sets variables that are used for the process instance creation.- Parameters:
variableMap- A map of variables.- Returns:
- The executor.
-
withWaitTimeout
Specifies a timeout in milliseconds for tasks that audit the test engine's record stream (e.g. tasks that check process instance is waiting at or has passed a certain BPMN element) and for waiting that the engine's becomes idle.- Parameters:
waitTimeout- The wait timeout in milliseconds - the default value is5000- Returns:
- The executor.
-
withWaitTimeout(long)instead.