Package org.camunda.community.bpmndt.api
Class MultiInstanceHandler<T extends MultiInstanceHandler<?,?>,U>
java.lang.Object
org.camunda.community.bpmndt.api.MultiInstanceHandler<T,U>
- Type Parameters:
T- The generated multi instance handler type.U- The activity handler type (e.g.UserTaskHandler).
Fluent API for multi instance activites (call activities or tasks). This class does not support
multi instances scopes like 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.protected UcreateHandler(int loopIndex) Creates a new activity handler.protected JobHandlercreateHandlerAfter(int loopIndex) Creates a new job handler for the asynchronous continuation after the activity.protected JobHandlercreateHandlerBefore(int loopIndex) Creates a new job handler for the asynchronous continuation before the activity.customize(Consumer<MultiInstanceHandler<T, U>> customizer) Customizes the handler, using the givenConsumerfunction.protected UgetHandler(int loopIndex) protected JobHandlergetHandlerAfter(int loopIndex) protected JobHandlergetHandlerBefore(int loopIndex) protected org.camunda.bpm.engine.ProcessEnginehandle()Returns the default activity handler, which is used when for a multi instance loop with a specific index no handler is defined.handle(int loopIndex) Returns the activity handler, which is applied on the multi instance loop with the given index.Returns the default job handler for the asynchronous continuation after the activity, which is used when for a multi instance loop with a specific index no handler is defined.handleAfter(int loopIndex) Returns the job handler for the asynchronous continuation after the activity, which is applied on the multi instance loop with the given index.Returns the default job handler for the asynchronous continuation before the activity, which is used when for a multi instance loop with a specific index no handler is defined.handleBefore(int loopIndex) Returns the job handler for the asynchronous continuation before the activity, which is applied on the multi instance loop with the given index.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 voidRegisters 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.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
-
MultiInstanceHandler
-
-
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 overriden by generated multi instance handler classes in case of call activities, external tasks and user tasks.- 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.
-
createHandler
Creates a new activity handler. Please note: This method will be overridden by generated multi instance handler classes.- Parameters:
loopIndex- The current loop index.- Returns:
- The newly created handler.
-
createHandlerAfter
Creates a new job handler for the asynchronous continuation after the activity.- Parameters:
loopIndex- The current loop index.- Returns:
- The newly created job handler.
-
createHandlerBefore
Creates a new job handler for the asynchronous continuation before the activity.- Parameters:
loopIndex- The current loop index.- Returns:
- The newly created job handler.
-
customize
Customizes the handler, using the givenConsumerfunction. This method can be used to apply a common customization needed for different test cases.tc.handleMultiInstance().customize(this::prepareMultiInstance);
- Parameters:
customizer- A function that accepts a suitableMultiInstanceHandler.- Returns:
- The handler.
-
getHandler
-
getHandlerAfter
-
getHandlerBefore
-
getProcessEngine
protected org.camunda.bpm.engine.ProcessEngine getProcessEngine() -
handle
Returns the default activity handler, which is used when for a multi instance loop with a specific index no handler is defined.- Returns:
- The default handler.
-
handle
Returns the activity handler, which is applied on the multi instance loop with the given index.- Parameters:
loopIndex- A specific loop index.- Returns:
- The handler for the given loop index.
-
handleAfter
Returns the default job handler for the asynchronous continuation after the activity, which is used when for a multi instance loop with a specific index no handler is defined.- Returns:
- The default async after job handler.
-
handleAfter
Returns the job handler for the asynchronous continuation after the activity, which is applied on the multi instance loop with the given index. This handler can be used to verify the process variables after the activity was executed the nth time.- Parameters:
loopIndex- A specific loop index.- Returns:
- The async after job handler for the given loop index.
-
handleBefore
Returns the default job handler for the asynchronous continuation before the activity, which is used when for a multi instance loop with a specific index no handler is defined.- Returns:
- The default async before job handler.
-
handleBefore
Returns the job handler for the asynchronous continuation before the activity, which is applied on the multi instance loop with the given index. This handler can be used to verify the process variables before the activity is executed the nth time.- Parameters:
loopIndex- A specific loop index.- Returns:
- The async before job handler for the given loop index.
-
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:
handler- The handler to be executed next.
-
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 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.
-