Class DefaultStrategy

java.lang.Object
org.camunda.community.bpmndt.strategy.DefaultStrategy
All Implemented Interfaces:
GeneratorStrategy
Direct Known Subclasses:
DefaultHandlerStrategy

public class DefaultStrategy extends Object implements GeneratorStrategy
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.squareup.javapoet.TypeName
     
    static final com.squareup.javapoet.TypeName
     
    protected final BpmnElement
     
    static final com.squareup.javapoet.TypeName
     
    protected final String
     
    static final com.squareup.javapoet.TypeName
     
    static final com.squareup.javapoet.TypeName
     
    static final com.squareup.javapoet.TypeName
     
    static final com.squareup.javapoet.TypeName
     
    static final com.squareup.javapoet.TypeName
     
    static final com.squareup.javapoet.TypeName
     
    static final com.squareup.javapoet.TypeName
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.:
    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.:
    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.:
    Returns the underlying BPMN element.
    com.squareup.javapoet.CodeBlock
    Returns code for getting a handler field reference.
    com.squareup.javapoet.TypeName
    Returns the type name of the related handler or Void, if the activity is not handled by a specific handler.
    Gets the ID of the underlying BPMN element as a literal.
    void
    hasPassed(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
    Adds code, which asserts that the process instance has passed a BPMN element.
    void
    initHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
    Adds code, which initializes a handler field.
    void
    initHandlerElement(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
    Adds code, which initializes the handler's element - e.g.
    com.squareup.javapoet.CodeBlock
    Returns the statement that initializes the handler.
    void
    isWaitingAt(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
    Adds code, which asserts that the process instance is waiting at a BPMN element.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CALL_ACTIVITY

      public static final com.squareup.javapoet.TypeName CALL_ACTIVITY
    • CUSTOM_MULTI_INSTANCE

      public static final com.squareup.javapoet.TypeName CUSTOM_MULTI_INSTANCE
    • JOB

      public static final com.squareup.javapoet.TypeName JOB
    • MESSAGE_EVENT

      public static final com.squareup.javapoet.TypeName MESSAGE_EVENT
    • OUTBOUND_CONNECTOR

      public static final com.squareup.javapoet.TypeName OUTBOUND_CONNECTOR
    • OTHER

      public static final com.squareup.javapoet.TypeName OTHER
    • RECEIVE_TASK

      public static final com.squareup.javapoet.TypeName RECEIVE_TASK
    • SIGNAL_EVENT

      public static final com.squareup.javapoet.TypeName SIGNAL_EVENT
    • TIMER_EVENT

      public static final com.squareup.javapoet.TypeName TIMER_EVENT
    • USER_TASK

      public static final com.squareup.javapoet.TypeName USER_TASK
    • element

      protected final BpmnElement element
    • literal

      protected final String literal
  • Constructor Details

    • DefaultStrategy

      public DefaultStrategy(BpmnElement element)
  • Method Details

    • addHandlerField

      public void addHandlerField(com.squareup.javapoet.TypeSpec.Builder classBuilder)
      Description copied from interface: GeneratorStrategy
      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.

      Specified by:
      addHandlerField in interface GeneratorStrategy
      Parameters:
      classBuilder - The class builder to use.
    • addHandlerMethod

      public void addHandlerMethod(com.squareup.javapoet.TypeSpec.Builder classBuilder)
      Description copied from interface: GeneratorStrategy
      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.

      Specified by:
      addHandlerMethod in interface GeneratorStrategy
      Parameters:
      classBuilder - The class builder to use.
    • applyHandler

      public void applyHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
      Description copied from interface: GeneratorStrategy
      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.

      Specified by:
      applyHandler in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
    • getElement

      public BpmnElement getElement()
      Description copied from interface: GeneratorStrategy
      Returns the underlying BPMN element.
      Specified by:
      getElement in interface GeneratorStrategy
      Returns:
      The test case element.
    • getHandler

      public com.squareup.javapoet.CodeBlock getHandler()
      Description copied from interface: GeneratorStrategy
      Returns code for getting a handler field reference. Normally a handler field is references using GeneratorStrategy.getLiteral(), but in case of a multi instance scope a specific getHandler method must be called.

      Normally:

       approveUserTask
       

      Multi instance scope:

       getApproveUserTaskHandler(loopIndex)
       
      Specified by:
      getHandler in interface GeneratorStrategy
      Returns:
      The handler reference code.
    • getHandlerType

      public com.squareup.javapoet.TypeName getHandlerType()
      Description copied from interface: GeneratorStrategy
      Returns the type name of the related handler or Void, if the activity is not handled by a specific handler.
      Specified by:
      getHandlerType in interface GeneratorStrategy
      Returns:
      The handler type name e.g. TypeName.get(UserTaskHandler.class).
    • getLiteral

      public String getLiteral()
      Description copied from interface: GeneratorStrategy
      Gets the ID of the underlying BPMN element as a literal.
      Specified by:
      getLiteral in interface GeneratorStrategy
      Returns:
      The element ID literal.
    • hasPassed

      public void hasPassed(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
      Description copied from interface: GeneratorStrategy
      Adds code, which asserts that the process instance has passed a BPMN element.
      Specified by:
      hasPassed in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
    • initHandler

      public void initHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
      Description copied from interface: GeneratorStrategy
      Adds code, which initializes a handler field.
       approveUserTask = new UserTaskHandler(approveUserTaskElement);
       
      Specified by:
      initHandler in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
      See Also:
    • initHandlerElement

      public void initHandlerElement(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
      Description copied from interface: GeneratorStrategy
      Adds code, which initializes the handler's element - e.g. TestCaseInstanceElement.UserTaskElement
      Specified by:
      initHandlerElement in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
    • initHandlerStatement

      public com.squareup.javapoet.CodeBlock initHandlerStatement()
      Description copied from interface: GeneratorStrategy
      Returns the statement that initializes the handler.
       new UserTaskHandler(approveUserTaskElement)
       
      Specified by:
      initHandlerStatement in interface GeneratorStrategy
      Returns:
      The code.
    • isWaitingAt

      public void isWaitingAt(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
      Description copied from interface: GeneratorStrategy
      Adds code, which asserts that the process instance is waiting at a BPMN element.
      Specified by:
      isWaitingAt in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.