Class BpmnAwareTests

  • Direct Known Subclasses:
    CmmnAwareTests

    public class BpmnAwareTests
    extends AbstractAssertions
    Convenience class to access only camunda *BPMN* related Assertions PLUS helper methods. Usage is possible, if you only need BPMN Tests and mandatory if you still use Camunda Platform lower than 7.2 version. Use it with a static import: import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.*;
    See Also:
    for full Camunda Platform Assertions functionality
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected BpmnAwareTests()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ExternalTaskAssert assertThat​(ExternalTask actual)
      Assert that...
      static ProcessDefinitionAssert assertThat​(ProcessDefinition actual)
      Assert that...
      static JobAssert assertThat​(Job actual)
      Assert that...
      static ProcessInstanceAssert assertThat​(ProcessInstance actual)
      Assert that...
      static TaskAssert assertThat​(Task actual)
      Assert that...
      static AuthorizationService authorizationService()
      Helper method to easily access AuthorizationService
      static ProcessInstance calledProcessInstance()
      Helper method to easily access the only called process instance currently available in the context of the last asserted process instance.
      static ProcessInstance calledProcessInstance​(java.lang.String processDefinitionKey)
      Helper method to easily access the only called process instance with the given processDefinitionKey currently available in the context of the last asserted process instance.
      static ProcessInstance calledProcessInstance​(java.lang.String processDefinitionKey, ProcessInstance processInstance)
      Helper method to easily access the only called process instance with the given processDefinitionKey currently available in the context of the given process instance.
      static ProcessInstance calledProcessInstance​(ProcessInstance processInstance)
      Helper method to easily access the only called process instance currently available in the context of the given process instance.
      static ProcessInstance calledProcessInstance​(ProcessInstanceQuery processInstanceQuery)
      Helper method to easily access the only called process instance compliant to a given processInstanceQuery and currently available in the context of the last asserted process instance.
      static ProcessInstance calledProcessInstance​(ProcessInstanceQuery processInstanceQuery, ProcessInstance processInstance)
      Helper method to easily access the only called process instance compliant to a given processInstanceQuery and currently available in the context of the given process instance.
      static Task claim​(Task task, java.lang.String assigneeUserId)
      Helper method to easily claim a task for a specific assignee.
      static void complete​(ExternalTask externalTask)
      Helper method to easily fetch, lock and complete an external task.
      static void complete​(ExternalTask externalTask, java.util.Map<java.lang.String,​java.lang.Object> variables)
      Helper method to easily fetch, lock and complete an external task.
      static void complete​(LockedExternalTask lockedExternalTask)
      Helper method to easily complete a locked external task.
      static void complete​(LockedExternalTask lockedExternalTask, java.util.Map<java.lang.String,​java.lang.Object> variables)
      Helper method to easily complete a locked external task.
      static void complete​(Task task)
      Helper method to easily complete a task.
      static void complete​(Task task, java.util.Map<java.lang.String,​java.lang.Object> variables)
      Helper method to easily complete a task and pass some process variables.
      static DecisionService decisionService()
      Helper method to easily access DecisionService
      static void execute​(Job job)
      Helper method to easily execute a job.
      static ExecutionQuery executionQuery()
      Helper method to easily create a new ExecutionQuery
      static ExternalTask externalTask()
      Helper method to easily access the only external task currently available in the context of the last asserted process instance.
      static ExternalTask externalTask​(java.lang.String activityId)
      Helper method to easily access the only external task with the given activityId currently available in the context of the last asserted process instance.
      static ExternalTask externalTask​(java.lang.String activityId, ProcessInstance processInstance)
      Helper method to easily access the only external task with the given activityId currently available in the context of the given process instance.
      static ExternalTask externalTask​(ExternalTaskQuery externalTaskQuery)
      Helper method to easily access the only external task compliant to a given externalTaskQuery and currently available in the context of the last asserted process instance.
      static ExternalTask externalTask​(ExternalTaskQuery externalTaskQuery, ProcessInstance processInstance)
      Helper method to easily access the only external task compliant to a given externalTaskQuery and currently available in the context of the given process instance.
      static ExternalTask externalTask​(ProcessInstance processInstance)
      Helper method to easily access the only external task currently available in the context of the given process instance.
      static ExternalTaskQuery externalTaskQuery()
      Helper method to easily create a new ExternalTaskQuery
      static ExternalTaskService externalTaskService()
      Helper method to easily access ExternalTaskService
      static java.util.List<LockedExternalTask> fetchAndLock​(java.lang.String topic, java.lang.String workerId, int maxResults)
      Helper method to easily fetch and lock external tasks from a given topic using a given workerId.
      static java.lang.String findId​(java.lang.String name)
      Maps any element (task, event, gateway) from the name to the ID.
      static FormService formService()
      Helper method to easily access FormService
      static HistoryService historyService()
      Helper method to easily access HistoryService
      static IdentityService identityService()
      Helper method to easily access IdentityService
      static Job job()
      Helper method to easily access the only job currently available in the context of the last asserted process instance.
      static Job job​(java.lang.String activityId)
      Helper method to easily access the only job with the given activityId currently available in the context of the last asserted process instance.
      static Job job​(java.lang.String activityId, ProcessInstance processInstance)
      Helper method to easily access the only job with the given activityId currently available in the context of the given process instance.
      static Job job​(JobQuery jobQuery)
      Helper method to easily access the only job compliant to a given jobQuery and currently available in the context of the last asserted process instance.
      static Job job​(JobQuery jobQuery, ProcessInstance processInstance)
      Helper method to easily access the only job compliant to a given jobQuery and currently available in the context of the given process instance.
      static Job job​(ProcessInstance processInstance)
      Helper method to easily access the only job currently available in the context of the given process instance.
      static JobQuery jobQuery()
      Helper method to easily create a new JobQuery
      static ManagementService managementService()
      Helper method to easily access ManagementService
      static ProcessDefinition processDefinition()
      Helper method to easily access the process definition on which the last asserted process instance is based.
      static ProcessDefinition processDefinition​(java.lang.String processDefinitionKey)
      Helper method to easily access the process definition with the given processDefinitionKey.
      static ProcessDefinition processDefinition​(ProcessDefinitionQuery processDefinitionQuery)
      Helper method to easily access the process definition compliant to a given process definition query.
      static ProcessDefinition processDefinition​(ProcessInstance processInstance)
      Helper method to easily access the process definition on which the given process instance is based.
      static ProcessDefinitionQuery processDefinitionQuery()
      Helper method to easily create a new ProcessDefinitionQuery
      static ProcessInstanceQuery processInstanceQuery()
      Helper method to easily create a new ProcessInstanceQuery
      static RepositoryService repositoryService()
      Helper method to easily access RepositoryService
      static RuntimeService runtimeService()
      Helper method to easily access RuntimeService
      static Task task()
      Helper method to easily access the only task currently available in the context of the last asserted process instance.
      static Task task​(java.lang.String taskDefinitionKey)
      Helper method to easily access the only task with the given taskDefinitionKey currently available in the context of the last asserted process instance.
      static Task task​(java.lang.String taskDefinitionKey, ProcessInstance processInstance)
      Helper method to easily access the only task with the given taskDefinitionKey currently available in the context of the given process instance.
      static Task task​(ProcessInstance processInstance)
      Helper method to easily access the only task currently available in the context of the given process instance.
      static Task task​(TaskQuery taskQuery)
      Helper method to easily access the only task compliant to a given taskQuery and currently available in the context of the last asserted process instance.
      static Task task​(TaskQuery taskQuery, ProcessInstance processInstance)
      Helper method to easily access the only task compliant to a given taskQuery and currently available in the context of the given process instance.
      static TaskQuery taskQuery()
      Helper method to easily create a new TaskQuery
      static TaskService taskService()
      Helper method to easily access TaskService
      static Task unclaim​(Task task)
      Helper method to easily unclaim a task.
      static java.util.Map<java.lang.String,​java.lang.Object> withVariables​(java.lang.String key, java.lang.Object value, java.lang.Object... furtherKeyValuePairs)
      Helper method to easily construct a map of process variables
      • Methods inherited from class java.lang.Object

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

      • DEFAULT_LOCK_DURATION_EXTERNAL_TASK

        public static final long DEFAULT_LOCK_DURATION_EXTERNAL_TASK
        See Also:
        Constant Field Values
      • DEFAULT_WORKER_EXTERNAL_TASK

        public static final java.lang.String DEFAULT_WORKER_EXTERNAL_TASK
        See Also:
        Constant Field Values
    • Constructor Detail

      • BpmnAwareTests

        protected BpmnAwareTests()
    • Method Detail

      • assertThat

        public static ProcessDefinitionAssert assertThat​(ProcessDefinition actual)
        Assert that... the given ProcessDefinition meets your expectations.
        Parameters:
        actual - ProcessDefinition under test
        Returns:
        Assert object offering ProcessDefinition specific assertions.
      • assertThat

        public static ProcessInstanceAssert assertThat​(ProcessInstance actual)
        Assert that... the given ProcessInstance meets your expectations.
        Parameters:
        actual - ProcessInstance under test
        Returns:
        Assert object offering ProcessInstance specific assertions.
      • assertThat

        public static TaskAssert assertThat​(Task actual)
        Assert that... the given Task meets your expectations.
        Parameters:
        actual - Task under test
        Returns:
        Assert object offering Task specific assertions.
      • assertThat

        public static ExternalTaskAssert assertThat​(ExternalTask actual)
        Assert that... the given ExternalTask meets your expectations.
        Parameters:
        actual - ExternalTask under test
        Returns:
        Assert object offering Task specific assertions.
      • assertThat

        public static JobAssert assertThat​(Job actual)
        Assert that... the given Job meets your expectations.
        Parameters:
        actual - Job under test
        Returns:
        Assert object offering Job specific assertions.
      • runtimeService

        public static RuntimeService runtimeService()
        Helper method to easily access RuntimeService
        Returns:
        RuntimeService of process engine bound to this testing thread
        See Also:
        RuntimeService
      • authorizationService

        public static AuthorizationService authorizationService()
        Helper method to easily access AuthorizationService
        Returns:
        AuthorizationService of process engine bound to this testing thread
        See Also:
        AuthorizationService
      • formService

        public static FormService formService()
        Helper method to easily access FormService
        Returns:
        FormService of process engine bound to this testing thread
        See Also:
        FormService
      • historyService

        public static HistoryService historyService()
        Helper method to easily access HistoryService
        Returns:
        HistoryService of process engine bound to this testing thread
        See Also:
        HistoryService
      • identityService

        public static IdentityService identityService()
        Helper method to easily access IdentityService
        Returns:
        IdentityService of process engine bound to this testing thread
        See Also:
        IdentityService
      • managementService

        public static ManagementService managementService()
        Helper method to easily access ManagementService
        Returns:
        ManagementService of process engine bound to this testing thread
        See Also:
        ManagementService
      • repositoryService

        public static RepositoryService repositoryService()
        Helper method to easily access RepositoryService
        Returns:
        RepositoryService of process engine bound to this testing thread
        See Also:
        RepositoryService
      • taskService

        public static TaskService taskService()
        Helper method to easily access TaskService
        Returns:
        TaskService of process engine bound to this testing thread
        See Also:
        TaskService
      • externalTaskService

        public static ExternalTaskService externalTaskService()
        Helper method to easily access ExternalTaskService
        Returns:
        ExternalTaskService of process engine bound to this testing thread
        See Also:
        ExternalTaskService
      • decisionService

        public static DecisionService decisionService()
        Helper method to easily access DecisionService
        Returns:
        DecisionService of process engine bound to this testing thread
        See Also:
        DecisionService
      • taskQuery

        public static TaskQuery taskQuery()
        Helper method to easily create a new TaskQuery
        Returns:
        new TaskQuery for process engine bound to this testing thread
        See Also:
        TaskQuery
      • externalTaskQuery

        public static ExternalTaskQuery externalTaskQuery()
        Helper method to easily create a new ExternalTaskQuery
        Returns:
        new ExternalTaskQuery for process engine bound to this testing thread
        See Also:
        ExternalTaskQuery
      • jobQuery

        public static JobQuery jobQuery()
        Helper method to easily create a new JobQuery
        Returns:
        new JobQuery for process engine bound to this testing thread
        See Also:
        JobQuery
      • processInstanceQuery

        public static ProcessInstanceQuery processInstanceQuery()
        Helper method to easily create a new ProcessInstanceQuery
        Returns:
        new ProcessInstanceQuery for process engine bound to this testing thread
        See Also:
        ProcessInstanceQuery
      • processDefinitionQuery

        public static ProcessDefinitionQuery processDefinitionQuery()
        Helper method to easily create a new ProcessDefinitionQuery
        Returns:
        new ProcessDefinitionQuery for process engine bound to this testing thread
        See Also:
        ProcessDefinitionQuery
      • executionQuery

        public static ExecutionQuery executionQuery()
        Helper method to easily create a new ExecutionQuery
        Returns:
        new ExecutionQuery for process engine bound to this testing thread
        See Also:
        ExecutionQuery
      • withVariables

        public static java.util.Map<java.lang.String,​java.lang.Object> withVariables​(java.lang.String key,
                                                                                           java.lang.Object value,
                                                                                           java.lang.Object... furtherKeyValuePairs)
        Helper method to easily construct a map of process variables
        Parameters:
        key - (obligatory) key of first process variable
        value - (obligatory) value of first process variable
        furtherKeyValuePairs - (optional) key/value pairs for further process variables
        Returns:
        a map of process variables by passing a list of String, Object key value pairs.
      • task

        public static Task task()
        Helper method to easily access the only task currently available in the context of the last asserted process instance.
        Returns:
        the only task of the last asserted process instance. May return null if no such task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one task is delivered by the underlying query or in case no process instance was asserted yet.
      • task

        public static Task task​(ProcessInstance processInstance)
        Helper method to easily access the only task currently available in the context of the given process instance.
        Parameters:
        processInstance - the process instance for which a task should be retrieved.
        Returns:
        the only task of the process instance. May return null if no such task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one task is delivered by the underlying query.
      • task

        public static Task task​(java.lang.String taskDefinitionKey)
        Helper method to easily access the only task with the given taskDefinitionKey currently available in the context of the last asserted process instance.
        Parameters:
        taskDefinitionKey - the key of the task that should be retrieved.
        Returns:
        the only task of the last asserted process instance. May return null if no such task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one task is delivered by the underlying query or in case no process instance was asserted yet.
      • task

        public static Task task​(java.lang.String taskDefinitionKey,
                                ProcessInstance processInstance)
        Helper method to easily access the only task with the given taskDefinitionKey currently available in the context of the given process instance.
        Parameters:
        taskDefinitionKey - the key of the task that should be retrieved.
        processInstance - the process instance for which a task should be retrieved.
        Returns:
        the only task of the given process instance. May return null if no such task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one task is delivered by the underlying query.
      • task

        public static Task task​(TaskQuery taskQuery)
        Helper method to easily access the only task compliant to a given taskQuery and currently available in the context of the last asserted process instance.
        Parameters:
        taskQuery - the query with which the task should be retrieved. This query will be further narrowed to the last asserted process instance.
        Returns:
        the only task of the last asserted process instance and compliant to the given query. May return null in case no such task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one task is delivered by the underlying query or in case no process instance was asserted yet.
      • task

        public static Task task​(TaskQuery taskQuery,
                                ProcessInstance processInstance)
        Helper method to easily access the only task compliant to a given taskQuery and currently available in the context of the given process instance.
        Parameters:
        taskQuery - the query with which the task should be retrieved. This query will be further narrowed to the given process instance.
        processInstance - the process instance for which a task should be retrieved.
        Returns:
        the only task of the given process instance and compliant to the given query. May return null in case no such task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one task is delivered by the underlying query.
      • externalTask

        public static ExternalTask externalTask()
        Helper method to easily access the only external task currently available in the context of the last asserted process instance.
        Returns:
        the only external task of the last asserted process instance. May return null if no such external task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one external task is delivered by the underlying query or in case no process instance was asserted yet.
      • externalTask

        public static ExternalTask externalTask​(ProcessInstance processInstance)
        Helper method to easily access the only external task currently available in the context of the given process instance.
        Parameters:
        processInstance - the process instance for which an external task should be retrieved.
        Returns:
        the only external task of the process instance. May return null if no such external task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one external task is delivered by the underlying query.
      • externalTask

        public static ExternalTask externalTask​(java.lang.String activityId)
        Helper method to easily access the only external task with the given activityId currently available in the context of the last asserted process instance.
        Parameters:
        activityId - the key of the external task that should be retrieved.
        Returns:
        the only external task of the last asserted process instance. May return null if no such external task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one external task is delivered by the underlying query or in case no process instance was asserted yet.
      • externalTask

        public static ExternalTask externalTask​(java.lang.String activityId,
                                                ProcessInstance processInstance)
        Helper method to easily access the only external task with the given activityId currently available in the context of the given process instance.
        Parameters:
        activityId - the key of the external task that should be retrieved.
        processInstance - the process instance for which a external task should be retrieved.
        Returns:
        the only external task of the given process instance. May return null if no such external task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one external task is delivered by the underlying query.
      • externalTask

        public static ExternalTask externalTask​(ExternalTaskQuery externalTaskQuery)
        Helper method to easily access the only external task compliant to a given externalTaskQuery and currently available in the context of the last asserted process instance.
        Parameters:
        externalTaskQuery - the query with which the external task should be retrieved. This query will be further narrowed to the last asserted process instance.
        Returns:
        the only external task of the last asserted process instance and compliant to the given query. May return null in case no such external task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one external task is delivered by the underlying query or in case no process instance was asserted yet.
      • externalTask

        public static ExternalTask externalTask​(ExternalTaskQuery externalTaskQuery,
                                                ProcessInstance processInstance)
        Helper method to easily access the only external task compliant to a given externalTaskQuery and currently available in the context of the given process instance.
        Parameters:
        externalTaskQuery - the query with which the external task should be retrieved. This query will be further narrowed to the given process instance.
        processInstance - the process instance for which a external task should be retrieved.
        Returns:
        the only external task of the given process instance and compliant to the given query. May return null in case no such external task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one external task is delivered by the underlying query.
      • processDefinition

        public static ProcessDefinition processDefinition()
        Helper method to easily access the process definition on which the last asserted process instance is based.
        Returns:
        the process definition on which the last asserted process instance is based.
        Throws:
        java.lang.IllegalStateException - in case no process instance was asserted yet.
      • processDefinition

        public static ProcessDefinition processDefinition​(ProcessInstance processInstance)
        Helper method to easily access the process definition on which the given process instance is based.
        Parameters:
        processInstance - the process instance for which the definition should be retrieved.
        Returns:
        the process definition on which the given process instance is based.
      • processDefinition

        public static ProcessDefinition processDefinition​(java.lang.String processDefinitionKey)
        Helper method to easily access the process definition with the given processDefinitionKey.
        Parameters:
        processDefinitionKey - the key of the process definition that should be retrieved.
        Returns:
        the process definition with the given key. May return null if no such process definition exists.
      • processDefinition

        public static ProcessDefinition processDefinition​(ProcessDefinitionQuery processDefinitionQuery)
        Helper method to easily access the process definition compliant to a given process definition query.
        Parameters:
        processDefinitionQuery - the query with which the process definition should be retrieved.
        Returns:
        the process definition compliant to the given query. May return null in case no such process definition exists.
        Throws:
        ProcessEngineException - in case more than one process definition is delivered by the underlying query.
      • calledProcessInstance

        public static ProcessInstance calledProcessInstance()
        Helper method to easily access the only called process instance currently available in the context of the last asserted process instance.
        Returns:
        the only called process instance called by the last asserted process instance. May return null if no such process instance exists.
        Throws:
        java.lang.IllegalStateException - in case more than one process instance is delivered by the underlying query or in case no process instance was asserted yet.
      • calledProcessInstance

        public static ProcessInstance calledProcessInstance​(ProcessInstance processInstance)
        Helper method to easily access the only called process instance currently available in the context of the given process instance.
        Parameters:
        processInstance - the process instance for which a called process instance should be retrieved.
        Returns:
        the only called process instance called by the given process instance. May return null if no such process instance exists.
        Throws:
        java.lang.IllegalStateException - in case more than one process instance is delivered by the underlying query.
      • calledProcessInstance

        public static ProcessInstance calledProcessInstance​(java.lang.String processDefinitionKey)
        Helper method to easily access the only called process instance with the given processDefinitionKey currently available in the context of the last asserted process instance.
        Parameters:
        processDefinitionKey - the key of the process instance that should be retrieved.
        Returns:
        the only such process instance called by the last asserted process instance. May return null if no such process instance exists.
        Throws:
        java.lang.IllegalStateException - in case more than one process instance is delivered by the underlying query or in case no process instance was asserted yet.
      • calledProcessInstance

        public static ProcessInstance calledProcessInstance​(java.lang.String processDefinitionKey,
                                                            ProcessInstance processInstance)
        Helper method to easily access the only called process instance with the given processDefinitionKey currently available in the context of the given process instance.
        Parameters:
        processDefinitionKey - the key of the process instance that should be retrieved.
        processInstance - the process instance for which a called process instance should be retrieved.
        Returns:
        the only such process instance called by the given process instance. May return null if no such process instance exists.
        Throws:
        java.lang.IllegalStateException - in case more than one process instance is delivered by the underlying query.
      • calledProcessInstance

        public static ProcessInstance calledProcessInstance​(ProcessInstanceQuery processInstanceQuery)
        Helper method to easily access the only called process instance compliant to a given processInstanceQuery and currently available in the context of the last asserted process instance.
        Parameters:
        processInstanceQuery - the query with which the called process instance should be retrieved. This query will be further narrowed to the last asserted process instance.
        Returns:
        the only such process instance called by the last asserted process instance and compliant to the given query. May return null in case no such task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one process instance is delivered by the underlying query or in case no process instance was asserted yet.
      • calledProcessInstance

        public static ProcessInstance calledProcessInstance​(ProcessInstanceQuery processInstanceQuery,
                                                            ProcessInstance processInstance)
        Helper method to easily access the only called process instance compliant to a given processInstanceQuery and currently available in the context of the given process instance.
        Parameters:
        processInstanceQuery - the query with which the process instance should be retrieved. This query will be further narrowed to the given process instance.
        processInstance - the process instance for which a called process instance should be retrieved.
        Returns:
        the only such process instance called by the given process instance and compliant to the given query. May return null in case no such process instance exists.
        Throws:
        java.lang.IllegalStateException - in case more than one instance is delivered by the underlying query.
      • job

        public static Job job()
        Helper method to easily access the only job currently available in the context of the last asserted process instance.
        Returns:
        the only job of the last asserted process instance. May return null if no such job exists.
        Throws:
        java.lang.IllegalStateException - in case more than one job is delivered by the underlying query or in case no process instance was asserted yet.
      • job

        public static Job job​(ProcessInstance processInstance)
        Helper method to easily access the only job currently available in the context of the given process instance.
        Parameters:
        processInstance - the process instance for which a job should be retrieved.
        Returns:
        the only job of the process instance. May return null if no such task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one job is delivered by the underlying query.
      • job

        public static Job job​(java.lang.String activityId)
        Helper method to easily access the only job with the given activityId currently available in the context of the last asserted process instance.
        Parameters:
        activityId - the id of the job that should be retrieved.
        Returns:
        the only job of the last asserted process instance. May return null if no such job exists.
        Throws:
        java.lang.IllegalStateException - in case more than one job is delivered by the underlying query or in case no process instance was asserted yet.
      • job

        public static Job job​(java.lang.String activityId,
                              ProcessInstance processInstance)
        Helper method to easily access the only job with the given activityId currently available in the context of the given process instance.
        Parameters:
        activityId - the activityId of the job that should be retrieved.
        processInstance - the process instance for which a job should be retrieved.
        Returns:
        the only job of the given process instance. May return null if no such job exists.
        Throws:
        java.lang.IllegalStateException - in case more than one job is delivered by the underlying query.
      • job

        public static Job job​(JobQuery jobQuery)
        Helper method to easily access the only job compliant to a given jobQuery and currently available in the context of the last asserted process instance.
        Parameters:
        jobQuery - the query with which the job should be retrieved. This query will be further narrowed to the last asserted process instance.
        Returns:
        the only job of the last asserted process instance and compliant to the given query. May return null in case no such task exists.
        Throws:
        java.lang.IllegalStateException - in case more than one job is delivered by the underlying query or in case no process instance was asserted yet.
      • job

        public static Job job​(JobQuery jobQuery,
                              ProcessInstance processInstance)
        Helper method to easily access the only job compliant to a given jobQuery and currently available in the context of the given process instance.
        Parameters:
        jobQuery - the query with which the job should be retrieved. This query will be further narrowed to the given process instance.
        processInstance - the process instance for which a job should be retrieved.
        Returns:
        the only job of the given process instance and compliant to the given query. May return null in case no such job exists.
        Throws:
        java.lang.IllegalStateException - in case more than one job is delivered by the underlying query.
      • claim

        public static Task claim​(Task task,
                                 java.lang.String assigneeUserId)
        Helper method to easily claim a task for a specific assignee.
        Parameters:
        task - Task to be claimed for an assignee
        assigneeUserId - userId of assignee for which the task should be claimed
        Returns:
        the assigned task - properly refreshed to its assigned state.
      • unclaim

        public static Task unclaim​(Task task)
        Helper method to easily unclaim a task.
        Parameters:
        task - Task to be claimed for an assignee
        Returns:
        the assigned task - properly refreshed to its unassigned state.
      • complete

        public static void complete​(Task task,
                                    java.util.Map<java.lang.String,​java.lang.Object> variables)
        Helper method to easily complete a task and pass some process variables.
        Parameters:
        task - Task to be completed
        variables - Process variables to be passed to the process instance when completing the task. For setting those variables, you can use withVariables(String key, Object value, ...)
      • complete

        public static void complete​(Task task)
        Helper method to easily complete a task.
        Parameters:
        task - Task to be completed
      • complete

        public static void complete​(ExternalTask externalTask)
        Helper method to easily fetch, lock and complete an external task.

        Note: if multiple external tasks exist that can be locked for the topic of the given external task, this method might throw an IllegalStateException if an external task with a different id is locked by chance. In this case, it is more advisable to use the fetchAndLock and complete(LockedExternalTask) methods to achieve reliable results.

        Parameters:
        externalTask - External task to be completed
      • complete

        public static void complete​(ExternalTask externalTask,
                                    java.util.Map<java.lang.String,​java.lang.Object> variables)
        Helper method to easily fetch, lock and complete an external task.

        Note: if multiple external tasks exist that can be locked for the topic of the given external task, this method might throw an IllegalStateException if an external task with a different id is locked by chance. In this case, it is more advisable to use the fetchAndLock and complete(LockedExternalTask, Map) methods to achieve reliable results.

        Parameters:
        externalTask - External task to be completed
        variables - Process variables to be passed to the process instance when completing the task. For setting those variables, you can use withVariables(String key, Object value, ...)
      • fetchAndLock

        public static java.util.List<LockedExternalTask> fetchAndLock​(java.lang.String topic,
                                                                      java.lang.String workerId,
                                                                      int maxResults)
        Helper method to easily fetch and lock external tasks from a given topic using a given workerId. The tasks will be locked for DEFAULT_LOCK_DURATION_EXTERNAL_TASK milliseconds.
        Parameters:
        topic - the name of the topic to query external tasks from
        workerId - the id of the worker to lock the tasks for
        maxResults - the maximum number of tasks to return
        Returns:
        list of external tasks locked for the given workerId
      • complete

        public static void complete​(LockedExternalTask lockedExternalTask)
        Helper method to easily complete a locked external task.
        Parameters:
        lockedExternalTask - an external task that was locked using the fetchAndLock method
      • complete

        public static void complete​(LockedExternalTask lockedExternalTask,
                                    java.util.Map<java.lang.String,​java.lang.Object> variables)
        Helper method to easily complete a locked external task.
        Parameters:
        lockedExternalTask - an external task that was locked using the fetchAndLock method
        variables - Process variables to be passed to the process instance when completing the task. For setting those variables, you can use withVariables(String key, Object value, ...)
      • execute

        public static void execute​(Job job)
        Helper method to easily execute a job.
        Parameters:
        job - Job to be executed.
      • findId

        public static java.lang.String findId​(java.lang.String name)
        Maps any element (task, event, gateway) from the name to the ID.
        Parameters:
        name -
        Returns:
        the ID of the element