Class DefaultStrategy
java.lang.Object
org.camunda.community.bpmndt.strategy.DefaultStrategy
- All Implemented Interfaces:
GeneratorStrategy
- Direct Known Subclasses:
DefaultHandlerStrategy,MultiInstanceStrategy
Default strategy, used for all unhandled activities (with type
TestCaseActivityType.OTHER).-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final TestCaseActivityprotected final Stringprotected booleanIndicates if the strategy is applied on a multi instance scope handler or not - seesetMultiInstanceParent(boolean)Fields inherited from interface org.camunda.community.bpmndt.GeneratorStrategy
CALL_ACTIVITY, EVENT, EXTERNAL_TASK, EXTERNAL_TASK_CLIENT, JOB, OTHER, RECEIVE_TASK, USER_TASK -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHandlerField(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds a handler field to the class, if the activity is handled by a handler - e.g.:voidaddHandlerFieldAfter(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds aJobHandlerfield to the class, if an asynchronous continuation is configured after the activity - e.g.:voidaddHandlerFieldBefore(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds aJobHandlerfield to the class, if an asynchronous continuation is configured before the activity - e.g.:voidaddHandlerMethod(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds a "handle" method to the class, if the activity is handled by a handler - e.g.:voidaddHandlerMethodAfter(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds a method to the class, which provides aJobHandler, if an asynchronous continuation is configured after the activity - e.g.:voidaddHandlerMethodBefore(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds a method to the class, which provides aJobHandler, if an asynchronous continuation is configured before the activity - e.g.:voidapplyHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code to the execute/apply method, if the activity is handled by a handler and a wait state - e.g.:voidapplyHandlerAfter(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code to the execute/apply method, if an asynchronous continuation is configured after the activity - e.g.:voidapplyHandlerBefore(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code to the execute/apply method, if an asynchronous continuation is configured before the activity - e.g.:protected StringbuildHandlerMethodName(String literal) booleanReturns the underlying activity.com.squareup.javapoet.CodeBlockReturns code for getting a handler field reference.com.squareup.javapoet.CodeBlockReturns code for getting an after handler field reference.com.squareup.javapoet.CodeBlockReturns code for getting a before handler field reference.com.squareup.javapoet.TypeNameReturns the type name of the related handler orVoid, if the activity is not handled by a specific handler.Gets the ID of the underlying activity as a literal.protected Stringprotected StringinthashCode()voidhasPassed(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which asserts that the process instance has passed an activity.voidinitHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which initializes a handler field.voidinitHandlerAfter(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which initializes an after handler field.com.squareup.javapoet.CodeBlockReturns the statement that initializes the after handler.voidinitHandlerBefore(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which initializes a before handler field.com.squareup.javapoet.CodeBlockReturns the statement that initializes the before handler.com.squareup.javapoet.CodeBlockReturns the statement that initializes the handler.voidisWaitingAt(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which asserts that the process instance is waiting at an activity.voidsetMultiInstanceParent(boolean multiInstanceParent) Set the multi instance parent indicator.booleanIf the activity has theasyncAfterflag set, it must be handled.booleanIf the activity has theasyncBeforeflag set, or it is a call activity but not a multi instance.
-
Field Details
-
activity
-
literal
-
multiInstanceParent
protected boolean multiInstanceParentIndicates if the strategy is applied on a multi instance scope handler or not - seesetMultiInstanceParent(boolean)
-
-
Constructor Details
-
DefaultStrategy
-
-
Method Details
-
addHandlerField
public void addHandlerField(com.squareup.javapoet.TypeSpec.Builder classBuilder) Description copied from interface:GeneratorStrategyAdds a handler field to the class, if the activity is handled by a handler - e.g.:private UserTaskHandler approveUserTask;
Otherwise, no field is added.
- Specified by:
addHandlerFieldin interfaceGeneratorStrategy- Parameters:
classBuilder- The class builder to use.
-
addHandlerFieldAfter
public void addHandlerFieldAfter(com.squareup.javapoet.TypeSpec.Builder classBuilder) Description copied from interface:GeneratorStrategyAdds aJobHandlerfield to the class, if an asynchronous continuation is configured after the activity - e.g.:private JobHandler sendMailServiceTaskAfter;
- Specified by:
addHandlerFieldAfterin interfaceGeneratorStrategy- Parameters:
classBuilder- The class builder to use.
-
addHandlerFieldBefore
public void addHandlerFieldBefore(com.squareup.javapoet.TypeSpec.Builder classBuilder) Description copied from interface:GeneratorStrategyAdds aJobHandlerfield to the class, if an asynchronous continuation is configured before the activity - e.g.:private JobHandler sendMailServiceTaskBefore;
- Specified by:
addHandlerFieldBeforein interfaceGeneratorStrategy- Parameters:
classBuilder- The class builder to use.
-
addHandlerMethod
public void addHandlerMethod(com.squareup.javapoet.TypeSpec.Builder classBuilder) Description copied from interface:GeneratorStrategyAdds a "handle" method to the class, if the activity is handled by a handler - e.g.:public UserTaskHandler handleApproveUserTask() { return approveUserTask; }Otherwise, no field is added.
- Specified by:
addHandlerMethodin interfaceGeneratorStrategy- Parameters:
classBuilder- The class builder to use.
-
addHandlerMethodAfter
public void addHandlerMethodAfter(com.squareup.javapoet.TypeSpec.Builder classBuilder) Description copied from interface:GeneratorStrategyAdds a method to the class, which provides aJobHandler, if an asynchronous continuation is configured after the activity - e.g.:public JobHandler handleSendMailServiceTaskAfter() { return sendMailServiceTaskAfter; }- Specified by:
addHandlerMethodAfterin interfaceGeneratorStrategy- Parameters:
classBuilder- The class builder to use.
-
addHandlerMethodBefore
public void addHandlerMethodBefore(com.squareup.javapoet.TypeSpec.Builder classBuilder) Description copied from interface:GeneratorStrategyAdds a method to the class, which provides aJobHandler, if an asynchronous continuation is configured before the activity - e.g.:public JobHandler handleSendMailServiceTaskBefore() { return sendMailServiceTaskBefore; }- Specified by:
addHandlerMethodBeforein interfaceGeneratorStrategy- Parameters:
classBuilder- The class builder to use.
-
applyHandler
public void applyHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Description copied from interface:GeneratorStrategyAdds code to the execute/apply method, if the activity is handled by a handler and a wait state - e.g.:assertThat(pi).isWaitingAt("placeOrderExternalTask"); instance.apply(placeOrderExternalTask)or the previous activity is an event based gateway.
- Specified by:
applyHandlerin interfaceGeneratorStrategy- Parameters:
methodBuilder- The method builder to use.
-
applyHandlerAfter
public void applyHandlerAfter(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Description copied from interface:GeneratorStrategyAdds code to the execute/apply method, if an asynchronous continuation is configured after the activity - e.g.:assertThat(pi).isWaitingAt("sendMailServiceTask"); instance.apply(sendMailServiceTaskAfter)- Specified by:
applyHandlerAfterin interfaceGeneratorStrategy- Parameters:
methodBuilder- The method builder to use.
-
applyHandlerBefore
public void applyHandlerBefore(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Description copied from interface:GeneratorStrategyAdds code to the execute/apply method, if an asynchronous continuation is configured before the activity - e.g.:assertThat(pi).isWaitingAt("sendMailServiceTask"); instance.apply(sendMailServiceTaskBefore)- Specified by:
applyHandlerBeforein interfaceGeneratorStrategy- Parameters:
methodBuilder- The method builder to use.
-
buildHandlerMethodName
-
equals
-
getActivity
Description copied from interface:GeneratorStrategyReturns the underlying activity.- Specified by:
getActivityin interfaceGeneratorStrategy- Returns:
- The test case activity.
-
getHandler
public com.squareup.javapoet.CodeBlock getHandler()Description copied from interface:GeneratorStrategyReturns code for getting a handler field reference. Normally a handler field is referenced usingTestCaseActivity.getId()as literal, but in case of a multi instance scope a specificgetHandlermethod must be called.
Normally:
approveUserTask
Multi instance scope:
getApproveUserTaskHandler(loopIndex)
- Specified by:
getHandlerin interfaceGeneratorStrategy- Returns:
- The handler reference code.
-
getHandlerAfter
public com.squareup.javapoet.CodeBlock getHandlerAfter()Description copied from interface:GeneratorStrategyReturns code for getting an after handler field reference. Normally an after handler field is referenced usingTestCaseActivity.getId()as literal +After, but in case of a multi instance scope a specificgetHandlermethod must be called.
Normally:
approveUserTaskAfter
Multi instance scope:
getApproveUserTaskHandlerAfter(loopIndex)
- Specified by:
getHandlerAfterin interfaceGeneratorStrategy- Returns:
- The after handler reference code.
-
getHandlerBefore
public com.squareup.javapoet.CodeBlock getHandlerBefore()Description copied from interface:GeneratorStrategyReturns code for getting a before handler field reference. Normally a before handler field is referenced usingTestCaseActivity.getId()as literal +Before, but in case of a multi instance scope a specificgetHandlermethod must be called.
Normally:
approveUserTaskBefore
Multi instance scope:
getApproveUserTaskHandlerBefore(loopIndex)
- Specified by:
getHandlerBeforein interfaceGeneratorStrategy- Returns:
- The before handler reference code.
-
getHandlerType
public com.squareup.javapoet.TypeName getHandlerType()Description copied from interface:GeneratorStrategyReturns the type name of the related handler orVoid, if the activity is not handled by a specific handler.- Specified by:
getHandlerTypein interfaceGeneratorStrategy- Returns:
- The handler type name e.g.
TypeName.get(UserTaskHandler.class).
-
getLiteral
Description copied from interface:GeneratorStrategyGets the ID of the underlying activity as a literal.- Specified by:
getLiteralin interfaceGeneratorStrategy- Returns:
- The activity ID literal.
-
getLiteralAfter
-
getLiteralBefore
-
hashCode
public int hashCode() -
hasPassed
public void hasPassed(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Description copied from interface:GeneratorStrategyAdds code, which asserts that the process instance has passed an activity.- Specified by:
hasPassedin interfaceGeneratorStrategy- Parameters:
methodBuilder- The method builder to use.
-
initHandler
public void initHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Description copied from interface:GeneratorStrategyAdds code, which initializes a handler field.approveUserTask = new UserTaskHandler(getProcessEngine(), "approveUserTask");
- Specified by:
initHandlerin interfaceGeneratorStrategy- Parameters:
methodBuilder- The method builder to use.- See Also:
-
initHandlerAfter
public void initHandlerAfter(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Description copied from interface:GeneratorStrategyAdds code, which initializes an after handler field.approveUserTaskAfter = new JobHandler(getProcessEngine(), "approveUserTask");
- Specified by:
initHandlerAfterin interfaceGeneratorStrategy- Parameters:
methodBuilder- The method builder to use.- See Also:
-
initHandlerAfterStatement
public com.squareup.javapoet.CodeBlock initHandlerAfterStatement()Description copied from interface:GeneratorStrategyReturns the statement that initializes the after handler.new JobHandler(getProcessEngine(), "approveUserTask");
- Specified by:
initHandlerAfterStatementin interfaceGeneratorStrategy- Returns:
- The code.
-
initHandlerBefore
public void initHandlerBefore(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Description copied from interface:GeneratorStrategyAdds code, which initializes a before handler field.approveUserTaskBefore = new JobHandler(getProcessEngine(), "approveUserTask");
- Specified by:
initHandlerBeforein interfaceGeneratorStrategy- Parameters:
methodBuilder- The method builder to use.- See Also:
-
initHandlerBeforeStatement
public com.squareup.javapoet.CodeBlock initHandlerBeforeStatement()Description copied from interface:GeneratorStrategyReturns the statement that initializes the before handler.new JobHandler(getProcessEngine(), "approveUserTask");
- Specified by:
initHandlerBeforeStatementin interfaceGeneratorStrategy- Returns:
- The code.
-
initHandlerStatement
public com.squareup.javapoet.CodeBlock initHandlerStatement()Description copied from interface:GeneratorStrategyReturns the statement that initializes the handler.new UserTaskHandler(getProcessEngine(), "approveUserTask");
- Specified by:
initHandlerStatementin interfaceGeneratorStrategy- Returns:
- The code.
-
isWaitingAt
public void isWaitingAt(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Description copied from interface:GeneratorStrategyAdds code, which asserts that the process instance is waiting at an activity.- Specified by:
isWaitingAtin interfaceGeneratorStrategy- Parameters:
methodBuilder- The method builder to use.
-
setMultiInstanceParent
public void setMultiInstanceParent(boolean multiInstanceParent) Description copied from interface:GeneratorStrategySet the multi instance parent indicator.- Specified by:
setMultiInstanceParentin interfaceGeneratorStrategy- Parameters:
multiInstanceParent-true, if the strategy is applied on a multi instance scope handler. Otherwise false.
-
shouldHandleAfter
public boolean shouldHandleAfter()If the activity has theasyncAfterflag set, it must be handled. If it is the last activity, and it does not end the process, the asynchronous continuation after should not be handled - the execution must wait!- Specified by:
shouldHandleAfterin interfaceGeneratorStrategy- Returns:
true, if it should be handled. Otherwisefalse.
-
shouldHandleBefore
public boolean shouldHandleBefore()If the activity has theasyncBeforeflag set, or it is a call activity but not a multi instance.- Specified by:
shouldHandleBeforein interfaceGeneratorStrategy- Returns:
true, if it should be handled. Otherwisefalse.- See Also:
-