Class DefaultStrategy

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

public class DefaultStrategy extends Object implements GeneratorStrategy
Default strategy, used for all unhandled activities (with type TestCaseActivityType.OTHER).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final TestCaseActivity
     
    protected static final com.squareup.javapoet.TypeName
     
    protected static final com.squareup.javapoet.TypeName
     
    protected static final com.squareup.javapoet.TypeName
     
    protected static final com.squareup.javapoet.TypeName
     
    protected final String
     
    protected boolean
    Indicates if the strategy is applied on a multi instance scope handler or not - see setMultiInstanceParent(boolean)
    protected static final com.squareup.javapoet.TypeName
     
    protected static final com.squareup.javapoet.TypeName
     
    protected 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 activity is handled by a handler - e.g.:
    void
    addHandlerFieldAfter(com.squareup.javapoet.TypeSpec.Builder classBuilder)
    Adds a JobHandler field to the class, if an asynchronous continuation is configured after the activity - e.g.:
    void
    addHandlerFieldBefore(com.squareup.javapoet.TypeSpec.Builder classBuilder)
    Adds a JobHandler field to the class, if an asynchronous continuation is configured before the activity - e.g.:
    void
    addHandlerMethod(com.squareup.javapoet.TypeSpec.Builder classBuilder)
    Adds a "handle" method to the class, if the activity is handled by a handler - e.g.:
    void
    addHandlerMethodAfter(com.squareup.javapoet.TypeSpec.Builder classBuilder)
    Adds a method to the class, which provides a JobHandler, if an asynchronous continuation is configured after the activity - e.g.:
    void
    addHandlerMethodBefore(com.squareup.javapoet.TypeSpec.Builder classBuilder)
    Adds a method to the class, which provides a JobHandler, if an asynchronous continuation is configured before the activity - e.g.:
    void
    applyHandler(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.:
    void
    applyHandlerAfter(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
    Adds code to the execute/apply method, if an asynchronous continuation is configured after the activity - e.g.:
    void
    applyHandlerBefore(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 String
     
    boolean
     
    Returns the underlying activity.
    com.squareup.javapoet.CodeBlock
    Returns code for getting a handler field reference.
    com.squareup.javapoet.CodeBlock
    Returns code for getting an after handler field reference.
    com.squareup.javapoet.CodeBlock
    Returns code for getting a before 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 activity as a literal.
    protected String
     
    protected String
     
    int
     
    void
    hasPassed(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
    Adds code, which asserts that the process instance has passed an activity.
    void
    initHandler(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
    Adds code, which initializes a handler field.
    void
    initHandlerAfter(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
    Adds code, which initializes an after handler field.
    com.squareup.javapoet.CodeBlock
    Returns the statement that initializes the after handler.
    void
    initHandlerBefore(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
    Adds code, which initializes a before handler field.
    com.squareup.javapoet.CodeBlock
    Returns the statement that initializes the before handler.
    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 an activity.
    void
    setMultiInstanceParent(boolean multiInstanceParent)
    Set the multi instance parent indicator.
    boolean
    If the activity has the asyncAfter flag set, it must be handled.
    boolean
    If the activity has the asyncBefore flag set, or it is a call activity but not a multi instance.

    Methods inherited from class java.lang.Object

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

    • CALL_ACTIVITY

      protected static final com.squareup.javapoet.TypeName CALL_ACTIVITY
    • EVENT

      protected static final com.squareup.javapoet.TypeName EVENT
    • EXTERNAL_TASK

      protected static final com.squareup.javapoet.TypeName EXTERNAL_TASK
    • JOB

      protected static final com.squareup.javapoet.TypeName JOB
    • OTHER

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

      protected static final com.squareup.javapoet.TypeName RECEIVE_TASK
    • USER_TASK

      protected static final com.squareup.javapoet.TypeName USER_TASK
    • activity

      protected final TestCaseActivity activity
    • literal

      protected final String literal
    • multiInstanceParent

      protected boolean multiInstanceParent
      Indicates if the strategy is applied on a multi instance scope handler or not - see setMultiInstanceParent(boolean)
  • Constructor Details

  • 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 activity 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.
    • addHandlerFieldAfter

      public void addHandlerFieldAfter(com.squareup.javapoet.TypeSpec.Builder classBuilder)
      Description copied from interface: GeneratorStrategy
      Adds a JobHandler field to the class, if an asynchronous continuation is configured after the activity - e.g.:
       private JobHandler sendMailServiceTaskAfter;
       
      Specified by:
      addHandlerFieldAfter in interface GeneratorStrategy
      Parameters:
      classBuilder - The class builder to use.
    • addHandlerFieldBefore

      public void addHandlerFieldBefore(com.squareup.javapoet.TypeSpec.Builder classBuilder)
      Description copied from interface: GeneratorStrategy
      Adds a JobHandler field to the class, if an asynchronous continuation is configured before the activity - e.g.:
       private JobHandler sendMailServiceTaskBefore;
       
      Specified by:
      addHandlerFieldBefore 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 activity 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.
    • addHandlerMethodAfter

      public void addHandlerMethodAfter(com.squareup.javapoet.TypeSpec.Builder classBuilder)
      Description copied from interface: GeneratorStrategy
      Adds a method to the class, which provides a JobHandler, if an asynchronous continuation is configured after the activity - e.g.:
       public JobHandler handleSendMailServiceTaskAfter() {
         return sendMailServiceTaskAfter;
       }
       
      Specified by:
      addHandlerMethodAfter in interface GeneratorStrategy
      Parameters:
      classBuilder - The class builder to use.
    • addHandlerMethodBefore

      public void addHandlerMethodBefore(com.squareup.javapoet.TypeSpec.Builder classBuilder)
      Description copied from interface: GeneratorStrategy
      Adds a method to the class, which provides a JobHandler, if an asynchronous continuation is configured before the activity - e.g.:
       public JobHandler handleSendMailServiceTaskBefore() {
         return sendMailServiceTaskBefore;
       }
       
      Specified by:
      addHandlerMethodBefore 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 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:
      applyHandler in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
    • applyHandlerAfter

      public void applyHandlerAfter(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
      Description copied from interface: GeneratorStrategy
      Adds 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:
      applyHandlerAfter in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
    • applyHandlerBefore

      public void applyHandlerBefore(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
      Description copied from interface: GeneratorStrategy
      Adds 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:
      applyHandlerBefore in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
    • buildHandlerMethodName

      protected String buildHandlerMethodName(String literal)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getActivity

      public TestCaseActivity getActivity()
      Description copied from interface: GeneratorStrategy
      Returns the underlying activity.
      Specified by:
      getActivity in interface GeneratorStrategy
      Returns:
      The test case activity.
    • 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 referenced using TestCaseActivity.getId() as literal, 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.
    • getHandlerAfter

      public com.squareup.javapoet.CodeBlock getHandlerAfter()
      Description copied from interface: GeneratorStrategy
      Returns code for getting an after handler field reference. Normally an after handler field is referenced using TestCaseActivity.getId() as literal + After, but in case of a multi instance scope a specific getHandler method must be called.

      Normally:

       approveUserTaskAfter
       

      Multi instance scope:

       getApproveUserTaskHandlerAfter(loopIndex)
       
      Specified by:
      getHandlerAfter in interface GeneratorStrategy
      Returns:
      The after handler reference code.
    • getHandlerBefore

      public com.squareup.javapoet.CodeBlock getHandlerBefore()
      Description copied from interface: GeneratorStrategy
      Returns code for getting a before handler field reference. Normally a before handler field is referenced using TestCaseActivity.getId() as literal + Before, but in case of a multi instance scope a specific getHandler method must be called.

      Normally:

       approveUserTaskBefore
       

      Multi instance scope:

       getApproveUserTaskHandlerBefore(loopIndex)
       
      Specified by:
      getHandlerBefore in interface GeneratorStrategy
      Returns:
      The before 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 activity as a literal.
      Specified by:
      getLiteral in interface GeneratorStrategy
      Returns:
      The activity ID literal.
    • getLiteralAfter

      protected String getLiteralAfter()
    • getLiteralBefore

      protected String getLiteralBefore()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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 an activity.
      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(getProcessEngine(), "approveUserTask");
       
      Specified by:
      initHandler in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
      See Also:
    • initHandlerAfter

      public void initHandlerAfter(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
      Description copied from interface: GeneratorStrategy
      Adds code, which initializes an after handler field.
       approveUserTaskAfter = new JobHandler(getProcessEngine(), "approveUserTask");
       
      Specified by:
      initHandlerAfter in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
      See Also:
    • initHandlerAfterStatement

      public com.squareup.javapoet.CodeBlock initHandlerAfterStatement()
      Description copied from interface: GeneratorStrategy
      Returns the statement that initializes the after handler.
       new JobHandler(getProcessEngine(), "approveUserTask");
       
      Specified by:
      initHandlerAfterStatement in interface GeneratorStrategy
      Returns:
      The code.
    • initHandlerBefore

      public void initHandlerBefore(com.squareup.javapoet.MethodSpec.Builder methodBuilder)
      Description copied from interface: GeneratorStrategy
      Adds code, which initializes a before handler field.
       approveUserTaskBefore = new JobHandler(getProcessEngine(), "approveUserTask");
       
      Specified by:
      initHandlerBefore in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
      See Also:
    • initHandlerBeforeStatement

      public com.squareup.javapoet.CodeBlock initHandlerBeforeStatement()
      Description copied from interface: GeneratorStrategy
      Returns the statement that initializes the before handler.
       new JobHandler(getProcessEngine(), "approveUserTask");
       
      Specified by:
      initHandlerBeforeStatement in interface GeneratorStrategy
      Returns:
      The code.
    • initHandlerStatement

      public com.squareup.javapoet.CodeBlock initHandlerStatement()
      Description copied from interface: GeneratorStrategy
      Returns the statement that initializes the handler.
       new UserTaskHandler(getProcessEngine(), "approveUserTask");
       
      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 an activity.
      Specified by:
      isWaitingAt in interface GeneratorStrategy
      Parameters:
      methodBuilder - The method builder to use.
    • setMultiInstanceParent

      public void setMultiInstanceParent(boolean multiInstanceParent)
      Description copied from interface: GeneratorStrategy
      Set the multi instance parent indicator.
      Specified by:
      setMultiInstanceParent in interface GeneratorStrategy
      Parameters:
      multiInstanceParent - true, if the strategy is applied on a multi instance scope handler. Otherwise false.
    • shouldHandleAfter

      public boolean shouldHandleAfter()
      If the activity has the asyncAfter flag 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:
      shouldHandleAfter in interface GeneratorStrategy
      Returns:
      true, if it should be handled. Otherwise false.
    • shouldHandleBefore

      public boolean shouldHandleBefore()
      If the activity has the asyncBefore flag set, or it is a call activity but not a multi instance.
      Specified by:
      shouldHandleBefore in interface GeneratorStrategy
      Returns:
      true, if it should be handled. Otherwise false.
      See Also: