Package org.camunda.community.bpmndt.api
Class EventHandler
java.lang.Object
org.camunda.community.bpmndt.api.EventHandler
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
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
ConstructorsConstructorDescriptionEventHandler(org.camunda.bpm.engine.ProcessEngine processEngine, String activityId, String eventName) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapply(org.camunda.bpm.engine.runtime.ProcessInstance pi) customize(Consumer<EventHandler> customizer) Customizes the handler, using the givenConsumerfunction.voidContinues the waiting execution with an action that callsmessageEventReceived,signalEventReceivedorsetVariables(depending on the actual event type).protected voideventReceived(org.camunda.bpm.engine.runtime.EventSubscription eventSubscription) voidExecutes 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' waiting state.withVariable(String name, Object value) Sets a variable, which is passed to the execution when the default behavior is used.withVariables(Map<String, Object> variables) 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.
-
Constructor Details
-
EventHandler
-
-
Method Details
-
apply
protected void apply(org.camunda.bpm.engine.runtime.ProcessInstance pi) -
customize
Customizes the handler, using the givenConsumerfunction. 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 aEventHandler.- Returns:
- The handler.
-
execute
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 anEventSubscription.- Throws:
IllegalArgumentException- if action isnull.
-
eventReceived
public void eventReceived()Continues the waiting execution with an action that callsmessageEventReceived,signalEventReceivedorsetVariables(depending on the actual event type). Please note: this is the default behavior.- See Also:
-
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' waiting state.- Parameters:
verifier- Verifier that accepts anProcessInstanceAssertinstance and anEventSubscription.- Returns:
- The handler.
-
withVariable
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
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.
-