Package org.camunda.community.bpmndt.api
Class MultiInstanceScopeHandler<T extends MultiInstanceScopeHandler<?>>
java.lang.Object
org.camunda.community.bpmndt.api.MultiInstanceScopeHandler<T>
- Type Parameters:
T- The generated multi instance scope handler type.
Fluent API for multi instance scopes (sub processes or transactions).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapply(org.camunda.bpm.engine.runtime.ProcessInstance pi) protected booleanapply(org.camunda.bpm.engine.runtime.ProcessInstance pi, int loopIndex) Applies the multi instance loop for the given index.customize(Consumer<MultiInstanceScopeHandler<T>> customizer) Customizes the handler, using the givenConsumerfunction.execute(int loopIndex, BiFunction<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert, Integer, Boolean> action) Executes a custom action, which handles the activities within the scope, for a given loop index.protected org.camunda.bpm.engine.ProcessEngineprotected voidhandleAsyncBefore(org.camunda.bpm.engine.runtime.ProcessInstance pi, int loopIndex) protected booleanisEnded(org.camunda.bpm.engine.runtime.ProcessInstance pi) Checks if the multi instance scope is ended or not.protected booleanDetermines if the multi instance loop is sequentially executed or not.protected voidregisterCallActivityHandler(String activityId, CallActivityHandler handler) Registers the given call activity handler at the test case instance, so that it will be executed when the custom call activity behavior is applied.
Since there can be multiple handlers (one for each loop index), it is necessary to register the correct one before the next multi instance loop is executed.verify(int loopIndex, BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert, Integer> verifier) Verifies the state before the multi instance loop with the given index is executed.verifyLoopCount(int loopCount) Verifies that the multi instance loop is executed n-times.Verifies that the multi instance loop execution is done in parallel.Verifies that the multi instance loop is sequentially executed.
-
Field Details
-
instance
-
-
Constructor Details
-
MultiInstanceScopeHandler
-
-
Method Details
-
apply
protected void apply(org.camunda.bpm.engine.runtime.ProcessInstance pi) -
apply
protected boolean apply(org.camunda.bpm.engine.runtime.ProcessInstance pi, int loopIndex) Applies the multi instance loop for the given index. Please note: This method will be overridden by generated multi instance scope handler classes.- Parameters:
pi- The process instance, used to execute the test case.loopIndex- The current loop index.- Returns:
true, if the multi instance execution should be continued. Otherwisefalse.
-
customize
Customizes the handler, using the givenConsumerfunction. This method can be used to apply a common customization needed for different test cases.tc.handleMultiInstanceScope().customize(this::prepareMultiInstanceScope);
- Parameters:
customizer- A function that accepts a suitableMultiInstanceScopeHandler.- Returns:
- The handler.
-
execute
public T execute(int loopIndex, BiFunction<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert, Integer, Boolean> action) Executes a custom action, which handles the activities within the scope, for a given loop index.- Parameters:
loopIndex- A specific loop index (>= 0).action- A specific action that accepts the related process instance asProcessInstanceAssertand the loop index. It returns a boolean value that indicates if the multi instance loop should be continued or not (e.g. in case of a boundary event that will be triggered afterward).
-
getProcessEngine
protected org.camunda.bpm.engine.ProcessEngine getProcessEngine() -
handleAsyncBefore
protected void handleAsyncBefore(org.camunda.bpm.engine.runtime.ProcessInstance pi, int loopIndex) -
isEnded
protected boolean isEnded(org.camunda.bpm.engine.runtime.ProcessInstance pi) Checks if the multi instance scope is ended or not.- Parameters:
pi- The related process instance.- Returns:
true, if the multi instance scope is ended. Otherwisefalse.
-
isSequential
protected boolean isSequential()Determines if the multi instance loop is sequentially executed or not. Please note: If the multi instance loop is defined as parallel, this method will be overridden by generated multi instance handler classes.- Returns:
true, if execution is done sequentially.false, if execution is done in parallel.
-
registerCallActivityHandler
Registers the given call activity handler at the test case instance, so that it will be executed when the custom call activity behavior is applied.
Since there can be multiple handlers (one for each loop index), it is necessary to register the correct one before the next multi instance loop is executed.- Parameters:
activityId- The ID of the call activity.handler- The call activity handler to be executed next.
-
verify
public T verify(int loopIndex, BiConsumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert, Integer> verifier) Verifies the state before the multi instance loop with the given index is executed.- Parameters:
loopIndex- A specific loop index (>= 0).verifier- Verifier that accepts anProcessInstanceAssertand the loop index.- Returns:
- The handler.
-
verifyLoopCount
Verifies that the multi instance loop is executed n-times.- Parameters:
loopCount- The expected loop count at the point of time when the multi instance scope is left (finished or terminated by a boundary event).- Returns:
- The handler.
-
verifyParallel
Verifies that the multi instance loop execution is done in parallel.- Returns:
- The handler.
-
verifySequential
Verifies that the multi instance loop is sequentially executed.- Returns:
- The handler.
-