Class BpmnAwareTests

java.lang.Object
org.camunda.bpm.engine.test.assertions.bpmn.AbstractAssertions
org.camunda.bpm.engine.test.assertions.bpmn.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:
  • Field Details

    • DEFAULT_LOCK_DURATION_EXTERNAL_TASK

      public static final long DEFAULT_LOCK_DURATION_EXTERNAL_TASK
      See Also:
    • DEFAULT_WORKER_EXTERNAL_TASK

      public static final String DEFAULT_WORKER_EXTERNAL_TASK
      See Also:
  • Constructor Details

    • BpmnAwareTests

      protected BpmnAwareTests()
  • Method Details

    • 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:
    • authorizationService

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

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

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

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

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

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

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

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

      public static DecisionService decisionService()
      Helper method to easily access DecisionService
      Returns:
      DecisionService of process engine bound to this testing thread
      See Also:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • withVariables

      public static Map<String,Object> withVariables(String key, Object value, 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:
      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:
      IllegalStateException - in case more than one task is delivered by the underlying query.
    • task

      public static Task task(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:
      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(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:
      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:
      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:
      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:
      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:
      IllegalStateException - in case more than one external task is delivered by the underlying query.
    • externalTask

      public static ExternalTask externalTask(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:
      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(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:
      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:
      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:
      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:
      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(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:
      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:
      IllegalStateException - in case more than one process instance is delivered by the underlying query.
    • calledProcessInstance

      public static ProcessInstance calledProcessInstance(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:
      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(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:
      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:
      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:
      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:
      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:
      IllegalStateException - in case more than one job is delivered by the underlying query.
    • job

      public static Job job(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:
      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(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:
      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:
      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:
      IllegalStateException - in case more than one job is delivered by the underlying query.
    • claim

      public static Task claim(Task task, 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, Map<String,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, Map<String,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, ...)
    • complete

      public static void complete(ExternalTask externalTask, Map<String,Object> variables, Map<String,Object> localVariables)
      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, ...)
      localVariables - Local 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 List<LockedExternalTask> fetchAndLock(String topic, 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, Map<String,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, ...)
    • complete

      public static void complete(LockedExternalTask lockedExternalTask, Map<String,Object> variables, Map<String,Object> localVariables)
      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, ...)
      localVariables - Local 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 String findId(String name)
      Maps any element (task, event, gateway) from the name to the ID.
      Parameters:
      name -
      Returns:
      the ID of the element