Java Code Examples for org.camunda.bpm.engine.runtime.ProcessInstance#getProcessDefinitionId()
The following examples show how to use
org.camunda.bpm.engine.runtime.ProcessInstance#getProcessDefinitionId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessInstanceAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testSuspendProcessInstanceByProcessDefinitionId() { // given ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY); String processInstanceId = instance.getId(); String processDefinitionId = instance.getProcessDefinitionId(); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE, SUSPEND); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE, SUSPEND_INSTANCE); // when runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId); // then instance = selectSingleProcessInstance(); assertTrue(instance.isSuspended()); }
Example 2
Source File: ProcessInstanceAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testActivateProcessInstanceByProcessDefinitionIdWithSuspendPermissionOnProcessInstance() { // given ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY); String processInstanceId = instance.getId(); String processDefinitionId = instance.getProcessDefinitionId(); suspendProcessInstanceById(processInstanceId); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, SUSPEND); try { // when runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId); fail("Exception expected: It should not be posssible to suspend a process instance."); } catch (AuthorizationException e) { // then String message = e.getMessage(); assertTextPresent(userId, message); assertTextPresent(UPDATE_INSTANCE.getName(), message); assertTextPresent(SUSPEND_INSTANCE.getName(), message); assertTextPresent(PROCESS_KEY, message); assertTextPresent(PROCESS_DEFINITION.resourceName(), message); assertTextPresent(SUSPEND.getName(), message); assertTextPresent(UPDATE.getName(), message); } }
Example 3
Source File: ProcessInstanceAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testActivateProcessInstanceByProcessDefinitionIdWithUpdateInstancesPermissionOnProcessDefinition() { // given ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY); String processInstanceId = instance.getId(); String processDefinitionId = instance.getProcessDefinitionId(); suspendProcessInstanceById(processInstanceId); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE); // when runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId); // then instance = selectSingleProcessInstance(); assertFalse(instance.isSuspended()); }
Example 4
Source File: ProcessInstanceAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testActivateProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnAnyProcessInstance() { // given ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY); String processInstanceId = instance.getId(); String processDefinitionId = instance.getProcessDefinitionId(); suspendProcessInstanceById(processInstanceId); createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE); // when runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId); // then instance = selectSingleProcessInstance(); assertFalse(instance.isSuspended()); }
Example 5
Source File: ProcessInstanceAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testActivateProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnProcessInstance() { // given ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY); String processInstanceId = instance.getId(); String processDefinitionId = instance.getProcessDefinitionId(); suspendProcessInstanceById(processInstanceId); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE); try { // when runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId); fail("Exception expected: It should not be posssible to suspend a process instance."); } catch (AuthorizationException e) { // then String message = e.getMessage(); assertTextPresent(userId, message); assertTextPresent(UPDATE_INSTANCE.getName(), message); assertTextPresent(SUSPEND_INSTANCE.getName(), message); assertTextPresent(PROCESS_KEY, message); assertTextPresent(PROCESS_DEFINITION.resourceName(), message); assertTextPresent(SUSPEND.getName(), message); assertTextPresent(UPDATE.getName(), message); } }
Example 6
Source File: ProcessInstanceAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testSuspendProcessInstanceByProcessDefinitionIdWithSuspendPermissionOnProcessInstance() { // given ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY); String processInstanceId = instance.getId(); String processDefinitionId = instance.getProcessDefinitionId(); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, SUSPEND); try { // when runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId); fail("Exception expected: It should not be posssible to suspend a process instance."); } catch (AuthorizationException e) { // then String message = e.getMessage(); assertTextPresent(userId, message); assertTextPresent(UPDATE_INSTANCE.getName(), message); assertTextPresent(SUSPEND_INSTANCE.getName(), message); assertTextPresent(PROCESS_KEY, message); assertTextPresent(PROCESS_DEFINITION.resourceName(), message); assertTextPresent(SUSPEND.getName(), message); assertTextPresent(UPDATE.getName(), message); } }
Example 7
Source File: ProcessInstanceAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testSuspendProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnProcessInstance() { // given ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY); String processInstanceId = instance.getId(); String processDefinitionId = instance.getProcessDefinitionId(); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE); try { // when runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId); fail("Exception expected: It should not be posssible to suspend a process instance."); } catch (AuthorizationException e) { // then String message = e.getMessage(); assertTextPresent(userId, message); assertTextPresent(UPDATE_INSTANCE.getName(), message); assertTextPresent(SUSPEND_INSTANCE.getName(), message); assertTextPresent(PROCESS_KEY, message); assertTextPresent(PROCESS_DEFINITION.resourceName(), message); assertTextPresent(SUSPEND.getName(), message); assertTextPresent(UPDATE.getName(), message); } }
Example 8
Source File: ExternalTaskServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityProcess.bpmn20.xml" }) public void testFetchByProcessDefinitionIds() { // given ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess"); String processDefinitionId1 = processInstance1.getProcessDefinitionId(); ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskWithPriorityProcess"); String processDefinitionId2 = processInstance2.getProcessDefinitionId(); // when List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(1, WORKER_ID) .topic(TOPIC_NAME, LOCK_TIME) .processDefinitionId(processDefinitionId2) .processDefinitionIdIn(processDefinitionId1) .execute(); // then assertEquals(0, externalTasks.size()); }
Example 9
Source File: ExternalTaskServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityProcess.bpmn20.xml" }) public void testFetchByProcessDefinitionId() { // given runtimeService.startProcessInstanceByKey("oneExternalTaskProcess"); ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskWithPriorityProcess"); String processDefinitionId2 = processInstance2.getProcessDefinitionId(); // when List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(1, WORKER_ID) .topic(TOPIC_NAME, LOCK_TIME) .processDefinitionId(processDefinitionId2) .execute(); // then assertEquals(1, externalTasks.size()); assertEquals(processDefinitionId2, externalTasks.get(0).getProcessDefinitionId()); }
Example 10
Source File: ProcessInstanceAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testSuspendProcessInstanceByProcessDefinitionIdWithUpdateInstancesPermissionOnProcessDefinition() { // given ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY); String processDefinitionId = instance.getProcessDefinitionId(); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE); // when runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId); // then instance = selectSingleProcessInstance(); assertTrue(instance.isSuspended()); }
Example 11
Source File: RestartProcessInstanceBatchScenario.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@DescribesScenario("initRestartProcessInstanceBatch") public static ScenarioSetup initRestartProcessInstanceBatch() { return new ScenarioSetup() { public void execute(ProcessEngine engine, String scenarioName) { List<String> processInstanceIds = new ArrayList<>(); String processDefinitionId = null; for (int i = 0; i < 10; i++) { ProcessInstance processInstance = engine.getRuntimeService() .startProcessInstanceByKey("oneTaskProcessRestart_710", "RestartProcessInstanceBatchScenario"); processDefinitionId = processInstance.getProcessDefinitionId(); processInstanceIds.add(processInstance.getId()); String taskId = engine.getTaskService().createTaskQuery() .processDefinitionKey("oneTaskProcessRestart_710") .processInstanceBusinessKey("RestartProcessInstanceBatchScenario") .singleResult() .getId(); engine.getTaskService().complete(taskId); } Batch batch = engine.getRuntimeService().restartProcessInstances(processDefinitionId) .startBeforeActivity("theTask") .processInstanceIds(processInstanceIds) .skipCustomListeners() .skipIoMappings() .withoutBusinessKey() .executeAsync(); engine.getManagementService().setProperty("RestartProcessInstanceBatchScenario.batchId", batch.getId()); } }; }
Example 12
Source File: ProcessInstanceAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testSuspendProcessInstanceByProcessDefinitionIdWithSuspendInstancesPermissionOnProcessDefinition() { // given ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY); String processDefinitionId = instance.getProcessDefinitionId(); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, SUSPEND_INSTANCE); // when runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId); // then instance = selectSingleProcessInstance(); assertTrue(instance.isSuspended()); }
Example 13
Source File: ProcessInstanceDto.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public ProcessInstanceDto(ProcessInstance instance) { this.id = instance.getId(); this.definitionId = instance.getProcessDefinitionId(); this.businessKey = instance.getBusinessKey(); this.caseInstanceId = instance.getCaseInstanceId(); this.ended = instance.isEnded(); this.suspended = instance.isSuspended(); this.tenantId = instance.getTenantId(); }
Example 14
Source File: CustomHistoryEventHandlerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml") public void shouldReceiveMigrateEvents() { // given VariableMap variables = Variables.createVariables().putValue("foo", "bar"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables); String processDefinitionId = processInstance.getProcessDefinitionId(); String processInstanceId = processInstance.getId(); Task task = taskService.createTaskQuery().singleResult(); ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstanceId).getActivityInstances("theTask")[0]; MigrationPlan migrationPlan = runtimeService.createMigrationPlan(processDefinitionId, processDefinitionId).mapEqualActivities().build(); recorderHandler.clear(); // when runtimeService.newMigration(migrationPlan).processInstanceIds(processInstanceId).execute(); // then // one process instance, one activity instance, one task instance, one variable instance assertThat(recorderHandler.size()).isEqualTo(4); List<HistoryEvent> processInstanceEvents = recorderHandler.getEventsForEntity(processInstanceId); assertThat(processInstanceEvents).hasSize(1); assertThat(processInstanceEvents.get(0).getEventType()).isEqualTo(HistoryEventTypes.PROCESS_INSTANCE_MIGRATE.getEventName()); List<HistoryEvent> activityInstanceEvents = recorderHandler.getEventsForEntity(activityInstance.getId()); assertThat(activityInstanceEvents).hasSize(1); assertThat(activityInstanceEvents.get(0).getEventType()).isEqualTo(HistoryEventTypes.ACTIVITY_INSTANCE_MIGRATE.getEventName()); List<HistoryEvent> taskEvents = recorderHandler.getEventsForEntity(task.getId()); assertThat(taskEvents).hasSize(1); assertThat(taskEvents.get(0).getEventType()).isEqualTo(HistoryEventTypes.TASK_INSTANCE_MIGRATE.getEventName()); List<HistoryEvent> variableEvents = recorderHandler.getEventsForEntity(null); // variable events currently have no id set assertThat(variableEvents).hasSize(1); assertThat(variableEvents.get(0).getEventType()).isEqualTo(HistoryEventTypes.VARIABLE_INSTANCE_MIGRATE.getEventName()); }
Example 15
Source File: ExternalTaskServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/parallelExternalTaskProcess.bpmn20.xml") public void testFetchByProcessDefinitionIdAndKey() { // given String topicName1 = "topic1"; String topicName2 = "topic2"; String businessKey1 = "testBusinessKey1"; String businessKey2 = "testBusinessKey2"; String businessKey3 = "testBusinessKey3"; Long lockDuration = 60L * 1000L; runtimeService.startProcessInstanceByKey("parallelExternalTaskProcess", businessKey1); ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("parallelExternalTaskProcess", businessKey2); String processDefinitionId2 = processInstance2.getProcessDefinitionId(); ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("parallelExternalTaskProcess", businessKey3); String processDefinitionId3 = processInstance3.getProcessDefinitionId(); //when List<LockedExternalTask> topicTasks = externalTaskService .fetchAndLock(3, "externalWorkerId") .topic(topicName1, lockDuration) .topic(topicName2, lockDuration) .processDefinitionIdIn(processDefinitionId2, processDefinitionId3) .topic("topic3", lockDuration) .processDefinitionIdIn("unexisting") .execute(); //then assertEquals(3, topicTasks.size()); for (LockedExternalTask externalTask : topicTasks) { ProcessInstance pi = runtimeService.createProcessInstanceQuery() .processInstanceId(externalTask.getProcessInstanceId()) .singleResult(); if (externalTask.getTopicName().equals(topicName1)) { assertEquals(pi.getProcessDefinitionId(), externalTask.getProcessDefinitionId()); } else if (externalTask.getTopicName().equals(topicName2)){ assertEquals(processDefinitionId2, pi.getProcessDefinitionId()); assertEquals(processDefinitionId2, externalTask.getProcessDefinitionId()); } else { fail("No other topic name values should be available!"); } } }
Example 16
Source File: UserOperationLogQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources = {ONE_TASK_PROCESS}) public void testQueryJobDefinitionOperationWithDelayedJobDefinition() { // given // a running process instance ProcessInstance process = runtimeService.startProcessInstanceByKey("oneTaskProcess"); // with a process definition id String processDefinitionId = process.getProcessDefinitionId(); // ...which will be suspended with the corresponding jobs managementService.suspendJobDefinitionByProcessDefinitionId(processDefinitionId, true); // one week from now ClockUtil.setCurrentTime(today); long oneWeekFromStartTime = today.getTime() + (7 * 24 * 60 * 60 * 1000); // when // activate the job definition managementService.activateJobDefinitionByProcessDefinitionId(processDefinitionId, false, new Date(oneWeekFromStartTime)); // then // there is a user log entry for the activation Long jobDefinitionEntryCount = query() .entityType(JOB_DEFINITION) .operationType(UserOperationLogEntry.OPERATION_TYPE_ACTIVATE_JOB_DEFINITION) .processDefinitionId(processDefinitionId) .category(UserOperationLogEntry.CATEGORY_OPERATOR) .count(); assertEquals(1, jobDefinitionEntryCount.longValue()); // there exists a job for the delayed activation execution JobQuery jobQuery = managementService.createJobQuery(); Job delayedActivationJob = jobQuery.timers().active().singleResult(); assertNotNull(delayedActivationJob); // execute job managementService.executeJob(delayedActivationJob.getId()); jobDefinitionEntryCount = query() .entityType(JOB_DEFINITION) .operationType(UserOperationLogEntry.OPERATION_TYPE_ACTIVATE_JOB_DEFINITION) .processDefinitionId(processDefinitionId) .category(UserOperationLogEntry.CATEGORY_OPERATOR) .count(); assertEquals(1, jobDefinitionEntryCount.longValue()); // Clean up db CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired(); commandExecutor.execute(new Command<Object>() { public Object execute(CommandContext commandContext) { commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerActivateJobDefinitionHandler.TYPE); return null; } }); }
Example 17
Source File: WorkflowEngineService.java From wecube-platform with Apache License 2.0 | 4 votes |
public ProcInstOutline getProcInstOutline(String procInstId) { if (procInstId == null) { throw new WecubeCoreException("Process instance is null."); } ProcessInstanceStatusEntity procInstStatusEntity = processInstanceStatusRepository .findOneByprocInstanceId(procInstId); if (procInstStatusEntity == null) { log.warn("cannot find such process instance record with procInstId={}", procInstId); throw new WecubeCoreException("Such process instance record does not exist."); } String processInstanceId = null; String processDefinitionId = null; if (TraceStatus.Completed.equals(procInstStatusEntity.getStatus())) { processInstanceId = procInstStatusEntity.getProcInstanceId(); processDefinitionId = procInstStatusEntity.getProcDefinitionId(); } else { ProcessInstance existProcInst = getProcessInstanceByProcInstId(procInstId); if (existProcInst == null) { log.warn("such process instance does not exist,procInstId={}", procInstId); throw new WecubeCoreException("Such process instance does not exist."); } processInstanceId = existProcInst.getId(); processDefinitionId = existProcInst.getProcessDefinitionId(); } ProcessDefinition procDef = getProcessDefinitionByProcId(processDefinitionId); if (procDef == null) { log.warn("such process definition does not exist,procDefId={}", processDefinitionId); throw new WecubeCoreException("Such process definition does not exist."); } BpmnModelInstance bpmnModel = repositoryService.getBpmnModelInstance(procDef.getId()); Collection<org.camunda.bpm.model.bpmn.instance.Process> processes = bpmnModel .getModelElementsByType(org.camunda.bpm.model.bpmn.instance.Process.class); org.camunda.bpm.model.bpmn.instance.Process process = processes.iterator().next(); Collection<StartEvent> startEvents = process.getChildElementsByType(StartEvent.class); StartEvent startEvent = startEvents.iterator().next(); ProcInstOutline result = new ProcInstOutline(); result.setId(processInstanceId); result.setProcInstKey(procInstStatusEntity.getProcInstanceBizKey()); result.setProcDefKernelId(procDef.getId()); result.setProcDefKey(procDef.getKey()); result.setProcDefName(procDef.getName()); populateFlowNodeInsts(result, startEvent); refreshFlowNodeStatus(result); return result; }
Example 18
Source File: SingleProcessInstanceModificationAsyncAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources = PARALLEL_GATEWAY_PROCESS) public void testModificationWithAllPermissions() { // given createGrantAuthorization(PROCESS_DEFINITION, "parallelGateway", userId, CREATE_INSTANCE, READ_INSTANCE, UPDATE_INSTANCE); createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, CREATE); createGrantAuthorization(BATCH, ANY, userId, CREATE); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("parallelGateway"); String processInstanceId = processInstance.getId(); String processDefinitionId = processInstance.getProcessDefinitionId(); disableAuthorization(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult(); enableAuthorization(); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); // when Batch modificationBatch = runtimeService .createProcessInstanceModification(processInstance.getId()) .cancelActivityInstance(getInstanceIdForActivity(tree, "task1")) .executeAsync(); assertNotNull(modificationBatch); Job job = managementService.createJobQuery().jobDefinitionId(modificationBatch.getSeedJobDefinitionId()).singleResult(); // seed job managementService.executeJob(job.getId()); // then for (Job pending : managementService.createJobQuery().jobDefinitionId(modificationBatch.getBatchJobDefinitionId()).list()) { managementService.executeJob(pending.getId()); assertEquals(processDefinition.getDeploymentId(), pending.getDeploymentId()); } ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task2").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree("task2").scope().done()); // complete the process disableAuthorization(); completeTasksInOrder("task2"); assertProcessEnded(processInstanceId); enableAuthorization(); }
Example 19
Source File: ProcessInstanceSnapshotBuilder.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public ProcessInstanceSnapshotBuilder(ProcessInstance processInstance, ProcessEngine processEngine) { this.processEngine = processEngine; this.processInstanceId = processInstance.getId(); this.snapshot = new ProcessInstanceSnapshot(processInstance.getId(), processInstance.getProcessDefinitionId()); }
Example 20
Source File: MultiTenancySingleProcessInstanceModificationAsyncTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Test public void testModificationSameTenant() { // given testRule.deployForTenant(TENANT_ONE, PARALLEL_GATEWAY_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("parallelGateway"); String processInstanceId = processInstance.getId(); String processDefinitionId = processInstance.getProcessDefinitionId(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult(); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); // when Batch modificationBatch = runtimeService.createProcessInstanceModification(processInstance.getId()) .cancelActivityInstance(getInstanceIdForActivity(tree, "task1")) .executeAsync(); assertNotNull(modificationBatch); assertEquals(TENANT_ONE, modificationBatch.getTenantId()); Job job = managementService.createJobQuery().jobDefinitionId(modificationBatch.getSeedJobDefinitionId()).singleResult(); // seed job assertEquals(TENANT_ONE, job.getTenantId()); managementService.executeJob(job.getId()); for (Job pending : managementService.createJobQuery().jobDefinitionId(modificationBatch.getBatchJobDefinitionId()).list()) { managementService.executeJob(pending.getId()); assertEquals(processDefinition.getDeploymentId(), pending.getDeploymentId()); assertEquals(TENANT_ONE, pending.getTenantId()); } // when ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task2").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngineConfiguration.getProcessEngine()); assertThat(executionTree).matches(describeExecutionTree("task2").scope().done()); // complete the process completeTasksInOrder("task2"); assertProcessEnded(processInstanceId); }