Class CustomMultiInstanceHandler

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

public class CustomMultiInstanceHandler extends Object
Fluent API to handle multi instances and multi instance scopes, using custom code - see execute(BiConsumer).
  • Constructor Details

  • Method Details

    • customize

      Customizes the handler, using the given Consumer function. This method can be used to apply a common customization needed for different test cases.
       tc.handleMultiInstance().customize(this::prepare);
       
      Parameters:
      customizer - A function that accepts a CustomMultiInstanceHandler.
      Returns:
      The handler.
    • execute

      public void execute(BiConsumer<TestCaseInstance,Long> action)
      Executes a custom action that handles the multi instance or the multi instance scope.
      Parameters:
      action - A specific action that accepts a TestCaseInstance and the related process instance key.
    • executeLoop

      public void executeLoop(BiConsumer<TestCaseInstance,Long> loopAction)
      Executes a custom action that handles the multi instance loop. The given consumer is called once per loop.

      Please note: If the multi instance is NOT a scope (e.g. embedded sub process), the flow scope key, used to apply handler or to check if an element has been passed, must be obtained via TestCaseInstance.getFlowScopeKey(long).

         tc.handleUserTask().executeLoop((instance, elementInstanceKey) -> {
            var flowScopeKey = instance.getFlowScopeKey(elementInstanceKey);
      
            instance.apply(flowScopeKey, userTaskHandler);
            instance.hasPassed(flowScopeKey, "userTask");
         }
       
      Parameters:
      loopAction - A specific action that accepts a TestCaseInstance and the current element instance key.
    • verify

      public CustomMultiInstanceHandler verify(Consumer<io.camunda.zeebe.process.test.assertions.ProcessInstanceAssert> verifier)
      Verifies the multi instance state.

      Please note: An application specific job worker may have already completed the related job and updated some variables.

      Parameters:
      verifier - Verifier that accepts an ProcessInstanceAssert instance.
      Returns:
      The handler.
    • verifyLoopCount

      public CustomMultiInstanceHandler verifyLoopCount(int expectedLoopCount)
      Verifies that the multi instance loop is executed n-times.
      Parameters:
      expectedLoopCount - The expected loop count at the point of time when the multi instance is left (completed or terminated by a boundary event).
      Returns:
      The handler.
    • verifyParallel

      public CustomMultiInstanceHandler verifyParallel()
      Verifies that the multi instance loop execution is done in parallel.
      Returns:
      The handler.
    • verifySequential

      public CustomMultiInstanceHandler verifySequential()
      Verifies that the multi instance loop is sequentially executed.
      Returns:
      The handler.