Class MockJiraWorkflow

java.lang.Object
com.atlassian.jira.workflow.MockJiraWorkflow
All Implemented Interfaces:
JiraWorkflow, Comparable<JiraWorkflow>

public class MockJiraWorkflow extends Object implements JiraWorkflow
New Mock for JiraWorkflow. Note that there is another existing MockJiraWorkflow, but it relies on the underlying OSWorkflow implementation.
Since:
v3.13
  • Constructor Details

    • MockJiraWorkflow

      public MockJiraWorkflow()
    • MockJiraWorkflow

      public MockJiraWorkflow(String name)
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface JiraWorkflow
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface JiraWorkflow
    • setName

      public void setName(String name)
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface JiraWorkflow
    • getDescriptor

      public com.opensymphony.workflow.loader.WorkflowDescriptor getDescriptor()
      Specified by:
      getDescriptor in interface JiraWorkflow
    • setWorkflowDescriptor

      public void setWorkflowDescriptor(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor)
    • getAllActions

      public Collection<com.opensymphony.workflow.loader.ActionDescriptor> getAllActions()
      Description copied from interface: JiraWorkflow
      Get all the actions in this workflow, global, common and from steps.
      Specified by:
      getAllActions in interface JiraWorkflow
      Returns:
      A collection of ActionDescriptors.
    • getActionsByName

      public Collection<com.opensymphony.workflow.loader.ActionDescriptor> getActionsByName(String name)
      Description copied from interface: JiraWorkflow
      Get all actions in this workflow, global, common and from steps, whose name matched name.
      Specified by:
      getActionsByName in interface JiraWorkflow
      Parameters:
      name - of the action to match. This is case-insensitive.
      Returns:
      A collection of ActionDescriptor whose name matched the given name.
    • addAction

      public MockJiraWorkflow addAction(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
    • getActionsWithResult

      public Collection<com.opensymphony.workflow.loader.ActionDescriptor> getActionsWithResult(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Description copied from interface: JiraWorkflow
      Get all the actions which have a particular step as their unconditional result.
      Specified by:
      getActionsWithResult in interface JiraWorkflow
      Returns:
      all the actions which have a particular step as their unconditional result.
    • removeStep

      public boolean removeStep(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Description copied from interface: JiraWorkflow
      Remove a step from the workflow.

      This method will also remove all actions with this step ID as their unconditional result.

      Specified by:
      removeStep in interface JiraWorkflow
      Returns:
      true if the remove was successful
    • getLinkedStep

      public com.opensymphony.workflow.loader.StepDescriptor getLinkedStep(org.ofbiz.core.entity.GenericValue status)
      Description copied from interface: JiraWorkflow
      Get the StepDescriptor linked to the given status for this workflow.
      Specified by:
      getLinkedStep in interface JiraWorkflow
      Parameters:
      status - the Status
      Returns:
      The StepDescriptor linked, or null if no steps are linked to this status.
    • getLinkedStep

      public com.opensymphony.workflow.loader.StepDescriptor getLinkedStep(Status status)
      Description copied from interface: JiraWorkflow
      Get the StepDescriptor linked to the given status for this workflow.
      Specified by:
      getLinkedStep in interface JiraWorkflow
      Parameters:
      status - the Status
      Returns:
      The StepDescriptor linked, or null if no steps are linked to this status.
    • getLinkedStatuses

      public List<org.ofbiz.core.entity.GenericValue> getLinkedStatuses()
      Description copied from interface: JiraWorkflow
      Returns all statuses for this workflow
      Specified by:
      getLinkedStatuses in interface JiraWorkflow
      Returns:
      a List of GenericValue
    • getLinkedStatusObjects

      public List<Status> getLinkedStatusObjects()
      Description copied from interface: JiraWorkflow
      Returns all statuses for this workflow
      Specified by:
      getLinkedStatusObjects in interface JiraWorkflow
      Returns:
      a List of Status objects
    • getLinkedStatusIds

      public Set<String> getLinkedStatusIds()
      Description copied from interface: JiraWorkflow
      Returns all status ids for this workflow
      Specified by:
      getLinkedStatusIds in interface JiraWorkflow
      Returns:
      a Set of String status id's
    • isActive

      public boolean isActive() throws WorkflowException
      Description copied from interface: JiraWorkflow
      Determine whether this workflow object is currently active.
      Specified by:
      isActive in interface JiraWorkflow
      Returns:
      true if this workflow object is active.
      Throws:
      WorkflowException - Runtime Exception indicating a problem in the WorkflowManager.
    • isSystemWorkflow

      public boolean isSystemWorkflow() throws WorkflowException
      Description copied from interface: JiraWorkflow
      Determines if the workflow is loaded from XML or the database
      Specified by:
      isSystemWorkflow in interface JiraWorkflow
      Returns:
      true if this workflow object is the uneditable system workflow.
      Throws:
      WorkflowException - Runtime Exception indicating a problem in the WorkflowManager.
    • isEditable

      public boolean isEditable() throws WorkflowException
      Description copied from interface: JiraWorkflow
      Determines if the workflow can be modifed within JIRA.

      System workflows are never editable. The "published" version of an active workflow is not editable, but the draft version is. Inactive workflows are editable.

      Specified by:
      isEditable in interface JiraWorkflow
      Returns:
      true if this workflow is editable.
      Throws:
      WorkflowException - Runtime Exception indicating a problem in the WorkflowManager.
    • isDefault

      public boolean isDefault()
      Description copied from interface: JiraWorkflow
      Determines if the workflow is the default JIRA workflow
      Specified by:
      isDefault in interface JiraWorkflow
      Returns:
      true if this is the workflow is the default JIRA workflow.
    • hasDraftWorkflow

      public boolean hasDraftWorkflow()
      Description copied from interface: JiraWorkflow
      Determines if this workflow has a draft edit copy.
      Specified by:
      hasDraftWorkflow in interface JiraWorkflow
      Returns:
      true if this workflow has a draft edit copy.
    • getNextActionId

      public int getNextActionId()
      Description copied from interface: JiraWorkflow
      Get the next available action id
      Specified by:
      getNextActionId in interface JiraWorkflow
      Returns:
      The next available action id.
    • setStepsForTransition

      public void setStepsForTransition(com.opensymphony.workflow.loader.ActionDescriptor action, Collection<com.opensymphony.workflow.loader.StepDescriptor> steps)
    • getStepsForTransition

      public Collection<com.opensymphony.workflow.loader.StepDescriptor> getStepsForTransition(com.opensymphony.workflow.loader.ActionDescriptor action)
      Description copied from interface: JiraWorkflow
      Returns a collection of all step descriptors that reference the given common action.
      Specified by:
      getStepsForTransition in interface JiraWorkflow
      Returns:
      a collection of all step descriptors that reference the given common action.
    • getPostFunctionsForTransition

      public Collection<com.opensymphony.workflow.loader.FunctionDescriptor> getPostFunctionsForTransition(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Description copied from interface: JiraWorkflow
      Returns all post-functions of the transition, including the ones on all conditional results, unconditional results and 'global' (non-result) postfunctions.
      Specified by:
      getPostFunctionsForTransition in interface JiraWorkflow
      Returns:
      all post-functions of the transition, including the ones on all conditional results, unconditional results and 'global' (non-result) postfunctions.
    • isInitialAction

      public boolean isInitialAction(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Specified by:
      isInitialAction in interface JiraWorkflow
    • isCommonAction

      public boolean isCommonAction(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Specified by:
      isCommonAction in interface JiraWorkflow
    • setGlobalAction

      public void setGlobalAction(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
    • isGlobalAction

      public boolean isGlobalAction(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Specified by:
      isGlobalAction in interface JiraWorkflow
    • isOrdinaryAction

      public boolean isOrdinaryAction(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Specified by:
      isOrdinaryAction in interface JiraWorkflow
    • getLinkedStatus

      public Status getLinkedStatus(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Description copied from interface: JiraWorkflow
      Get the Status associated with the given StepDescriptor.
      Specified by:
      getLinkedStatus in interface JiraWorkflow
      Parameters:
      stepDescriptor - the StepDescriptor
      Returns:
      the Status associated with the given StepDescriptor.
    • getLinkedStatusObject

      public Status getLinkedStatusObject(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Description copied from interface: JiraWorkflow
      Get the Status associated with the given StepDescriptor.
      Specified by:
      getLinkedStatusObject in interface JiraWorkflow
      Parameters:
      stepDescriptor - the StepDescriptor
      Returns:
      the Status associated with the given StepDescriptor.
    • getLinkedStatusId

      public String getLinkedStatusId(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Description copied from interface: JiraWorkflow
      Get the id of the Status associated with the given StepDescriptor
      Specified by:
      getLinkedStatusId in interface JiraWorkflow
      Parameters:
      stepDescriptor - the StepDescriptor
      Returns:
      the id of the status associated with the given StepDescriptor.
    • getActionType

      public String getActionType(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Specified by:
      getActionType in interface JiraWorkflow
    • reset

      public void reset()
      Specified by:
      reset in interface JiraWorkflow
    • getActionsForScreen

      public Collection<com.opensymphony.workflow.loader.ActionDescriptor> getActionsForScreen(FieldScreen fieldScreen)
      Specified by:
      getActionsForScreen in interface JiraWorkflow
    • getUpdateAuthorName

      public String getUpdateAuthorName()
      Description copied from interface: JiraWorkflow
      Returns the most recent authors username.
      Specified by:
      getUpdateAuthorName in interface JiraWorkflow
      Returns:
      Returns the authors username
    • getUpdateAuthor

      public ApplicationUser getUpdateAuthor()
      Description copied from interface: JiraWorkflow
      Returns the most recent author

      Notice: This method will also return proxy user even when is not existing. Please use UserManager.isUserExisting(com.atlassian.jira.user.ApplicationUser) if you want to check user's existence.
      Specified by:
      getUpdateAuthor in interface JiraWorkflow
      Returns:
      The update author.
    • getUpdatedDate

      public Date getUpdatedDate()
      Description copied from interface: JiraWorkflow
      Returns the date of the most recent update to this workflow.
      Specified by:
      getUpdatedDate in interface JiraWorkflow
      Returns:
      date of the most recent update to this workflow
    • getMode

      public String getMode()
      Description copied from interface: JiraWorkflow
      Returns either JiraWorkflow.DRAFT or JiraWorkflow.LIVE depending on the workflow implementation.
      Specified by:
      getMode in interface JiraWorkflow
      Returns:
      JiraWorkflow.DRAFT or JiraWorkflow.LIVE
    • compareTo

      public int compareTo(JiraWorkflow o)
      Specified by:
      compareTo in interface Comparable<JiraWorkflow>
    • addStep

      public com.opensymphony.workflow.loader.StepDescriptor addStep(int id, String statusName)
      Adds a step to this fake workflow with the given status
    • clear

      public void clear()
    • isDraftWorkflow

      public boolean isDraftWorkflow()
      Description copied from interface: JiraWorkflow
      Determines if the workflow is an draft edit of an active workflow.
      Specified by:
      isDraftWorkflow in interface JiraWorkflow
      Returns:
      true if an draft workflow, false otherwise.
    • setDraftWorkflow

      public void setDraftWorkflow(boolean draftWorkflow)
    • toString

      public String toString()
      Overrides:
      toString in class Object