Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompleteParentProcess()
        public virtual void shouldCompleteParentProcess()
        {
//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().callActivity("callActivity").calledElement("subprocess").endEvent().done();
            BpmnModelInstance parentProcessInstance = Bpmn.createExecutableProcess("parentProcess").startEvent().callActivity("callActivity").calledElement("subprocess").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("userTask").endEvent("subEnd").done();
            BpmnModelInstance subprocessInstance = Bpmn.createExecutableProcess("subprocess").startEvent().userTask("userTask").endEvent("subEnd").done();

            testHelper.deploy(parentProcessInstance, subprocessInstance);

            // given I start the process, which wait as user task in subprocess
            runtimeService.startProcessInstanceByKey("parentProcess");

            assertNotNull(taskService.createTaskQuery().taskName("userTask").singleResult());

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.runtime.ProcessInstance subprocess = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").singleResult();
            ProcessInstance subprocess = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").singleResult();

            assertNotNull(subprocess);

            // when I do process instance modification
            runtimeService.createProcessInstanceModification(subprocess.ProcessInstanceId).cancelAllForActivity("userTask").startAfterActivity("userTask").execute();

            // then the process should be finished
            assertThat(runtimeService.createProcessInstanceQuery().count(), @is(0L));
        }
Exemple #2
0
//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);
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Transactional public void completeUserTaskAndModifyInstanceInOneTransaction(org.camunda.bpm.engine.runtime.ProcessInstance procInst)
        public virtual void completeUserTaskAndModifyInstanceInOneTransaction(ProcessInstance procInst)
        {
            // this method assures that the execution the process instance
            // modification is done in one transaction.

            // reset the process instance before the timer
            runtimeService.createProcessInstanceModification(procInst.Id).cancelAllForActivity("TimerEvent").startBeforeActivity("TimerEvent").execute();
        }
Exemple #4
0
        public virtual void testQueryProcessInstanceModificationOperation()
        {
            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");

            processInstance.Id;

            repositoryService.createProcessDefinitionQuery().singleResult();

            runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("theTask").execute();

            UserOperationLogQuery logQuery = query().entityType(EntityTypes.PROCESS_INSTANCE).operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE);

            assertEquals(0, logQuery.count());
        }
Exemple #5
0
//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);
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void modifyAProcessInstanceWithLocalVariableCreation()
        public virtual void modifyAProcessInstanceWithLocalVariableCreation()
        {
            // given a process that sets a local variable when entering the user task
            BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().userTask("userTask").camundaTaskListenerClass("create", "org.camunda.bpm.engine.test.api.runtime.util.CreateLocalVariableEventListener").endEvent().done();

            testHelper.deployAndGetDefinition(instance);
            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");

            ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.Id);

            // when I start another activity and delete the old one
            runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("userTask").cancelActivityInstance(updatedTree.getActivityInstances("userTask")[0].Id).execute(false, false);

            // then migration was successful and I can finish the process
            Task task = taskService.createTaskQuery().singleResult();

            taskService.complete(task.Id);
            testHelper.assertProcessEnded(processInstance.Id);
        }
Exemple #7
0
        public virtual void testQueryProcessInstanceModificationOperation()
        {
            ProcessInstance processInstance   = runtimeService.startProcessInstanceByKey("oneTaskProcess");
            string          processInstanceId = processInstance.Id;

            ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().singleResult();

            runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("theTask").execute();

            UserOperationLogQuery logQuery = query().entityType(EntityTypes.PROCESS_INSTANCE).operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE);

            assertEquals(1, logQuery.count());
            UserOperationLogEntry logEntry = logQuery.singleResult();

            assertEquals(processInstanceId, logEntry.ProcessInstanceId);
            assertEquals(processInstance.ProcessDefinitionId, logEntry.ProcessDefinitionId);
            assertEquals(definition.Key, logEntry.ProcessDefinitionKey);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE, logEntry.OperationType);
            assertEquals(EntityTypes.PROCESS_INSTANCE, logEntry.EntityType);
            assertNull(logEntry.Property);
            assertNull(logEntry.OrgValue);
            assertNull(logEntry.NewValue);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR, logEntry.Category);
        }