Java Code Examples for org.camunda.bpm.engine.runtime.ProcessInstance#getId()
The following examples show how to use
org.camunda.bpm.engine.runtime.ProcessInstance#getId() .
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: ProcessInstanceModificationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS) public void testStartTransition() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway"); String processInstanceId = processInstance.getId(); runtimeService.createProcessInstanceModification(processInstance.getId()).startTransition("flow4").execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task1").activity("task2").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().done()); assertEquals(2, taskService.createTaskQuery().count()); // complete the process completeTasksInOrder("task1", "task2"); assertProcessEnded(processInstanceId); }
Example 2
Source File: SignalEventReceivedBuilderTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testNoSignalEventSubscriptionWithExecutionId() { deployment(Bpmn.createExecutableProcess("noSignal") .startEvent() .userTask() .endEvent() .done()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("noSignal"); String executionId = processInstance.getId(); try { runtimeService.createSignalEvent("signal").executionId(executionId).send(); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Execution '" + executionId + "' has not subscribed to a signal event with name 'signal'")); } }
Example 3
Source File: ProcessInstanceModificationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS) public void testStartBefore() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway"); String processInstanceId = processInstance.getId(); runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("task2").execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task1").activity("task2").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().done()); assertEquals(2, taskService.createTaskQuery().count()); // complete the process completeTasksInOrder("task1", "task2"); assertProcessEnded(processInstanceId); }
Example 4
Source File: ProcessInstanceModificationCancellationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = ONE_TASK_PROCESS) public void testCancelAllInOneTaskProcess() { // given ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); String processInstanceId = processInstance.getId(); // two instance of theTask runtimeService.createProcessInstanceModification(processInstanceId) .startBeforeActivity("theTask") .execute(); // when runtimeService .createProcessInstanceModification(processInstanceId) .cancelAllForActivity("theTask") .execute(); assertProcessEnded(processInstanceId); }
Example 5
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 6
Source File: ProcessInstanceModificationBoundaryEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = INTERRUPTING_BOUNDARY_EVENT_INSIDE_SUBPROCESS) public void testTask1AndStartBeforeTaskAfterBoundaryEventInsideSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); String processInstanceId = processInstance.getId(); runtimeService .createProcessInstanceModification(processInstanceId) .startBeforeActivity("innerTaskAfterBoundaryEvent") .execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .beginScope("subProcess") .activity("innerTask1") .activity("innerTaskAfterBoundaryEvent") .done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree(null).scope() .child(null).scope() .child("innerTaskAfterBoundaryEvent").concurrent().noScope().up() .child(null).concurrent().noScope() .child("innerTask1").scope() .done()); completeTasksInOrder("innerTask1", "innerTaskAfterBoundaryEvent", "innerTask2"); assertProcessEnded(processInstanceId); }
Example 7
Source File: ProcessInstanceModificationEventSubProcessTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = NON_INTERRUPTING_EVENT_SUBPROCESS_INSIDE_SUBPROCESS) public void testStartBeforeStartEventInsideNonInterruptingEventSubProcessInsideSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); String processInstanceId = processInstance.getId(); runtimeService .createProcessInstanceModification(processInstanceId) .startBeforeActivity("eventProcessStart") .execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .activity("task1") .beginScope("subProcess") .beginScope("eventSubProcess") .activity("eventSubProcessTask") .done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree(null).scope() .child("task1").concurrent().noScope().up() .child(null).concurrent().noScope() .child(null).scope() .child("eventSubProcessTask").scope() .done()); completeTasksInOrder("task1", "task2", "eventSubProcessTask"); assertProcessEnded(processInstanceId); }
Example 8
Source File: ProcessInstanceModificationEventSubProcessTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = NON_INTERRUPTING_EVENT_SUBPROCESS_INSIDE_SUBPROCESS) public void testStartBeforeNonInterruptingEventSubProcessInsideSubProcessTask2ShouldStay() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); String processInstanceId = processInstance.getId(); String taskId = taskService.createTaskQuery().singleResult().getId(); taskService.complete(taskId); runtimeService .createProcessInstanceModification(processInstanceId) .startBeforeActivity("eventSubProcess") .execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .beginScope("subProcess") .activity("task2") .beginScope("eventSubProcess") .activity("eventSubProcessTask") .done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree(null).scope() .child(null).scope() .child("task2").concurrent().noScope().up() .child(null).concurrent().noScope() .child("eventSubProcessTask").scope() .done()); completeTasksInOrder("task2", "eventSubProcessTask"); assertProcessEnded(processInstanceId); }
Example 9
Source File: ProcessInstanceModificationCancellationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = NESTED_PARALLEL_ONE_TASK_PROCESS) public void testScopeCancellationInNestedOneTaskProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedOneTaskProcess"); String processInstanceId = processInstance.getId(); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); runtimeService .createProcessInstanceModification(processInstance.getId()) .cancelActivityInstance(getInstanceIdForActivity(tree, "subProcess")) .execute(); assertProcessNotEnded(processInstanceId); // assert activity instance ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .activity("outerTask") .done()); // assert executions ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree("outerTask").scope() .done()); // assert successful completion of process Task task = taskService.createTaskQuery().singleResult(); taskService.complete(task.getId()); assertProcessEnded(processInstanceId); }
Example 10
Source File: ProcessInstanceModificationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = SUBPROCESS_LISTENER_PROCESS) public void testSkipListenerInvocation() { RecorderExecutionListener.clear(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subprocess", Collections.<String, Object> singletonMap("listener", new RecorderExecutionListener())); String processInstanceId = processInstance.getId(); assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty()); // when I start an activity with "skip listeners" setting runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("innerTask").execute(true, false); // then no listeners are invoked assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty()); // when I cancel an activity with "skip listeners" setting ActivityInstance activityInstanceTree = runtimeService.getActivityInstance(processInstanceId); runtimeService.createProcessInstanceModification(processInstance.getId()) .cancelActivityInstance(getChildInstanceForActivity(activityInstanceTree, "innerTask").getId()).execute(true, false); // then no listeners are invoked assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty()); // when I cancel an activity that ends the process instance runtimeService.createProcessInstanceModification(processInstance.getId()) .cancelActivityInstance(getChildInstanceForActivity(activityInstanceTree, "outerTask").getId()).execute(true, false); // then no listeners are invoked assertTrue(RecorderExecutionListener.getRecordedEvents().isEmpty()); }
Example 11
Source File: ProcessInstanceModificationBoundaryEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = NON_INTERRUPTING_BOUNDARY_EVENT_ON_SUBPROCESS) public void testStartBeforeTaskAfterNonInterruptingBoundaryEventOnSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); String processInstanceId = processInstance.getId(); runtimeService .createProcessInstanceModification(processInstanceId) .startBeforeActivity("taskAfterBoundaryEvent") .execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .beginScope("subProcess") .activity("innerTask") .endScope() .activity("taskAfterBoundaryEvent") .done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree(null).scope() .child("taskAfterBoundaryEvent").concurrent().noScope().up() .child(null).concurrent().noScope() .child("innerTask").scope() .done()); completeTasksInOrder("innerTask", "taskAfterBoundaryEvent"); assertProcessEnded(processInstanceId); }
Example 12
Source File: ProcessInstanceModificationBoundaryEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = NON_INTERRUPTING_BOUNDARY_EVENT_INSIDE_SUBPROCESS) public void testTask1AndStartBeforeTaskAfterNonInterruptingBoundaryEventInsideSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); String processInstanceId = processInstance.getId(); runtimeService .createProcessInstanceModification(processInstanceId) .startBeforeActivity("innerTaskAfterBoundaryEvent") .execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .beginScope("subProcess") .activity("innerTask1") .activity("innerTaskAfterBoundaryEvent") .done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree(null).scope() .child(null).scope() .child("innerTaskAfterBoundaryEvent").concurrent().noScope().up() .child(null).concurrent().noScope() .child("innerTask1").scope() .done()); completeTasksInOrder("innerTask1", "innerTaskAfterBoundaryEvent", "innerTask2"); assertProcessEnded(processInstanceId); }
Example 13
Source File: ProcessInstanceModificationCancellationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = NESTED_PARALLEL_CONCURRENT_SCOPE_TASKS_PROCESS) public void testScopeCancellationInNestedConcurrentScopeTasksProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedParallelGatewayScopeTasks"); String processInstanceId = processInstance.getId(); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); runtimeService .createProcessInstanceModification(processInstance.getId()) .cancelActivityInstance(getInstanceIdForActivity(tree, "subProcess")) .execute(); assertProcessNotEnded(processInstanceId); // assert activity instance ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .activity("outerTask") .done()); // assert executions ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree("outerTask").scope() .done()); // assert successful completion of process Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); taskService.complete(task.getId()); assertProcessEnded(processInstanceId); }
Example 14
Source File: ProcessInstanceModificationCancellationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = NESTED_PARALLEL_ONE_SCOPE_TASK_PROCESS) public void testScopeCancellationInNestedOneScopeTaskProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedOneScopeTaskProcess"); String processInstanceId = processInstance.getId(); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); runtimeService .createProcessInstanceModification(processInstance.getId()) .cancelActivityInstance(getInstanceIdForActivity(tree, "subProcess")) .execute(); assertProcessNotEnded(processInstanceId); // assert activity instance ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .activity("outerTask") .done()); // assert executions ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree("outerTask").scope() .done()); // assert successful completion of process Task task = taskService.createTaskQuery().singleResult(); taskService.complete(task.getId()); assertProcessEnded(processInstanceId); }
Example 15
Source File: ProcessInstanceModificationCancellationTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources = NESTED_PARALLEL_CONCURRENT_PROCESS) public void testCancellationInNestedConcurrentProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedParallelGateway"); String processInstanceId = processInstance.getId(); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); runtimeService .createProcessInstanceModification(processInstance.getId()) .cancelActivityInstance(getInstanceIdForActivity(tree, "innerTask1")) .execute(); assertProcessNotEnded(processInstanceId); // assert activity instance ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .activity("outerTask") .beginScope("subProcess") .activity("innerTask2") .done()); // assert executions ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree(null).scope() .child("outerTask").concurrent().noScope().up() .child(null).concurrent().noScope() .child("innerTask2").scope() .done()); // assert successful completion of process List<Task> tasks = taskService.createTaskQuery().list(); assertEquals(2, tasks.size()); for (Task task : tasks) { taskService.complete(task.getId()); } assertProcessEnded(processInstanceId); }
Example 16
Source File: ProcessInstanceModificationCancellationTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources = NESTED_PARALLEL_ONE_SCOPE_TASK_PROCESS) public void testCreationAndCancellationInNestedOneScopeTaskProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedOneScopeTaskProcess"); String processInstanceId = processInstance.getId(); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); runtimeService .createProcessInstanceModification(processInstance.getId()) .startBeforeActivity("innerTask") .cancelActivityInstance(getInstanceIdForActivity(tree, "innerTask")) .execute(); assertProcessNotEnded(processInstanceId); // assert activity instance ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertTrue(!getInstanceIdForActivity(tree, "innerTask").equals(getInstanceIdForActivity(updatedTree, "innerTask"))); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .activity("outerTask") .beginScope("subProcess") .activity("innerTask") .done()); // assert executions ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree(null).scope() .child("outerTask").concurrent().noScope().up() .child(null).concurrent().noScope() .child(null).scope() .child("innerTask").scope() .done()); // assert successful completion of process List<Task> tasks = taskService.createTaskQuery().list(); assertEquals(2, tasks.size()); for (Task task : tasks) { taskService.complete(task.getId()); } assertProcessEnded(processInstanceId); }
Example 17
Source File: SingleProcessInstanceModificationAsyncTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources = ONE_SCOPE_TASK_PROCESS) public void testScopeTaskStartAfter() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); String processInstanceId = processInstance.getId(); // when starting after the task, essentially nothing changes in the process // instance Batch modificationBatch = runtimeService .createProcessInstanceModification(processInstance.getId()) .startAfterActivity("theTask") .executeAsync(); assertNotNull(modificationBatch); executeSeedAndBatchJobs(modificationBatch); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("theTask").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child("theTask").scope().done()); // when starting after the start event, regular concurrency happens Batch modificationBatch2 = runtimeService.createProcessInstanceModification(processInstance.getId()).startAfterActivity("theStart").executeAsync(); assertNotNull(modificationBatch2); executeSeedAndBatchJobs(modificationBatch2); updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("theTask").activity("theTask").done()); executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).concurrent().noScope().child("theTask").scope().up().up().child(null) .concurrent().noScope().child("theTask").scope().done()); completeTasksInOrder("theTask", "theTask"); assertProcessEnded(processInstanceId); }
Example 18
Source File: ProcessInstanceModificationAsyncTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources = EXCLUSIVE_GATEWAY_ASYNC_BEFORE_TASK_PROCESS) public void testStartBeforeAsync() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway"); String processInstanceId = processInstance.getId(); runtimeService .createProcessInstanceModification(processInstance.getId()) .startBeforeActivity("task2") .execute(); // the task does not yet exist because it is started asynchronously Task task = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult(); assertNull(task); // and there is no activity instance for task2 yet ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .activity("task1") .transition("task2") .done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree) .matches( describeExecutionTree(null).scope() .child("task1").concurrent().noScope().up() .child("task2").concurrent().noScope() .done()); // when the async job is executed Job job = managementService.createJobQuery().singleResult(); assertNotNull(job); executeAvailableJobs(); // then there is the task task = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult(); assertNotNull(task); // and there is an activity instance for task2 updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertThat(updatedTree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .activity("task1") .activity("task2") .done()); completeTasksInOrder("task1", "task2"); assertProcessEnded(processInstanceId); }
Example 19
Source File: HistoryServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) @Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testDeleteAllHistoricVariablesAndDetailsOnRunningInstance() { // given ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS); String executionId = processInstance.getId(); assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey(ONE_TASK_PROCESS).count()); runtimeService.setVariable(executionId, "myVariable", "testValue1"); runtimeService.setVariable(executionId, "myVariable", "testValue2"); runtimeService.setVariable(executionId, "myVariable", "testValue3"); runtimeService.setVariable(executionId, "mySecondVariable", "testValue1"); runtimeService.setVariable(executionId, "mySecondVariable", "testValue2"); VariableInstanceQuery variableQuery = runtimeService.createVariableInstanceQuery().processInstanceIdIn(executionId).variableName("myVariable"); VariableInstanceQuery secondVariableQuery = runtimeService.createVariableInstanceQuery().processInstanceIdIn(executionId).variableName("mySecondVariable"); assertEquals(1L, variableQuery.count()); assertEquals(1L, secondVariableQuery.count()); assertEquals("testValue3", variableQuery.singleResult().getValue()); assertEquals("testValue2", secondVariableQuery.singleResult().getValue()); HistoricVariableInstanceQuery histVariableQuery = historyService.createHistoricVariableInstanceQuery().processInstanceId(executionId) .variableName("myVariable"); HistoricVariableInstanceQuery secondHistVariableQuery = historyService.createHistoricVariableInstanceQuery().processInstanceId(executionId) .variableName("mySecondVariable"); assertEquals(1L, histVariableQuery.count()); assertEquals(1L, secondHistVariableQuery.count()); String variableInstanceId = histVariableQuery.singleResult().getId(); String secondVariableInstanceId = secondHistVariableQuery.singleResult().getId(); HistoricDetailQuery detailsQuery = historyService.createHistoricDetailQuery().processInstanceId(executionId).variableInstanceId(variableInstanceId); HistoricDetailQuery secondDetailsQuery = historyService.createHistoricDetailQuery().processInstanceId(executionId).variableInstanceId(secondVariableInstanceId); assertEquals(3L, detailsQuery.count()); assertEquals(2L, secondDetailsQuery.count()); // when historyService.deleteHistoricVariableInstancesByProcessInstanceId(executionId); // then HistoricVariableInstanceQuery allHistVariableQuery = historyService.createHistoricVariableInstanceQuery().processInstanceId(executionId); HistoricDetailQuery allDetailsQuery = historyService.createHistoricDetailQuery().processInstanceId(executionId); assertEquals(0L, histVariableQuery.count()); assertEquals(0L, secondHistVariableQuery.count()); assertEquals(0L, allHistVariableQuery.count()); assertEquals(0L, detailsQuery.count()); assertEquals(0L, secondDetailsQuery.count()); assertEquals(0L, allDetailsQuery.count()); assertEquals(1L, variableQuery.count()); assertEquals("testValue3", variableQuery.singleResult().getValue()); assertEquals("testValue2", secondVariableQuery.singleResult().getValue()); }
Example 20
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; }