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.simulateProcess(String processId) Simulates the process with the given ID by adding a stub process to the resource deployment.Verifies the state after the test case execution has finished.withAdditionalResource(String resourceName, String resource) Adds a resource to the 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
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.
-
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.
-
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.
-
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.