Class TestCaseExecutor

java.lang.Object
org.camunda.community.bpmndt.api.TestCaseExecutor

public class TestCaseExecutor extends Object
Fluent API to prepare and start the actual test case execution.
  • Constructor Details

    • TestCaseExecutor

      public TestCaseExecutor(AbstractTestCase testCase, io.camunda.zeebe.process.test.api.ZeebeTestEngine engine, String simulateSubProcessResource)
  • Method Details

    • customize

      public TestCaseExecutor customize(Consumer<TestCaseExecutor> customizer)
      Customizes the executor, using the given Consumer function. 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 a TestCaseExecutor.
      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

      public TestCaseExecutor simulateProcess(String processId)
      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

      public TestCaseExecutor simulateVersionedProcess(String processId, String versionTag)
      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 an ProcessInstanceAssert instance.
      Returns:
      The executor.
    • withAdditionalClasspathResource

      public TestCaseExecutor withAdditionalClasspathResource(String classpathResourceName)
      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

      public TestCaseExecutor withAdditionalResource(String resourceName, String resource)
      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

      public TestCaseExecutor withObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Sets the object mapper that is used by the ZeebeClient.
      Parameters:
      objectMapper - A specific object mapper.
      Returns:
      The executor.
    • withPrintRecordStreamEnabled

      public TestCaseExecutor withPrintRecordStreamEnabled(boolean printRecordStreamEnabled)
      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 public TestCaseExecutor withTaskTimeout(long taskTimeout)
      Deprecated.
      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 is 5000
      Returns:
      The executor.
    • withTenantId

      public TestCaseExecutor withTenantId(String tenantId)
      Sets the tenant ID to be used for the automatic process deployment.
      Parameters:
      tenantId - A specific tenant ID.
      Returns:
      The executor.
    • withVariable

      public TestCaseExecutor withVariable(String name, Object value)
      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

      public TestCaseExecutor withVariables(Object variables)
      Sets an object as variables that is used for the process instance creation.
      Parameters:
      variables - The variables as POJO.
      Returns:
      The executor.
    • withVariableMap

      public TestCaseExecutor withVariableMap(Map<String,Object> variableMap)
      Sets variables that are used for the process instance creation.
      Parameters:
      variableMap - A map of variables.
      Returns:
      The executor.
    • withWaitTimeout

      public TestCaseExecutor withWaitTimeout(long waitTimeout)
      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 is 5000
      Returns:
      The executor.