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(TestCaseInstance instance, Consumer<org.camunda.bpm.engine.runtime.ProcessInstance> executor)
  • 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 org.camunda.bpm.engine.runtime.ProcessInstance execute()
      Create a new ProcessInstance, executes the actual test case and verifies the state after.
      Returns:
      The newly created process instance.
    • execute

      public void execute(org.camunda.bpm.engine.runtime.ProcessInstance pi)
      Executes the actual test case and verifies the state after, using the given ProcessInstance.
      Parameters:
      pi - A process instance, used to execute the test case.
    • execute

      public org.camunda.bpm.engine.runtime.ProcessInstance execute(String processInstanceId)
      Executes the actual test case and verifies the state after, using the ProcessInstance, identified by the given ID.
      Parameters:
      processInstanceId - The ID of an existing process instance.
      Returns:
      The identified process instance.
    • migrate

      protected void migrate(org.camunda.bpm.engine.runtime.ProcessInstance pi)
    • unwrapAssertionError

      protected org.camunda.bpm.engine.ProcessEngineException unwrapAssertionError(org.camunda.bpm.engine.ProcessEngineException e)
      Unwraps and throws a possible AssertionError in case of a failed assertion within a CallActivityHandler's verifier. If not unwrapped, a test will be marked as an error, instead of a failure!
      Parameters:
      e - An exception that has been catched during process instance execution.
      Returns:
      The original exception, if the cause of the given exception is null or not an assertion error.
    • verify

      public TestCaseExecutor verify(Consumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert> verifier)
      Verifies that state after the test case execution has finished.
      Parameters:
      verifier - Verifier that accepts an ProcessInstanceAssert instance.
      Returns:
      The executor.
    • withBean

      public TestCaseExecutor withBean(String key, Object value)
      Registers a bean for the given key.
      Please note: If Spring is enabled, the beans will be provided via Spring's application context (e.g. by providing a specific test configuration).
      Parameters:
      key - The key, under which the bean is registered.
      value - The value.
      Returns:
      The executor.
      See Also:
      • Mocks.register(String, Object)
    • withBusinessKey

      public TestCaseExecutor withBusinessKey(String businessKey)
      Sets the business key of the process instance that will be created.
      Parameters:
      businessKey - A specific business key.
      Returns:
      The executor.
    • withVariable

      public TestCaseExecutor withVariable(String name, Object value)
      Sets a variable on the process instance that will be created.
      Parameters:
      name - The name of the variable.
      value - The variable's value.
      Returns:
      The executor.
    • withVariables

      public TestCaseExecutor withVariables(Map<String,Object> variables)
      Sets variables on the process instance that will be created.
      Parameters:
      variables - A map of variables to set.
      Returns:
      The executor.
    • withVariableTyped

      public TestCaseExecutor withVariableTyped(String name, org.camunda.bpm.engine.variable.value.TypedValue value)
      Sets a typed variable on the process instance that will be started.
      Parameters:
      name - The name of the variable.
      value - The variable's typed value.
      Returns:
      The executor.