Class CallActivityHandler

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

public class CallActivityHandler extends Object
Fluent API to handle call activities.
  • Constructor Details

  • Method Details

    • customize

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

      protected boolean execute(org.camunda.bpm.engine.runtime.ProcessInstance pi, org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution execution, org.camunda.bpm.engine.impl.bpmn.behavior.CallActivityBehavior behavior) throws Exception
      Simulates the execution of a call activity.
      1. Gets the call activity definition and verifies it.
      2. Performs and verifies the variable mapping between super execution and stubbed sub instance.
      3. Create sub execution and propagate possible error or escalation events.
      Parameters:
      pi - The current process instance.
      execution - The current execution.
      behavior - The call activity's original behavior.
      Returns:
      true, if the execution should leave (continue). false, if the execution should wait.
      Throws:
      Exception - Exception If the occurrence of an error end event is simulated and the error propagation fails.
    • isWaitingForBoundaryEvent

      public boolean isWaitingForBoundaryEvent()
      Determines if the call activity is waiting for a boundary message, signal or timer event.
      Returns:
      true, if it is waiting for a boundary event. false, if not.
    • simulateBpmnError

      public void simulateBpmnError(String errorCode, String errorMessage)
      Simulates the occurrence of an error end event within the called sub instance.
      Parameters:
      errorCode - The error code of the attached boundary error event.
      errorMessage - An error message or null.
    • simulateEscalation

      public void simulateEscalation(String escalationCode)
      Simulates the occurrence of an escalation end event within the called sub instance.
      Parameters:
      escalationCode - The escalation code of the attached boundary escalation event.
    • verify

      public CallActivityHandler verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert,CallActivityDefinition> verifier)
      Verifies the definition of the call activity and the state before it is executed (actually before the mapInputVariables method of a possible DelegateVariableMapping is invoked).
      Parameters:
      verifier - Verifier that accepts an ProcessInstanceAssert and an CallActivityDefinition instance.
      Returns:
      The handler.
    • verify

      protected void verify(org.camunda.bpm.engine.runtime.ProcessInstance pi, CallActivityDefinition callActivityDefinition)
    • verifyInput

      public CallActivityHandler verifyInput(Consumer<org.camunda.bpm.engine.delegate.VariableScope> inputVerifier)
      Verifies the state after the mapInputVariables method of a possible DelegateVariableMapping was invoked.
      Please note: This method can also be used to simulate the behavior of a called process. The variables set, will be available when the mapOutputVariables method of a possible DelegateVariableMapping is invoked.
      Parameters:
      inputVerifier - Verifier that accepts the VariableScope of the sub process instance.
      Returns:
      The handler.
    • verifyInput

      protected void verifyInput(org.camunda.bpm.engine.delegate.VariableScope variables)
    • verifyOutput

      public CallActivityHandler verifyOutput(Consumer<org.camunda.bpm.engine.delegate.VariableScope> outputVerifier)
      Verifies the state after the mapOutputVariables method of a possible DelegateVariableMapping was invoked.
      Parameters:
      outputVerifier - Verifier that accepts the VariableScope of the super execution.
      Returns:
      The handler.
    • verifyOutput

      protected void verifyOutput(org.camunda.bpm.engine.delegate.VariableScope variables)
    • waitForBoundaryEvent

      public void waitForBoundaryEvent()
      Lets the call activity become a wait state. This is required to wait for events (e.g. message, signal or timer events) that are attached as boundary events on the activity itself or on the surrounding scope (e.g. embedded subprocess).
    • withErrorMessage

      public CallActivityHandler withErrorMessage(String errorMessage)
      Sets the error message, which is used when the next activity is an error boundary event.
      Parameters:
      errorMessage - An error message or null.
      Returns:
      The handler.