Package org.camunda.community.bpmndt.api
Class CallActivityHandler
java.lang.Object
org.camunda.community.bpmndt.api.CallActivityHandler
Fluent API to handle call activities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncustomize(Consumer<CallActivityHandler> customizer) Customizes the handler, using the givenConsumerfunction.protected booleanexecute(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) Simulates the execution of a call activity.booleanDetermines if the call activity is waiting for a boundary message, signal or timer event.voidsimulateBpmnError(String errorCode, String errorMessage) Simulates the occurrence of an error end event within the called sub instance.voidsimulateEscalation(String escalationCode) Simulates the occurrence of an escalation end event within the called sub instance.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 themapInputVariablesmethod of a possibleDelegateVariableMappingis invoked).protected voidverify(org.camunda.bpm.engine.runtime.ProcessInstance pi, CallActivityDefinition callActivityDefinition) verifyInput(Consumer<org.camunda.bpm.engine.delegate.VariableScope> inputVerifier) Verifies the state after themapInputVariablesmethod of a possibleDelegateVariableMappingwas invoked.
Please note: This method can also be used to simulate the behavior of a called process.protected voidverifyInput(org.camunda.bpm.engine.delegate.VariableScope variables) verifyOutput(Consumer<org.camunda.bpm.engine.delegate.VariableScope> outputVerifier) Verifies the state after themapOutputVariablesmethod of a possibleDelegateVariableMappingwas invoked.protected voidverifyOutput(org.camunda.bpm.engine.delegate.VariableScope variables) voidLets the call activity become a wait state.withErrorMessage(String errorMessage) Sets the error message, which is used when the next activity is an error boundary event.
-
Constructor Details
-
CallActivityHandler
-
-
Method Details
-
customize
Customizes the handler, using the givenConsumerfunction. 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 aCallActivityHandler.- 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
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 ornull.
-
simulateEscalation
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 themapInputVariablesmethod of a possibleDelegateVariableMappingis invoked).- Parameters:
verifier- Verifier that accepts anProcessInstanceAssertand anCallActivityDefinitioninstance.- 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 themapInputVariablesmethod of a possibleDelegateVariableMappingwas invoked.
Please note: This method can also be used to simulate the behavior of a called process. The variables set, will be available when themapOutputVariablesmethod of a possibleDelegateVariableMappingis invoked.- Parameters:
inputVerifier- Verifier that accepts theVariableScopeof 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 themapOutputVariablesmethod of a possibleDelegateVariableMappingwas invoked.- Parameters:
outputVerifier- Verifier that accepts theVariableScopeof 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
Sets the error message, which is used when the next activity is an error boundary event.- Parameters:
errorMessage- An error message ornull.- Returns:
- The handler.
-