Package org.camunda.community.bpmndt
Interface GeneratorStrategy
- All Known Implementing Classes:
CallActivityStrategy,CustomMultiInstanceScopeStrategy,CustomMultiInstanceStrategy,DefaultHandlerStrategy,DefaultStrategy,JobStrategy,MessageBoundaryEventStrategy,MessageEventStrategy,OutboundConnectorStrategy,SignalBoundaryEventStrategy,SignalEventStrategy,TimerBoundaryEventStrategy,TimerEventStrategy,UserTaskStrategy
public interface GeneratorStrategy
Strategy, used per BPMN element when generating a test case.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddHandlerField(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds a handler field to the class, if the element is handled by a handler - e.g.:voidaddHandlerMethod(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds a "handle" method to the class, if the element is handled by a handler - e.g.:voidapplyHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code to the execute/apply method, if the element is handled by a handler - e.g.:Returns the underlying BPMN element.com.squareup.javapoet.CodeBlockReturns code for getting a 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 BPMN element as a literal.voidhasPassed(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which asserts that the process instance has passed a BPMN element.voidinitHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which initializes a handler field.voidinitHandlerElement(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which initializes the handler's element - e.g.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 a BPMN element.
-
Method Details
-
addHandlerField
void addHandlerField(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds a handler field to the class, if the element is handled by a handler - e.g.:private UserTaskHandler approveUserTask;
Otherwise, no field is added.
- Parameters:
classBuilder- The class builder to use.
-
addHandlerMethod
void addHandlerMethod(com.squareup.javapoet.TypeSpec.Builder classBuilder) Adds a "handle" method to the class, if the element is handled by a handler - e.g.:public UserTaskHandler handleApproveUserTask() { return approveUserTask; }Otherwise, no field is added.
- Parameters:
classBuilder- The class builder to use.
-
applyHandler
void applyHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code to the execute/apply method, if the element is handled by a handler - e.g.:instance.isWaitingAt(processInstanceEvent, "placeOrderExternalTask"); instance.apply(processInstanceEvent, placeOrderExternalTask)
or the previous element is an event based gateway.
- Parameters:
methodBuilder- The method builder to use.
-
getElement
BpmnElement getElement()Returns the underlying BPMN element.- Returns:
- The test case element.
-
getHandler
com.squareup.javapoet.CodeBlock getHandler()Returns code for getting a handler field reference. Normally a handler field is references usinggetLiteral(), but in case of a multi instance scope a specificgetHandlermethod must be called.
Normally:
approveUserTask
Multi instance scope:
getApproveUserTaskHandler(loopIndex)
- Returns:
- The handler reference code.
-
getHandlerType
com.squareup.javapoet.TypeName getHandlerType()Returns the type name of the related handler orVoid, if the activity is not handled by a specific handler.- Returns:
- The handler type name e.g.
TypeName.get(UserTaskHandler.class).
-
getLiteral
String getLiteral()Gets the ID of the underlying BPMN element as a literal.- Returns:
- The element ID literal.
-
hasPassed
void hasPassed(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which asserts that the process instance has passed a BPMN element.- Parameters:
methodBuilder- The method builder to use.
-
initHandler
void initHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which initializes a handler field.approveUserTask = new UserTaskHandler(approveUserTaskElement);
- Parameters:
methodBuilder- The method builder to use.- See Also:
-
initHandlerElement
void initHandlerElement(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which initializes the handler's element - e.g.TestCaseInstanceElement.UserTaskElement- Parameters:
methodBuilder- The method builder to use.
-
initHandlerStatement
com.squareup.javapoet.CodeBlock initHandlerStatement()Returns the statement that initializes the handler.new UserTaskHandler(approveUserTaskElement)
- Returns:
- The code.
-
isWaitingAt
void isWaitingAt(com.squareup.javapoet.MethodSpec.Builder methodBuilder) Adds code, which asserts that the process instance is waiting at a BPMN element.- Parameters:
methodBuilder- The method builder to use.
-