예제 #1
0
        public virtual void executeAsyncModification()
        {
            //given
            var processInstance1 = engineRule.RuntimeService.StartProcessInstanceByKey(ProcessModels.ProcessKey);
            var processInstance2 = engineRule.RuntimeService.StartProcessInstanceByKey(ProcessModels.ProcessKey);

            authRule.Init(scenario)
            .WithUser("userId")
            .BindResource("processInstance1", processInstance1.Id)
            .BindResource("processInstance2", processInstance2.Id)
            .BindResource("processDefinition", ProcessModels.ProcessKey)
            .BindResource("batchId", "*")
            .Start();

            var batch = engineRule.RuntimeService.CreateModification(processDefinition.Id)
                        .SetProcessInstanceIds(processInstance1.Id, processInstance2.Id)
                        .StartAfterActivity("userTask2")
                        .ExecuteAsync();

            var job = engineRule.ManagementService.CreateJobQuery(c => c.JobDefinitionId == batch.SeedJobDefinitionId)
                      .First();

            //seed job
            engineRule.ManagementService.ExecuteJob(job.Id);

            foreach (var pending in engineRule.ManagementService.CreateJobQuery(c => c.JobDefinitionId == batch.BatchJobDefinitionId)

                     .ToList())
            {
                engineRule.ManagementService.ExecuteJob(pending.Id);
            }

            // then
            authRule.AssertScenario(scenario);
        }
        public virtual void testBatchProcessInstanceDeletion()
        {
            //given
            authRule.Init(scenario).WithUser("userId").BindResource("batchId", "*").Start();

            // when
            IList<string> processInstanceIds = new List<string> { processInstance.Id}; //Collections.singletonList(processInstance.Id);
            runtimeService.DeleteProcessInstancesAsync(processInstanceIds, null, TEST_REASON);

            // then
            authRule.AssertScenario(scenario);
        }
예제 #3
0
        public virtual void getDecisionRequirementsDefinition()
        {
            string decisionRequirementsDefinitionId = repositoryService.CreateDecisionRequirementsDefinitionQuery(c => c.Key == DEFINITION_KEY).First().Id;

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("decisionRequirementsDefinitionKey", DEFINITION_KEY).Start();

            IDecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.GetDecisionRequirementsDefinition(decisionRequirementsDefinitionId);

            if (authRule.AssertScenario(scenario))
            {
                Assert.NotNull(decisionRequirementsDefinition);
            }
        }
예제 #4
0
        public virtual void CreateIncident()
        {
            //given
            testRule.DeployAndGetDefinition(ProcessModels.TwoTasksProcess);

            IProcessInstance processInstance = engineRule.RuntimeService.StartProcessInstanceByKey("Process");
            ExecutionEntity  execution       = (ExecutionEntity)engineRule.RuntimeService.CreateExecutionQuery(c => c.IsActive).First();

            authRule.Init(scenario).WithUser("userId").BindResource("processInstance", processInstance.Id).BindResource("processDefinition", "Process").Start();

            engineRule.RuntimeService.CreateIncident("foo", execution.Id, execution.ActivityId, "bar");

            // then
            authRule.AssertScenario(scenario);
        }
        public virtual void testRedeploy()
        {
            // given
            IRepositoryService repositoryService = engineRule.RepositoryService;

            IBpmnModelInstance model1 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process1").Done();
            IBpmnModelInstance model2 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process2").Done();

            // first deployment
            IDeployment deployment1 = repositoryService.CreateDeployment().AddModelInstance("process1.bpmn", model1).AddModelInstance("process2.bpmn", model2).Deploy();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("deploymentId", deployment1.Id).Start();

            IDeployment deployment2 = repositoryService.CreateDeployment().AddDeploymentResources(deployment1.Id).Deploy();

            // then
            if (authRule.AssertScenario(scenario))
            {
                Assert.AreEqual(2, repositoryService.CreateDeploymentQuery().Count());
                deleteDeployments(deployment2);
                deleteAuthorizations();
            }

            deleteDeployments(deployment1);
        }
예제 #6
0
        public virtual void execute()
        {
            //given
            var processDefinition = testRule.DeployAndGetDefinition(ProcessModels.TwoTasksProcess);

            var processInstance1 = engineRule.RuntimeService.StartProcessInstanceByKey("Process");
            var processInstance2 = engineRule.RuntimeService.StartProcessInstanceByKey("Process");

            engineRule.RuntimeService.DeleteProcessInstance(processInstance1.Id, TEST_REASON);
            engineRule.RuntimeService.DeleteProcessInstance(processInstance2.Id, TEST_REASON);

            authRule.Init(scenario)
            .WithUser("userId")
            .BindResource("processInstance1", processInstance1.Id)
            .BindResource("restartedProcessInstance", "*")
            .BindResource("processInstance2", processInstance2.Id)
            .BindResource("processDefinition", "Process")
            .Start();

            engineRule.RuntimeService.RestartProcessInstances(processDefinition.Id)
            .SetProcessInstanceIds(processInstance1.Id, processInstance2.Id)
            .StartAfterActivity("userTask1")
            .Execute();

            // then
            authRule.AssertScenario(scenario);
        }
예제 #7
0
        public virtual void testCompleteExternalTask()
        {
            // given
            IProcessInstance            processInstance = engineRule.RuntimeService.StartProcessInstanceByKey("oneExternalTaskProcess");
            IList <ILockedExternalTask> tasks           = engineRule.ExternalTaskService.FetchAndLock(5, "workerId") as IList <ILockedExternalTask>
            ;    //.Topic("externalTaskTopic", 5000L).Execute();

            ILockedExternalTask task = tasks[0];

            //preconditions method
            engineRule.ExternalTaskService.HandleFailure(task.Id, task.WorkerId, "anError", ERROR_DETAILS, 1, 1000L);

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("ProcessInstanceId", processInstance.Id).BindResource("processDefinitionKey", "oneExternalTaskProcess").Start();

            //execution method
            currentDetails = engineRule.ExternalTaskService.GetExternalTaskErrorDetails(task.Id);

            // then
            if (authRule.AssertScenario(scenario))
            {
                //Assertion method
                Assert.That(currentDetails, Is.EqualTo(ERROR_DETAILS));
            }
        }
예제 #8
0
        public virtual void evaluateDecisionById()
        {
            // given
            IDecisionDefinition decisionDefinition = engineRule.RepositoryService.CreateDecisionDefinitionQuery().First();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("decisionDefinitionKey", DECISION_DEFINITION_KEY).Start();

            IDmnDecisionTableResult decisionResult = engineRule.DecisionService.EvaluateDecisionTableById(decisionDefinition.Id, createVariables());

            // then
            if (authRule.AssertScenario(scenario))
            {
                AssertThatDecisionHasExpectedResult(decisionResult);
            }
        }
        public virtual void testSetRetrieSync()
        {
            // given
            IProcessInstance processInstance1 = engineRule.RuntimeService.StartProcessInstanceByKey("oneExternalTaskProcess");
            IProcessInstance processInstance2 = engineRule.RuntimeService.StartProcessInstanceByKey("oneExternalTaskProcess");
            IList <ESS.FW.Bpm.Engine.Externaltask.IExternalTask> tasks = engineRule.ExternalTaskService.CreateExternalTaskQuery()
                                                                         .ToList();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("processInstanceId1", processInstance1.Id).BindResource("processInstanceId2", processInstance2.Id).BindResource("processDefinitionKey", "oneExternalTaskProcess").Start();

            List <string> externalTaskIds = new List <string>();

            externalTaskIds.Add(tasks[0].Id);
            externalTaskIds.Add(tasks[1].Id);
            foreach (var taskId in externalTaskIds)
            {
                engineRule.ExternalTaskService.SetRetries(taskId, 5);
            }
            //engineRule.ExternalTaskService.SetRetries(externalTaskIds, 5);

            // then
            if (authRule.AssertScenario(scenario))
            {
                tasks = engineRule.ExternalTaskService.CreateExternalTaskQuery().ToList();
                Assert.AreEqual(5, (int)tasks[0].Retries);
                Assert.AreEqual(5, (int)tasks[1].Retries);
            }
        }
        public virtual void testSetJobDefinitionPriority()
        {
            // given
            IJobDefinition jobDefinition = engineRule.ManagementService.CreateJobDefinitionQuery().First();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("processDefinitionKey", "process").Start();

            engineRule.ManagementService.SetOverridingJobPriorityForJobDefinition(jobDefinition.Id, 42);

            // then
            if (authRule.AssertScenario(scenario))
            {
                IJobDefinition updatedJobDefinition = engineRule.ManagementService.CreateJobDefinitionQuery().First();
                Assert.AreEqual(42, (long)updatedJobDefinition.OverridingJobPriority);
            }
        }
        //JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
        //ORIGINAL LINE: @Test public void testDeleteProcessDefinition()
        public virtual void testDeleteProcessDefinition()
        {
            testHelper.Deploy("resources/repository/twoProcesses.bpmn20.xml");
            IList <IProcessDefinition> processDefinitions = repositoryService.CreateProcessDefinitionQuery()
                                                            .ToList();

            authRule.Init(scenario).WithUser("userId").Start();

            //when a process definition is been deleted
            repositoryService.DeleteProcessDefinition(processDefinitions[0].Id);

            //then only one process definition should remain
            if (authRule.AssertScenario(scenario))
            {
                Assert.AreEqual(1, repositoryService.CreateProcessDefinitionQuery().Count());
            }
        }
        public virtual void testDeleteBatch()
        {
            // given
            IProcessInstance processInstance = engineRule.RuntimeService.StartProcessInstanceById(migrationPlan.SourceProcessDefinitionId);

            batch = engineRule.RuntimeService.NewMigration(migrationPlan).ProcessInstanceIds((processInstance.Id)).ExecuteAsync();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("batchId", batch.Id).Start();

            cascade = false;
            engineRule.ManagementService.DeleteBatch(batch.Id, cascade);

            // then
            if (authRule.AssertScenario(scenario))
            {
                Assert.AreEqual(0, engineRule.ManagementService.CreateBatchQuery().Count());
            }
        }
        public virtual void testMigrate()
        {
            // given
            IProcessDefinition sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            IProcessDefinition targetDefinition = testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess).ChangeElementId(ProcessModels.ProcessKey, "new" + ProcessModels.ProcessKey));

            IProcessInstance processInstance = engineRule.RuntimeService.StartProcessInstanceById(sourceDefinition.Id);

            IMigrationPlan migrationPlan = engineRule.RuntimeService.CreateMigrationPlan(sourceDefinition.Id, targetDefinition.Id).MapEqualActivities().Build();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("sourceDefinitionKey", sourceDefinition.Key).BindResource("targetDefinitionKey", targetDefinition.Key).BindResource("processInstance", processInstance.Id).Start();

            batch = engineRule.RuntimeService.NewMigration(migrationPlan).ProcessInstanceIds((processInstance.Id)).ExecuteAsync();

            // then
            if (authRule.AssertScenario(scenario))
            {
                Assert.AreEqual(1, engineRule.ManagementService.CreateBatchQuery().Count());
            }
        }
        public virtual void testCreateStatistics()
        {
            //given
            authRule.Init(scenario).WithUser("userId").BindResource("drd", "*").Start();

            // when
            historyService.CreateHistoricDecisionInstanceStatisticsQuery(decisionRequirementsDefinition.Id)
            .ToList();

            // then
            authRule.AssertScenario(scenario);
        }
예제 #15
0
        public virtual void testSuspendBatch()
        {
            // given
            IProcessInstance processInstance = engineRule.RuntimeService.StartProcessInstanceById(migrationPlan.SourceProcessDefinitionId);

            batch = engineRule.RuntimeService.NewMigration(migrationPlan).ProcessInstanceIds(new List <string> {
                processInstance.Id
            }).ExecuteAsync();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("batchId", batch.Id).Start();

            engineRule.ManagementService.SuspendBatchById(batch.Id);

            // then
            if (authRule.AssertScenario(scenario))
            {
                batch = engineRule.ManagementService.CreateBatchQuery(c => c.Id == batch.Id).First();

                Assert.True(batch.Suspended);
            }
        }
예제 #16
0
        public virtual void testSetRetriesAsync()
        {
            // given
            IProcessDefinition processDefinition = testRule.DeployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
            IProcessInstance   processInstance1  = engineRule.RuntimeService.StartProcessInstanceByKey("Process");
            IList <ESS.FW.Bpm.Engine.Externaltask.IExternalTask> externalTasks = engineRule.ExternalTaskService.CreateExternalTaskQuery()
                                                                                 .ToList();

            List <string> externalTaskIds = new List <string>();

            foreach (ESS.FW.Bpm.Engine.Externaltask.IExternalTask task in externalTasks)
            {
                externalTaskIds.Add(task.Id);
            }

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("batchId", "*").BindResource("processInstance1", processInstance1.Id).BindResource("processDefinition", processDefinition.Key).Start();

            IBatch batch = engineRule.ExternalTaskService.SetRetriesAsync(externalTaskIds, null, 5);

            if (batch != null)
            {
                executeSeedAndBatchJobs(batch);
            }

            // then
            if (authRule.AssertScenario(scenario))
            {
                externalTasks = engineRule.ExternalTaskService.CreateExternalTaskQuery()
                                .ToList();
                foreach (ESS.FW.Bpm.Engine.Externaltask.IExternalTask task in externalTasks)
                {
                    Assert.AreEqual(5, (int)task.Retries);
                }
            }
        }
        public virtual void testCreate()
        {
            // given
            IProcessDefinition sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            IProcessDefinition targetDefinition = testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess).ChangeElementId(ProcessModels.ProcessKey, "new" + ProcessModels.ProcessKey));

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("sourceDefinitionKey", sourceDefinition.Key).BindResource("targetDefinitionKey", targetDefinition.Key).Start();

            IMigrationPlan migrationPlan = engineRule.RuntimeService.CreateMigrationPlan(sourceDefinition.Id, targetDefinition.Id).MapEqualActivities().Build();

            // then
            if (authRule.AssertScenario(scenario))
            {
                Assert.NotNull(migrationPlan);
            }
        }
예제 #18
0
        public virtual void queryDecisionRequirementsDefinitions()
        {
            // when
            authRule.Init(scenario).WithUser("userId").BindResource("decisionRequirementsDefinitionKey", DEFINITION_KEY).Start();

            IQueryable <IDecisionRequirementsDefinition> query = engineRule.RepositoryService.CreateDecisionRequirementsDefinitionQuery();
            long Count = query.Count();

            // then
            if (authRule.AssertScenario(scenario))
            {
                Assert.That(Count, Is.EqualTo((long)expectedDefinitionKeys.Length));

                IList <string> definitionKeys = getDefinitionKeys(query.ToList());
                Assert.That(definitionKeys, Has.Member(expectedDefinitionKeys));
            }
        }
        public virtual void testProcessInstancesList()
        {
            //given
            IList <string> processInstanceIds = new List <string> {
                historicProcessInstance.Id, historicProcessInstance2.Id
            };

            authRule.Init(scenario).WithUser("userId").BindResource("processInstance1", processInstance.Id).BindResource("processInstance2", processInstance2.Id).Start();

            // when
            historyService.DeleteHistoricProcessInstances(processInstanceIds);

            // then
            if (authRule.AssertScenario(scenario))
            {
                Assert.That(historyService.CreateHistoricProcessInstanceQuery().Count(), Is.EqualTo(0L));
            }
        }
        public virtual void testSetRetries()
        {
            // given
            IProcessInstance processInstance = engineRule.RuntimeService.StartProcessInstanceByKey("oneExternalTaskProcess");

            ESS.FW.Bpm.Engine.Externaltask.IExternalTask task = engineRule.ExternalTaskService.CreateExternalTaskQuery().First();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("ProcessInstanceId", processInstance.Id).BindResource("processDefinitionKey", "oneExternalTaskProcess").Start();

            engineRule.ExternalTaskService.SetRetries(task.Id, 5);

            // then
            if (authRule.AssertScenario(scenario))
            {
                task = engineRule.ExternalTaskService.CreateExternalTaskQuery().First();
                Assert.AreEqual(5, (int)task.Retries);
            }
        }
예제 #21
0
        public virtual void executeBatch()
        {
            //given
            var processDefinition = testRule.DeployAndGetDefinition(ProcessModels.TwoTasksProcess);

            var processInstance1 = engineRule.RuntimeService.StartProcessInstanceByKey("Process");
            var processInstance2 = engineRule.RuntimeService.StartProcessInstanceByKey("Process");

            engineRule.RuntimeService.DeleteProcessInstance(processInstance1.Id, TEST_REASON);
            engineRule.RuntimeService.DeleteProcessInstance(processInstance2.Id, TEST_REASON);

            authRule.Init(scenario)
            .WithUser("userId")
            .BindResource("processInstance1", processInstance1.Id)
            .BindResource("restartedProcessInstance", "*")
            .BindResource("processInstance2", processInstance2.Id)
            .BindResource("processDefinition", "Process")
            .BindResource("batchId", "*")
            .Start();

            var batch = engineRule.RuntimeService.RestartProcessInstances(processDefinition.Id)
                        .SetProcessInstanceIds(processInstance1.Id, processInstance2.Id)
                        .StartAfterActivity("userTask1")
                        .ExecuteAsync();

            if (batch != null)
            {
                var job = engineRule.ManagementService.CreateJobQuery(c => c.JobDefinitionId == batch.SeedJobDefinitionId)
                          .First();

                // seed job
                engineRule.ManagementService.ExecuteJob(job.Id);

                foreach (var pending in engineRule.ManagementService.CreateJobQuery(c => c.JobDefinitionId == batch.BatchJobDefinitionId)

                         .ToList())
                {
                    engineRule.ManagementService.ExecuteJob(pending.Id);
                }
            }
            // then
            authRule.AssertScenario(scenario);
        }
예제 #22
0
        public virtual void testSetJobPriority()
        {
            // given
            IProcessInstance processInstance = engineRule.RuntimeService.StartProcessInstanceByKey("process");

            ESS.FW.Bpm.Engine.Runtime.IJob job = engineRule.ManagementService.CreateJobQuery().First();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("ProcessInstanceId", processInstance.Id).BindResource("processDefinitionKey", "process").Start();

            engineRule.ManagementService.SetJobPriority(job.Id, 42);

            // then
            if (authRule.AssertScenario(scenario))
            {
                ESS.FW.Bpm.Engine.Runtime.IJob updatedJob = engineRule.ManagementService.CreateJobQuery().First();
                Assert.AreEqual(42, updatedJob.Priority);
            }
        }
        public virtual void testCompleteExternalTask()
        {
            // given
            IProcessInstance            processInstance = engineRule.RuntimeService.StartProcessInstanceByKey("oneExternalTaskProcess");
            IList <ILockedExternalTask> tasks           = engineRule.ExternalTaskService.FetchAndLock(5, "workerId")
                                                          //.Topic("externalTaskTopic", 5000L).Execute();
                                                          as IList <ILockedExternalTask>;
            ILockedExternalTask task = tasks[0];

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("ProcessInstanceId", processInstance.Id).BindResource("processDefinitionKey", "oneExternalTaskProcess").Start();

            testExternalTaskApi(task);

            // then
            if (authRule.AssertScenario(scenario))
            {
                AssertExternalTaskResults();
            }
        }
예제 #24
0
        public virtual void testCleanupHistory()
        {
            //given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<String> ids = prepareHistoricDecisions();
            var ids = prepareHistoricDecisions();

            // when
            authRule.Init(scenario)
            .WithUser("demo")
            .Start();

            //historyService.DeleteHistoricDecisionInstancesBulk(ids);

            //then
            if (authRule.AssertScenario(scenario))
            {
                Assert.AreEqual(0, historyService.CreateHistoricDecisionInstanceQuery(c => c.DecisionDefinitionKey == DECISION)
                                .Count());
            }
        }
        public virtual void testSetJobPriority()
        {
            // given
            IProcessInstance            processInstance = engineRule.RuntimeService.StartProcessInstanceByKey("oneExternalTaskProcess");
            IList <ILockedExternalTask> tasks           = engineRule.ExternalTaskService.FetchAndLock(5, "workerId")
                                                          //.Topic("externalTaskTopic", 5000L).Execute();
                                                          as IList <ILockedExternalTask>;
            ILockedExternalTask task = tasks[0];

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("ProcessInstanceId", processInstance.Id).BindResource("processDefinitionKey", "oneExternalTaskProcess").Start();

            engineRule.ExternalTaskService.Unlock(task.Id);

            // then
            if (authRule.AssertScenario(scenario))
            {
                ESS.FW.Bpm.Engine.Externaltask.IExternalTask externalTask = engineRule.ExternalTaskService.CreateExternalTaskQuery().First();
                Assert.IsNull(externalTask.LockExpirationTime);
            }
        }
        public virtual void testSetJobDefinitionPriority()
        {
            // given
            IJobDefinition   jobDefinition = engineRule.ManagementService.CreateJobDefinitionQuery().First();
            IProcessInstance instance      = engineRule.RuntimeService.StartProcessInstanceByKey("process");

            ESS.FW.Bpm.Engine.Runtime.IJob job = engineRule.ManagementService.CreateJobQuery().First();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("processDefinitionKey", "process").BindResource("ProcessInstanceId", instance.Id).Start();

            engineRule.ManagementService.SetOverridingJobPriorityForJobDefinition(jobDefinition.Id, 42, true);

            // then
            if (authRule.AssertScenario(scenario))
            {
                jobDefinition = engineRule.ManagementService.CreateJobDefinitionQuery().First();
                Assert.AreEqual(42L, (long)jobDefinition.OverridingJobPriority);

                job = engineRule.ManagementService.CreateJobQuery().First();
                Assert.AreEqual(42L, job.Priority);
            }
        }
예제 #27
0
        public virtual void testCleanupHistory()
        {
            //given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<String> ids = prepareHistoricProcesses();
            var ids = prepareHistoricProcesses();

            runtimeService.DeleteProcessInstances(ids, null, true, true);

            // when
            authRule.Init(scenario)
            .WithUser("demo")
            .Start();

            //when
            historyService.DeleteHistoricProcessInstancesBulk(ids);

            if (authRule.AssertScenario(scenario))
            {
                Assert.AreEqual(0, historyService.CreateHistoricProcessInstanceQuery(c => c.CaseDefinitionKey == ONE_TASK_PROCESS)
                                .Count());
            }
        }