Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMigrateHistoricIncidentAddScope()
        public virtual void testMigrateHistoricIncidentAddScope()
        {
            // given
            ProcessDefinition sourceProcess = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
            ProcessDefinition targetProcess = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_SUBPROCESS_USER_TASK_PROCESS);

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcess.Id, targetProcess.Id).mapActivities("userTask", "userTask").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcess.Id);

            Job job = managementService.createJobQuery().singleResult();

            managementService.setJobRetries(job.Id, 0);

            // when
            runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).execute();

            // then
            ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.Id);

            HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();

            Assert.assertNotNull(historicIncident);
            Assert.assertEquals(activityInstance.getTransitionInstances("userTask")[0].ExecutionId, historicIncident.ExecutionId);
        }
Ejemplo n.º 2
0
        public virtual void testMigrateHistoryUserTaskInstance()
        {
            //given
            ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId("Process", "Process2").changeElementId("userTask", "userTask2"));

            MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask", "userTask2").build();

            ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id);

            HistoricTaskInstanceQuery sourceHistoryTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery().processDefinitionId(sourceProcessDefinition.Id);
            HistoricTaskInstanceQuery targetHistoryTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery().processDefinitionId(targetProcessDefinition.Id);

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

            //when
            assertEquals(1, sourceHistoryTaskInstanceQuery.count());
            assertEquals(0, targetHistoryTaskInstanceQuery.count());
            ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.Id);

            runtimeService.newMigration(migrationPlan).processInstanceQuery(sourceProcessInstanceQuery).execute();

            //then
            assertEquals(0, sourceHistoryTaskInstanceQuery.count());
            assertEquals(1, targetHistoryTaskInstanceQuery.count());

            HistoricTaskInstance instance = targetHistoryTaskInstanceQuery.singleResult();

            assertEquals(targetProcessDefinition.Key, instance.ProcessDefinitionKey);
            assertEquals(targetProcessDefinition.Id, instance.ProcessDefinitionId);
            assertEquals("userTask2", instance.TaskDefinitionKey);
            assertEquals(activityInstance.getActivityInstances("userTask")[0].Id, instance.ActivityInstanceId);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void execute(org.camunda.bpm.engine.delegate.DelegateExecution execution) throws Exception
        public virtual void execute(DelegateExecution execution)
        {
            ProcessEngineServices processEngineServices = execution.ProcessEngineServices;
            RuntimeService        runtimeService        = processEngineServices.RuntimeService;

            runtimeService.getActivityInstance(execution.ProcessInstanceId);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void execute(org.camunda.bpm.engine.delegate.DelegateExecution execution) throws Exception
            public virtual void execute(DelegateExecution execution)
            {
                RuntimeService runtimeService = engine.RuntimeService;

                ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");

                // then the wait state is reached immediately after instantiation
                ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.Id);

                ActivityInstance[] activityInstances = activityInstance.getActivityInstances("waitState");
                Assert.assertEquals(1, activityInstances.Length);
            }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryWhen1InstanceActive()
        public virtual void testQueryWhen1InstanceActive()
        {
            // given
            Assume.assumeTrue(engineRule.ProcessEngineConfiguration.DatabaseType.Equals("oracle"));
            RuntimeService runtimeService = engineRule.RuntimeService;

            testRule.deploy(ProcessModels.TWO_TASKS_PROCESS);

            // when
            ProcessInstance processInstance    = runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValue("foo", "bar"));
            string          activityInstanceId = runtimeService.getActivityInstance(processInstance.Id).Id;

            // then
            IList <VariableInstance> variables = engineRule.RuntimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId).list();

            assertEquals(1, variables.Count);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testStartBefore()
        public virtual void testStartBefore()
        {
            DeploymentWithDefinitions deployment = testRule.deploy(instance);
            ProcessDefinition         definition = deployment.DeployedProcessDefinitions[0];

            IList <string> processInstanceIds = helper.startInstances("process1", 2);

            runtimeService.createModification(definition.Id).startBeforeActivity("user2").processInstanceIds(processInstanceIds).execute();

            foreach (string processInstanceId in processInstanceIds)
            {
                ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
                assertNotNull(updatedTree);
                assertEquals(processInstanceId, updatedTree.ProcessInstanceId);

                assertThat(updatedTree).hasStructure(describeActivityInstanceTree(definition.Id).activity("user1").activity("user2").done());
            }
        }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Ignore("CAM-9354") @Test public void shouldHaveEqualParentActivityInstanceId()
        public virtual void shouldHaveEqualParentActivityInstanceId()
        {
            // given
            testHelper.deploy(Bpmn.createExecutableProcess("process").startEvent().subProcess("subprocess").embeddedSubProcess().startEvent().scriptTask("scriptTaskInSubprocess").scriptFormat("groovy").scriptText("throw new org.camunda.bpm.engine.delegate.BpmnError(\"anErrorCode\");").userTask().endEvent().subProcessDone().endEvent().moveToActivity("subprocess").boundaryEvent("boundary").error("anErrorCode").userTask("userTaskAfterBoundaryEvent").endEvent().done());

            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");

            // when
            runtimeService.createModification(processInstance.ProcessDefinitionId).startAfterActivity("scriptTaskInSubprocess").processInstanceIds(processInstance.Id).execute();

            ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.Id).getActivityInstances("subprocess")[0];

            HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("subprocess").unfinished().singleResult();

            // assume
            assertNotNull(activityInstance);
            assertNotNull(historicActivityInstance);

            // then
            assertEquals(historicActivityInstance.ParentActivityInstanceId, activityInstance.ParentActivityInstanceId);
        }