public virtual void testStartBeforeCancelEndEventConcurrent() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); string processInstanceId = processInstance.Id; Task txTask = taskService.createTaskQuery().singleResult(); assertEquals("txTask", txTask.TaskDefinitionKey); // when I start before the cancel end event runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("cancelEnd").execute(); // then the subprocess instance is cancelled ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("afterCancellation").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree("afterCancellation").scope().done()); Task afterCancellationTask = taskService.createTaskQuery().singleResult(); assertNotNull(afterCancellationTask); assertFalse(txTask.Id.Equals(afterCancellationTask.Id)); assertEquals("afterCancellation", afterCancellationTask.TaskDefinitionKey); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testVariableAtConcurrentExecutionAddParentScopeBecomeNonConcurrent() public virtual void testVariableAtConcurrentExecutionAddParentScopeBecomeNonConcurrent() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.PARALLEL_TASK_AND_SUBPROCESS_PROCESS).activityBuilder("subProcess").camundaInputParameter("foo", "subProcessValue").done()); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id); ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine); ExecutionTree task1CcExecution = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0]; ExecutionTree task2CcExecution = executionTreeBeforeMigration.getLeafExecutions("userTask2")[0]; runtimeService.setVariableLocal(task1CcExecution.Id, "foo", "task1Value"); runtimeService.setVariableLocal(task2CcExecution.Id, "foo", "task2Value"); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then the io mapping variable was overwritten due to a compacted execution tree Assert.assertEquals(2, testHelper.snapshotAfterMigration.getVariables().Count); IList <string> values = new List <string>(); foreach (VariableInstance variable in testHelper.snapshotAfterMigration.getVariables()) { values.Add((string)variable.Value); } Assert.assertTrue(values.Contains("task1Value")); Assert.assertTrue(values.Contains("task2Value")); }
public virtual void testStartBeforeIntermediateCatchEvent() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); string processInstanceId = processInstance.Id; runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("intermediateCatchEvent").execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("task").activity("intermediateCatchEvent").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task").concurrent().noScope().up().child(null).concurrent().noScope().child("intermediateCatchEvent").scope().done()); ActivityInstance catchEventInstance = getChildInstanceForActivity(updatedTree, "intermediateCatchEvent"); // and there is a timer job Job job = managementService.createJobQuery().singleResult(); assertNotNull(job); assertEquals(catchEventInstance.ExecutionIds[0], job.ExecutionId); completeTasksInOrder("task"); executeAvailableJobs(); assertProcessEnded(processInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testVariableAtConcurrentAndScopeExecutionBecomeNonScope() public virtual void testVariableAtConcurrentAndScopeExecutionBecomeNonScope() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id); ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine); ExecutionTree scopeExecution = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0]; ExecutionTree concurrentExecution = scopeExecution.Parent; runtimeService.setVariableLocal(scopeExecution.Id, "foo", 42); runtimeService.setVariableLocal(concurrentExecution.Id, "foo", 42); // when try { testHelper.migrateProcessInstance(migrationPlan, processInstance); Assert.fail("expected exception"); } catch (ProcessEngineException e) { Assert.assertThat(e.Message, CoreMatchers.containsString("The variable 'foo' exists in both, this scope" + " and concurrent local in the parent scope. Migrating to a non-scope activity would overwrite one of them.")); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testVariableAtParentScopeExecutionAndScopeExecutionBecomeNonScope() public virtual void testVariableAtParentScopeExecutionAndScopeExecutionBecomeNonScope() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id); ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine); ExecutionTree scopeExecution = executionTreeBeforeMigration.getLeafExecutions("userTask")[0]; runtimeService.setVariableLocal(scopeExecution.Id, "foo", "userTaskScopeValue"); runtimeService.setVariableLocal(processInstance.Id, "foo", "processScopeValue"); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then the process scope variable was overwritten due to a compacted execution tree Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().Count); VariableInstance variable = testHelper.snapshotAfterMigration.getVariables().GetEnumerator().next(); Assert.assertEquals("userTaskScopeValue", variable.Value); }
public virtual void testStartBeforeTimerStartEvent() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); string processInstanceId = processInstance.Id; Job startTimerJob = managementService.createJobQuery().singleResult(); assertNotNull(startTimerJob); // when I start before the timer start event runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("theStart").execute(); // then there are two instances of "task" ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("task").activity("task").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task").concurrent().noScope().up().child("task").concurrent().noScope().done()); // and there is only one timer job Job job = managementService.createJobQuery().singleResult(); assertNotNull(job); assertEquals(startTimerJob.Id, job.Id); completeTasksInOrder("task", "task"); assertProcessEnded(processInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testVariableAtConcurrentExecutionBecomeScope() public virtual void testVariableAtConcurrentExecutionBecomeScope() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_SCOPE_TASKS); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id); ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine); ExecutionTree concurrentExecution = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0]; runtimeService.setVariableLocal(concurrentExecution.Id, "foo", 42); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo"); ExecutionTree userTask1CCExecution = testHelper.snapshotAfterMigration.ExecutionTree.getLeafExecutions("userTask1")[0].Parent; Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().Count); testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1CCExecution.Id); }
public virtual void testCancelInnerActivityParallelTasksAllButOne() { // given ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miParallelUserTasks"); completeTasksInOrder("beforeTask"); // when ActivityInstance tree = runtimeService.getActivityInstance(processInstance.Id); runtimeService.createProcessInstanceModification(processInstance.Id).cancelActivityInstance(tree.getActivityInstances("miTasks")[0].Id).cancelActivityInstance(tree.getActivityInstances("miTasks")[1].Id).execute(); // then tree = runtimeService.getActivityInstance(processInstance.Id); assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).beginMiBody("miTasks").activity("miTasks").endScope().done()); // the execution tree should still be in the expected shape ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.Id, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("miTasks").concurrent().noScope().done()); // and the process is able to complete successfully completeTasksInOrder("miTasks", "afterTask"); assertProcessEnded(processInstance.Id); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testVariableAtConcurrentExecutionInScopeActivityRemoveParentScope() public virtual void testVariableAtConcurrentExecutionInScopeActivityRemoveParentScope() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(SUBPROCESS_CONCURRENT_BOUNDARY_TASKS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id); ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine); ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0].Parent; runtimeService.setVariableLocal(userTask1CCExecutionBefore.Id, "foo", 42); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo"); ExecutionTree userTask1CCExecutionAfter = testHelper.snapshotAfterMigration.ExecutionTree.getLeafExecutions("userTask1")[0].Parent; Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().Count); // for variables at concurrent executions that are parent of a leaf-scope-execution, the activity instance is // the activity instance id of the parent activity instance (which is probably a bug) testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1CCExecutionAfter.Id, processInstance.Id); }
public virtual void testCancellationAndStartBefore() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway"); string processInstanceId = processInstance.Id; ActivityInstance tree = runtimeService.getActivityInstance(processInstance.Id); Batch modificationBatch = runtimeService.createProcessInstanceModification(processInstance.Id).cancelActivityInstance(getInstanceIdForActivity(tree, "task1")).startBeforeActivity("task2").executeAsync(); assertNotNull(modificationBatch); executeSeedAndBatchJobs(modificationBatch); ActivityInstance activityInstanceTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(activityInstanceTree); assertEquals(processInstanceId, activityInstanceTree.ProcessInstanceId); assertThat(activityInstanceTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("task2").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree("task2").scope().done()); completeTasksInOrder("task2"); assertProcessEnded(processInstanceId); }
public virtual void testStartBeforeInnerActivityWithMiBodySequentialSubprocess() { // given the mi body is not yet instantiated ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess"); // when ActivityInstance tree = runtimeService.getActivityInstance(processInstance.Id); runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("subProcessTask").execute(); // then the mi variables should be correct Execution leafExecution = runtimeService.createExecutionQuery().activityId("subProcessTask").singleResult(); assertNotNull(leafExecution); assertVariable(leafExecution, "loopCounter", 0); assertVariable(leafExecution, "nrOfInstances", 1); assertVariable(leafExecution, "nrOfCompletedInstances", 0); assertVariable(leafExecution, "nrOfActiveInstances", 1); // and the trees should be correct tree = runtimeService.getActivityInstance(processInstance.Id); assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("beforeTask").beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").endScope().done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.Id, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child("beforeTask").concurrent().noScope().up().child(null).concurrent().noScope().child(null).scope().child("subProcessTask").scope().done()); // and the process is able to complete successfully completeTasksInOrder("subProcessTask", "afterTask", "beforeTask", "subProcessTask", "subProcessTask", "subProcessTask", "afterTask"); assertProcessEnded(processInstance.Id); }
public virtual void testStartAfterActivityListenerInvocation() { RecorderExecutionListener.clear(); ProcessInstance instance = runtimeService.startProcessInstanceByKey("transitionListenerProcess", Variables.createVariables().putValue("listener", new RecorderExecutionListener())); Batch modificationBatch = runtimeService.createProcessInstanceModification(instance.Id).startTransition("flow2").executeAsync(); assertNotNull(modificationBatch); executeSeedAndBatchJobs(modificationBatch); // transition listener should have been invoked IList <RecorderExecutionListener.RecordedEvent> events = RecorderExecutionListener.RecordedEvents; assertEquals(1, events.Count); RecorderExecutionListener.RecordedEvent @event = events[0]; assertEquals("flow2", @event.TransitionId); RecorderExecutionListener.clear(); ActivityInstance updatedTree = runtimeService.getActivityInstance(instance.Id); assertNotNull(updatedTree); assertEquals(instance.Id, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(instance.ProcessDefinitionId).activity("task1").activity("task2").done()); ExecutionTree executionTree = ExecutionTree.forExecution(instance.Id, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().done()); completeTasksInOrder("task1", "task2", "task2"); assertProcessEnded(instance.Id); }
public virtual void testTask2AndStartBeforeNonInterruptingBoundaryEventInsideSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); string processInstanceId = processInstance.Id; string taskId = taskService.createTaskQuery().singleResult().Id; taskService.complete(taskId); runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("innerBoundaryEvent").execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).beginScope("subProcess").activity("innerTask2").activity("innerTaskAfterBoundaryEvent").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("innerTaskAfterBoundaryEvent").concurrent().noScope().up().child("innerTask2").concurrent().noScope().done()); completeTasksInOrder("innerTask2", "innerTaskAfterBoundaryEvent"); assertProcessEnded(processInstanceId); }
public virtual void testScopeTaskStartBefore() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); string processInstanceId = processInstance.Id; Batch modificationBatch = runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("theTask").executeAsync(); assertNotNull(modificationBatch); executeSeedAndBatchJobs(modificationBatch); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("theTask").activity("theTask").done()); ExecutionTree 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()); assertEquals(2, taskService.createTaskQuery().count()); completeTasksInOrder("theTask", "theTask"); assertProcessEnded(processInstanceId); }
public virtual void testStartBeforeEventSubProcessInsideSubProcessTask2ShouldBeCancelled() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); string processInstanceId = processInstance.Id; string taskId = taskService.createTaskQuery().singleResult().Id; taskService.complete(taskId); runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("eventSubProcess").execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).beginScope("subProcess").beginScope("eventSubProcess").activity("eventSubProcessTask").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("eventSubProcessTask").scope().done()); completeTasksInOrder("eventSubProcessTask"); assertProcessEnded(processInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testVariableAtScopeExecutionBecomeNonScope() public virtual void testVariableAtScopeExecutionBecomeNonScope() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapEqualActivities().build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id); ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine); ExecutionTree scopeExecution = executionTreeBeforeMigration.Executions[0]; runtimeService.setVariableLocal(scopeExecution.Id, "foo", 42); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo"); Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().Count); testHelper.assertVariableMigratedToExecution(beforeMigration, processInstance.Id); // and the variable is concurrent local, i.e. expands on tree expansion runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("userTask").execute(); VariableInstance variableAfterExpansion = runtimeService.createVariableInstanceQuery().singleResult(); Assert.assertNotNull(variableAfterExpansion); Assert.assertNotSame(processInstance.Id, variableAfterExpansion.ExecutionId); }
public virtual void testStartBeforNoneStartEvent() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); string processInstanceId = processInstance.Id; // when I start before the none start event runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("theStart").execute(); // then there are two instances of "task" ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("theTask").activity("theTask").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child("theTask").concurrent().noScope().up().child("theTask").concurrent().noScope().done()); // and the process can be ended as usual IList <Task> tasks = taskService.createTaskQuery().list(); assertEquals(2, tasks.Count); foreach (Task task in tasks) { taskService.complete(task.Id); } assertProcessEnded(processInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCancelConcurrentExecutionInCallingProcess() public virtual void shouldCancelConcurrentExecutionInCallingProcess() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance parentProcessInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("parentProcess").startEvent().parallelGateway("split").callActivity("callActivity").calledElement("subprocess").endEvent().moveToLastGateway().userTask("parentUserTask").endEvent().done(); BpmnModelInstance parentProcessInstance = Bpmn.createExecutableProcess("parentProcess").startEvent().parallelGateway("split").callActivity("callActivity").calledElement("subprocess").endEvent().moveToLastGateway().userTask("parentUserTask").endEvent().done(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.model.bpmn.BpmnModelInstance subprocessInstance = org.camunda.bpm.model.bpmn.Bpmn.createExecutableProcess("subprocess").startEvent().userTask("childUserTask").endEvent("subEnd").done(); BpmnModelInstance subprocessInstance = Bpmn.createExecutableProcess("subprocess").startEvent().userTask("childUserTask").endEvent("subEnd").done(); testHelper.deploy(parentProcessInstance, subprocessInstance); ProcessInstance callingInstance = runtimeService.startProcessInstanceByKey("parentProcess"); ProcessInstance calledInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(callingInstance.Id).singleResult(); // when runtimeService.createProcessInstanceModification(calledInstance.Id).cancelAllForActivity("childUserTask").execute(); // then ProcessInstance calledInstanceAfterModification = runtimeService.createProcessInstanceQuery().processInstanceId(calledInstance.Id).singleResult(); Assert.assertNull(calledInstanceAfterModification); ExecutionTree executionTree = ExecutionTree.forExecution(callingInstance.Id, rule.ProcessEngine); assertThat(executionTree).matches(describeExecutionTree("parentUserTask").scope().done()); }
public virtual ProcessInstanceSnapshotBuilder executionTree() { ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); snapshot.ExecutionTree = executionTree; return(this); }
public virtual 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.Id; string processDefinitionId = processInstance.ProcessDefinitionId; disableAuthorization(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult(); enableAuthorization(); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.Id); // when Batch modificationBatch = runtimeService.createProcessInstanceModification(processInstance.Id).cancelActivityInstance(getInstanceIdForActivity(tree, "task1")).executeAsync(); assertNotNull(modificationBatch); Job job = managementService.createJobQuery().jobDefinitionId(modificationBatch.SeedJobDefinitionId).singleResult(); // seed job managementService.executeJob(job.Id); // then foreach (Job pending in managementService.createJobQuery().jobDefinitionId(modificationBatch.BatchJobDefinitionId).list()) { managementService.executeJob(pending.Id); assertEquals(processDefinition.DeploymentId, pending.DeploymentId); } ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).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(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testNonInterruptingWithReceiveTask() public virtual void testNonInterruptingWithReceiveTask() { string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id; // when (1) runtimeService.correlateMessage("firstMessage"); // then (1) assertEquals(1, taskService.createTaskQuery().count()); Task task1 = taskService.createTaskQuery().taskDefinitionKey("eventSubProcessTask").singleResult(); assertNotNull(task1); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); // check that the parent execution of the event sub process task execution is the event // sub process execution assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).concurrent().noScope().child("receiveTask").scope().up().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done()); // when (2) runtimeService.correlateMessage("secondMessage"); // then (2) assertEquals(2, taskService.createTaskQuery().count()); task1 = taskService.createTaskQuery().taskDefinitionKey("eventSubProcessTask").singleResult(); assertNotNull(task1); Task task2 = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult(); assertNotNull(task2); executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); // check that the parent execution of the event sub process task execution is the event // sub process execution assertThat(executionTree).matches(describeExecutionTree(null).scope().child("userTask").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done()); assertEquals(1, runtimeService.createEventSubscriptionQuery().count()); taskService.complete(task1.Id); taskService.complete(task2.Id); assertProcessEnded(processInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testModificationSameTenant() public virtual void testModificationSameTenant() { // given testRule.deployForTenant(TENANT_ONE, PARALLEL_GATEWAY_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("parallelGateway"); string processInstanceId = processInstance.Id; string processDefinitionId = processInstance.ProcessDefinitionId; ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult(); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.Id); // when Batch modificationBatch = runtimeService.createProcessInstanceModification(processInstance.Id).cancelActivityInstance(getInstanceIdForActivity(tree, "task1")).executeAsync(); assertNotNull(modificationBatch); assertEquals(TENANT_ONE, modificationBatch.TenantId); Job job = managementService.createJobQuery().jobDefinitionId(modificationBatch.SeedJobDefinitionId).singleResult(); // seed job assertEquals(TENANT_ONE, job.TenantId); managementService.executeJob(job.Id); foreach (Job pending in managementService.createJobQuery().jobDefinitionId(modificationBatch.BatchJobDefinitionId).list()) { managementService.executeJob(pending.Id); assertEquals(processDefinition.DeploymentId, pending.DeploymentId); assertEquals(TENANT_ONE, pending.TenantId); } // when ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("task2").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngineConfiguration.ProcessEngine); assertThat(executionTree).matches(describeExecutionTree("task2").scope().done()); // complete the process completeTasksInOrder("task2"); assertProcessEnded(processInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testVariableAtScopeAndConcurrentExecutionAddParentScope() public virtual void testVariableAtScopeAndConcurrentExecutionAddParentScope() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id); ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.Id, rule.ProcessEngine); ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1")[0]; ExecutionTree userTask2CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask2")[0]; runtimeService.setVariableLocal(processInstance.Id, "foo", "processInstanceValue"); runtimeService.setVariableLocal(userTask1CCExecutionBefore.Id, "foo", "task1Value"); runtimeService.setVariableLocal(userTask2CCExecutionBefore.Id, "foo", "task2Value"); VariableInstance processScopeVariable = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "processInstanceValue").singleResult(); VariableInstance task1Variable = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "task1Value").singleResult(); VariableInstance task2Variable = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "task2Value").singleResult(); // when testHelper.migrateProcessInstance(migrationPlan, processInstance); // then the scope variable instance has been overwritten during compaction (conform to prior behavior); // although this is tested here, changing this behavior may be ok in the future Assert.assertEquals(3, testHelper.snapshotAfterMigration.getVariables().Count); VariableInstance processScopeVariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(processScopeVariable.Id); Assert.assertNotNull(processScopeVariableAfterMigration); Assert.assertEquals("processInstanceValue", processScopeVariableAfterMigration.Value); VariableInstance task1VariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(task1Variable.Id); Assert.assertNotNull(task1VariableAfterMigration); Assert.assertEquals("task1Value", task1VariableAfterMigration.Value); VariableInstance task2VariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(task2Variable.Id); Assert.assertNotNull(task2VariableAfterMigration); Assert.assertEquals("task2Value", task2VariableAfterMigration.Value); }
public virtual void testStartBeforeCancelEndEvent() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); string processInstanceId = processInstance.Id; // complete the transaction subprocess once Task txTask = taskService.createTaskQuery().singleResult(); assertEquals("txTask", txTask.TaskDefinitionKey); taskService.complete(txTask.Id, Variables.createVariables().putValue("success", true)); Task afterSuccessTask = taskService.createTaskQuery().singleResult(); assertEquals("afterSuccess", afterSuccessTask.TaskDefinitionKey); // when I start before the cancel end event runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("cancelEnd").execute(); // then a new subprocess instance is created and immediately cancelled ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("afterCancellation").activity("afterSuccess").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child("afterCancellation").concurrent().noScope().up().child("afterSuccess").concurrent().noScope().up().child("tx").scope().eventScope().done()); // the compensation for the completed tx has not been triggered assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("undoTxTask").count()); // complete the process Task afterCancellationTask = taskService.createTaskQuery().taskDefinitionKey("afterCancellation").singleResult(); assertNotNull(afterCancellationTask); taskService.complete(afterCancellationTask.Id); taskService.complete(afterSuccessTask.Id); assertProcessEnded(processInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testNonInterruptingWithParallelForkInsideEmbeddedSubProcess() public virtual void testNonInterruptingWithParallelForkInsideEmbeddedSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); runtimeService.messageEventReceived("newMessage", runtimeService.createEventSubscriptionQuery().singleResult().ExecutionId); ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.Id, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("firstUserTask").concurrent().noScope().up().child("secondUserTask").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").done()); IList <Task> tasks = taskService.createTaskQuery().list(); foreach (Task task in tasks) { taskService.complete(task.Id); } assertProcessEnded(processInstance.Id); }
public virtual void testScopeTaskStartAfter() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); string processInstanceId = processInstance.Id; // when starting after the task, essentially nothing changes in the process // instance Batch modificationBatch = runtimeService.createProcessInstanceModification(processInstance.Id).startAfterActivity("theTask").executeAsync(); assertNotNull(modificationBatch); executeSeedAndBatchJobs(modificationBatch); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).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.Id).startAfterActivity("theStart").executeAsync(); assertNotNull(modificationBatch2); executeSeedAndBatchJobs(modificationBatch2); updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).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); }
public virtual void testStartBeforeNonInterruptingEventSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); string processInstanceId = processInstance.Id; runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("eventSubProcess").execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("task1").beginScope("eventSubProcess").activity("eventSubProcessTask").endScope().done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done()); completeTasksInOrder("task1", "eventSubProcessTask", "task2"); assertProcessEnded(processInstanceId); }
public virtual void testTask1AndStartBeforeBoundaryEvent() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); string processInstanceId = processInstance.Id; runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("boundaryEvent").execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("taskAfterBoundaryEvent").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree("taskAfterBoundaryEvent").scope().done()); completeTasksInOrder("taskAfterBoundaryEvent"); assertProcessEnded(processInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testMultipleNonInterruptingInEmbeddedSubprocess() public virtual void testMultipleNonInterruptingInEmbeddedSubprocess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); // the process instance must have a message event subscription: Execution subProcess = runtimeService.createExecutionQuery().messageEventSubscriptionName("newMessage").singleResult(); assertNotNull(subProcess); assertEquals(1, createEventSubscriptionQuery().count()); Task subProcessTask = taskService.createTaskQuery().taskDefinitionKey("subProcessTask").singleResult(); assertNotNull(subProcessTask); // start event sub process multiple times for (int i = 1; i < 3; i++) { runtimeService.messageEventReceived("newMessage", subProcess.Id); // check that now i event sub process tasks exist IList <Task> eventSubProcessTasks = taskService.createTaskQuery().taskDefinitionKey("eventSubProcessTask").list(); assertEquals(i, eventSubProcessTasks.Count); } ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.Id, processEngine); // check that the parent execution of the event sub process task execution is the event // sub process execution assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("subProcessTask").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().up().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done()); // complete sub process task taskService.complete(subProcessTask.Id); // after complete the sub process task all task should be deleted because of the terminating end event assertEquals(0, taskService.createTaskQuery().count()); // and the process instance should be ended assertEquals(0, runtimeService.createProcessInstanceQuery().count()); }
public virtual void testStartBeforeNoneEndEvent() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); string processInstanceId = processInstance.Id; // when I start before the none end event runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("theEnd").execute(); // then there is no effect ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId); assertNotNull(updatedTree); assertEquals(processInstanceId, updatedTree.ProcessInstanceId); assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.ProcessDefinitionId).activity("theTask").done()); ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine); assertThat(executionTree).matches(describeExecutionTree("theTask").scope().done()); completeTasksInOrder("theTask"); assertProcessEnded(processInstanceId); }