Class EventHandler

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

public class EventHandler extends Object
Fluent API to handle conditional, message and signal intermediate catch or boundary events.
Please note: Since conditional events rely on an expression to evaluate true, their wait state cannot be handled automatically - set variables or use execute(Consumer) with a custom action, if the variable event is delete.
  • Constructor Summary

    Constructors
    Constructor
    Description
    EventHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId, String eventName)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    apply(org.camunda.bpm.engine.runtime.ProcessInstance pi)
     
    Customizes the handler, using the given Consumer function.
    void
    Continues the waiting execution with an action that calls messageEventReceived, signalEventReceived or setVariables (depending on the actual event type).
    protected void
    eventReceived(org.camunda.bpm.engine.runtime.EventSubscription eventSubscription)
     
    void
    execute(Consumer<org.camunda.bpm.engine.runtime.EventSubscription> action)
    Executes a custom action that handles the intermediate catch event, when the process instance is waiting at the corresponding activity.
    verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert,org.camunda.bpm.engine.runtime.EventSubscription> verifier)
    Verifies the events's waiting state.
    withVariable(String name, Object value)
    Sets a variable, which is passed to the execution when the default behavior is used.
    Sets variables, which are passed to the execution when the default behavior is used.
    withVariableTyped(String name, org.camunda.bpm.engine.variable.value.TypedValue value)
    Sets a typed variable, which is passed to the execution when the default behavior is used.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EventHandler

      public EventHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId, String eventName)
  • Method Details

    • apply

      protected void apply(org.camunda.bpm.engine.runtime.ProcessInstance pi)
    • customize

      public EventHandler customize(Consumer<EventHandler> 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.handleEvent().customize(this::prepareEvent);
       
      Parameters:
      customizer - A function that accepts a EventHandler.
      Returns:
      The handler.
    • execute

      public void execute(Consumer<org.camunda.bpm.engine.runtime.EventSubscription> action)
      Executes a custom action that handles the intermediate catch event, when the process instance is waiting at the corresponding activity.
      Parameters:
      action - A specific action that accepts an EventSubscription.
      Throws:
      IllegalArgumentException - if action is null.
    • eventReceived

      public void eventReceived()
      Continues the waiting execution with an action that calls messageEventReceived, signalEventReceived or setVariables (depending on the actual event type). Please note: this is the default behavior.
      See Also:
      • RuntimeService.messageEventReceived(String, String, java.util.Map)
      • RuntimeService.signalEventReceived(String, String, java.util.Map)
      • RuntimeService.setVariables(String, java.util.Map)
    • eventReceived

      protected void eventReceived(org.camunda.bpm.engine.runtime.EventSubscription eventSubscription)
    • verify

      public EventHandler verify(BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert,org.camunda.bpm.engine.runtime.EventSubscription> verifier)
      Verifies the events's waiting state.
      Parameters:
      verifier - Verifier that accepts an ProcessInstanceAssert instance and an EventSubscription.
      Returns:
      The handler.
    • withVariable

      public EventHandler withVariable(String name, Object value)
      Sets a variable, which is passed to the execution when the default behavior is used.
      Parameters:
      name - The name of the variable.
      value - The variable's value.
      Returns:
      The handler.
    • withVariables

      public EventHandler withVariables(Map<String,Object> variables)
      Sets variables, which are passed to the execution when the default behavior is used.
      Parameters:
      variables - A map of variables to set.
      Returns:
      The handler.
    • withVariableTyped

      public EventHandler withVariableTyped(String name, org.camunda.bpm.engine.variable.value.TypedValue value)
      Sets a typed variable, which is passed to the execution when the default behavior is used.
      Parameters:
      name - The name of the variable.
      value - The variable's typed value.
      Returns:
      The handler.