Ejemplo n.º 1
0
        [Test]   public virtual void testFailStartCaseInstanceFromOtherTenantWithLatestBinding()
        {
            IBpmnModelInstance callingProcess = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("callingProcess").StartEvent().CallActivity().CamundaCaseRef("Case_1").CamundaCaseBinding("latest").EndEvent().Done();

            DeploymentForTenant(TENANT_ONE, callingProcess);
            DeploymentForTenant(TENANT_TWO, CMMN);

            try
            {
                runtimeService.CreateProcessInstanceByKey("callingProcess").SetProcessDefinitionTenantId(TENANT_ONE).Execute();

                Assert.Fail("expected exception");
            }
            catch (ProcessEngineException e)
            {
                Assert.That(e.Message, Does.Contain("no case definition deployed with key 'Case_1'"));
            }
        }
        [Test]   public virtual void testPartialChangesDeployAll()
        {
            IBpmnModelInstance model1 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process1").Done();
            IBpmnModelInstance model2 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process2").Done();

            // create initial deployment
            var deployment1 = repositoryService.CreateDeployment(processApplication.Reference).Name("deployment").AddModelInstance("process1.bpmn20.xml", model1).AddModelInstance("process2.bpmn20.xml", model2).Deploy();

            IBpmnModelInstance changedModel2 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process2").StartEvent().Done();

            // second deployment with partial changes:
            IProcessApplicationDeployment deployment2 = repositoryService.CreateDeployment(processApplication.Reference).ResumePreviousVersions().Name("deployment").EnableDuplicateFiltering(false)
                                                        .AddModelInstance("process1.bpmn20.xml", model1).AddModelInstance("process2.bpmn20.xml", changedModel2)
                                                        .Deploy() as IProcessApplicationDeployment;

            Assert.AreEqual(4, repositoryService.CreateProcessDefinitionQuery().Count());

            IList <IProcessDefinition> processDefinitionsModel1 = repositoryService.CreateProcessDefinitionQuery()
                                                                  //.ProcessDefinitionKey("process1")
                                                                  //.OrderByProcessDefinitionVersion()
                                                                  /*.Asc()*/
                                                                  .ToList();

            // now there are two versions of process1 deployed
            Assert.AreEqual(2, processDefinitionsModel1.Count);
            Assert.AreEqual(1, processDefinitionsModel1[0].Version);
            Assert.AreEqual(2, processDefinitionsModel1[1].Version);

            // now there are two versions of process2 deployed
            IList <IProcessDefinition> processDefinitionsModel2 = repositoryService.CreateProcessDefinitionQuery(c => c.Key == "process1").ToList(); //.OrderByProcessDefinitionVersion()/*.Asc()*/.ToList();

            Assert.AreEqual(2, processDefinitionsModel2.Count);
            Assert.AreEqual(1, processDefinitionsModel2[0].Version);
            Assert.AreEqual(2, processDefinitionsModel2[1].Version);

            // old deployment was resumed
            var            registration  = deployment2.ProcessApplicationRegistration;
            IList <string> deploymentIds = registration.DeploymentIds;

            Assert.AreEqual(2, deploymentIds.Count);
            Assert.AreEqual(ProcessEngine.Name, registration.ProcessEngineName);

            deleteDeployments(deployment1, deployment2);
        }
Ejemplo n.º 3
0
        public virtual void TestPartialChangesDeployChangedOnly()
        {
            IBpmnModelInstance model1      = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process1").Done();
            IBpmnModelInstance model2      = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process2").Done();
            IDeployment        deployment1 = repositoryService.CreateDeployment().AddModelInstance("process1.bpmn20.xml", model1).AddModelInstance("process2.bpmn20.xml", model2).Name("thrice").Deploy();

            IList <string> deploymentResources = repositoryService.GetDeploymentResourceNames(deployment1.Id);

            Assert.AreEqual(2, deploymentResources.Count);

            IBpmnModelInstance changedModel2 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process2").StartEvent().Done();

            IDeployment deployment2 = repositoryService.CreateDeployment().EnableDuplicateFiltering(true).AddModelInstance("process1.bpmn20.xml", model1).AddModelInstance("process2.bpmn20.xml", changedModel2).Name("thrice").Deploy();

            IList <IDeployment> deploymentList = repositoryService.CreateDeploymentQuery().ToList();

            Assert.AreEqual(2, deploymentList.Count);

            // there should be only one version of process 1
            IProcessDefinition process1Definition = repositoryService.CreateProcessDefinitionQuery(c => c.Key == "process1").First();

            Assert.NotNull(process1Definition);
            Assert.AreEqual(1, process1Definition.Version);
            Assert.AreEqual(deployment1.Id, process1Definition.DeploymentId);

            // there should be two versions of process 2
            Assert.AreEqual(2, repositoryService.CreateProcessDefinitionQuery(c => c.Key == "process2").Count());

            IBpmnModelInstance anotherChangedModel2 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process2").StartEvent().EndEvent().Done();

            // testing with a third deployment to ensure the change check is not only performed against
            // the last version of the deployment
            IDeployment deployment3 = repositoryService.CreateDeployment().EnableDuplicateFiltering(true).AddModelInstance("process1.bpmn20.xml", model1).AddModelInstance("process2.bpmn20.xml", anotherChangedModel2).Name("thrice").Deploy();

            // there should still be one version of process 1
            Assert.AreEqual(1, repositoryService.CreateProcessDefinitionQuery(c => c.Key == "process1").Count());

            // there should be three versions of process 2
            Assert.AreEqual(3, repositoryService.CreateProcessDefinitionQuery(c => c.Key == "process2").Count());

            repositoryService.DeleteDeployment(deployment1.Id);
            repositoryService.DeleteDeployment(deployment2.Id);
            repositoryService.DeleteDeployment(deployment3.Id);
        }
        [Test]   public virtual void testPartialChangesResumePreviousVersionByDeploymentName()
        {
            IBpmnModelInstance model1 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process1").Done();
            IBpmnModelInstance model2 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process2").Done();

            // create initial deployment
            var deployment1 = repositoryService.CreateDeployment(processApplication.Reference).Name("deployment").AddModelInstance("process1.bpmn20.xml", model1).Deploy();

            IProcessApplicationDeployment deployment2 = repositoryService.CreateDeployment(processApplication.Reference)
                                                        .ResumePreviousVersions().ResumePreviousVersionsBy(ResumePreviousBy.ResumeByDeploymentName)
                                                        .Name("deployment").EnableDuplicateFiltering(true).AddModelInstance("process1.bpmn20.xml", model1)
                                                        .AddModelInstance("process2.bpmn20.xml", model2).Deploy() as IProcessApplicationDeployment;

            var registration = deployment2.ProcessApplicationRegistration;

            Assert.AreEqual(2, registration.DeploymentIds.Count);

            deleteDeployments(deployment1, deployment2);
        }
Ejemplo n.º 5
0
        [Test]   public virtual void testStartProcessInstanceWithLatestBindingDifferentVersion()
        {
            IBpmnModelInstance callingProcess = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("callingProcess").StartEvent().CallActivity().CalledElement("subProcess").CamundaCalledElementBinding("latest").EndEvent().Done();

            DeploymentForTenant(TENANT_ONE, callingProcess, SUB_PROCESS);

            DeploymentForTenant(TENANT_TWO, callingProcess, SUB_PROCESS);
            DeploymentForTenant(TENANT_TWO, SUB_PROCESS);

            runtimeService.CreateProcessInstanceByKey("callingProcess").SetProcessDefinitionTenantId(TENANT_ONE).Execute();
            runtimeService.CreateProcessInstanceByKey("callingProcess").SetProcessDefinitionTenantId(TENANT_TWO).Execute();

            IProcessDefinition latestSubProcessTenantTwo = repositoryService.CreateProcessDefinitionQuery(c => c.TenantId == TENANT_TWO) /*.ProcessDefinitionKey("subProcess")/*.LatestVersion()*/.First();

            IQueryable <IProcessInstance> query = runtimeService.CreateProcessInstanceQuery(c => c.ProcessDefinitionId == "subProcess");

            Assert.That(query.Where(c => c.TenantId == TENANT_ONE).Count(), Is.EqualTo(1L));
            Assert.That(query.Where(c => c.TenantId == TENANT_TWO && c.ProcessDefinitionId == latestSubProcessTenantTwo.Id).Count(), Is.EqualTo(1L));
        }
Ejemplo n.º 6
0
        [Test]   public virtual void testStartCaseInstanceWithLatestBindingDifferentVersion()
        {
            IBpmnModelInstance callingProcess = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("callingProcess").StartEvent().CallActivity().CamundaCaseRef("Case_1").CamundaCaseBinding("latest").EndEvent().Done();

            DeploymentForTenant(TENANT_ONE, CMMN, callingProcess);

            DeploymentForTenant(TENANT_TWO, CMMN, callingProcess);
            DeploymentForTenant(TENANT_TWO, CMMN);

            runtimeService.CreateProcessInstanceByKey("callingProcess").SetProcessDefinitionTenantId(TENANT_ONE).Execute();
            runtimeService.CreateProcessInstanceByKey("callingProcess").SetProcessDefinitionTenantId(TENANT_TWO).Execute();

            //ICaseInstanceQuery query = caseService.CreateCaseInstanceQuery().CaseDefinitionKey("Case_1");
            //Assert.That(query.Where(c=>c.TenantId == TENANT_ONE).Count(), Is.EqualTo(1L));

            //ICaseDefinition latestCaseDefinitionTenantTwo = repositoryService.CreateCaseDefinitionQuery(c=>c.TenantId == TENANT_TWO)/*.LatestVersion()*/.First();
            //query = caseService.CreateCaseInstanceQuery(c=>c.CaseDefinitionId== latestCaseDefinitionTenantTwo.Id);
            //Assert.That(query.Count(), Is.EqualTo(1L));
        }
        public virtual void testPropertyDuplicateFiltering()
        {
            // given
            IBpmnModelInstance model = createProcessWithServiceTask(PROCESS_KEY);

            // when
            IDeployment deployment = repositoryService.CreateDeployment().Name(DEPLOYMENT_NAME).AddModelInstance(RESOURCE_NAME, model).EnableDuplicateFiltering(false).Deploy();

            // then
            IQueryable <IUserOperationLogEntry> query = historyService.CreateUserOperationLogQuery();

            Assert.AreEqual(2, query.Count());

            // (1): duplicate filter enabled property
            //IUserOperationLogEntry logDuplicateFilterEnabledProperty = query.Property("duplicateFilterEnabled").First();
            //Assert.NotNull(logDuplicateFilterEnabledProperty);

            //Assert.AreEqual(EntityTypes.Deployment, logDuplicateFilterEnabledProperty.EntityType);
            //Assert.AreEqual(deployment.Id, logDuplicateFilterEnabledProperty.DeploymentId);
            //Assert.AreEqual(UserOperationLogEntryFields.OperationTypeCreate, logDuplicateFilterEnabledProperty.OperationType);

            //Assert.AreEqual(USER_ID, logDuplicateFilterEnabledProperty.UserId);

            //Assert.AreEqual("duplicateFilterEnabled", logDuplicateFilterEnabledProperty.Property);
            //Assert.IsNull(logDuplicateFilterEnabledProperty.OrgValue);
            //Assert.True(Convert.ToBoolean(logDuplicateFilterEnabledProperty.NewValue));

            //// (2): deploy changed only
            //IUserOperationLogEntry logDeployChangedOnlyProperty = query.Property("deployChangedOnly").First();
            //Assert.NotNull(logDeployChangedOnlyProperty);

            //Assert.AreEqual(EntityTypes.Deployment, logDeployChangedOnlyProperty.EntityType);
            //Assert.AreEqual(deployment.Id, logDeployChangedOnlyProperty.DeploymentId);
            //Assert.AreEqual(UserOperationLogEntryFields.OperationTypeCreate, logDeployChangedOnlyProperty.OperationType);
            //Assert.AreEqual(USER_ID, logDeployChangedOnlyProperty.UserId);

            //Assert.AreEqual("deployChangedOnly", logDeployChangedOnlyProperty.Property);
            //Assert.IsNull(logDeployChangedOnlyProperty.OrgValue);
            //Assert.IsFalse(Convert.ToBoolean(logDeployChangedOnlyProperty.NewValue));

            //// (3): operation id
            //Assert.AreEqual(logDuplicateFilterEnabledProperty.OperationId, logDeployChangedOnlyProperty.OperationId);
        }
Ejemplo n.º 8
0
        public static void addUserTaskCompensationHandler(IBpmnModelInstance modelInstance, string boundaryEventId,
                                                          string compensationHandlerId)
        {
            var boundaryEvent = (IBoundaryEvent)modelInstance.GetModelElementById/*<IBoundaryEvent>*/ (boundaryEventId);
            var scope         = (IBaseElement)boundaryEvent.ParentElement;

            var compensationHandler = modelInstance.NewInstance <IUserTask>(typeof(IUserTask));

            compensationHandler.Id = compensationHandlerId;
            compensationHandler.ForCompensation = true;
            scope.AddChildElement(compensationHandler);

            var association = modelInstance.NewInstance <IAssociation>(typeof(IAssociation));

            association.AssociationDirection = AssociationDirection.One;
            association.Source = boundaryEvent;
            association.Target = compensationHandler;
            scope.AddChildElement(association);
        }
Ejemplo n.º 9
0
        public virtual IMigratingBpmnEventTrigger AddBoundaryEvent(IProcessEngine engine,
                                                                   IBpmnModelInstance modelInstance, string activityId, string boundaryEventId)
        {
            ModifiableBpmnModelInstance.Wrap(modelInstance)
            //.ActivityBuilder(activityId)
            //.BoundaryEvent(boundaryEventId)
            //.Condition(VAR_CONDITION)
            //.Done()
            ;

            var trigger = new ConditionalEventTrigger();

            trigger.Engine        = engine;
            trigger.VariableName  = "any";
            trigger.VariableValue = "any";
            trigger.ActivityId    = boundaryEventId;

            return(trigger);
        }
Ejemplo n.º 10
0
        [Test]   public virtual void testFailStartProcessInstanceFromOtherTenantWithVersionBinding()
        {
            IBpmnModelInstance callingProcess = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("callingProcess").StartEvent().CallActivity().CalledElement("subProcess").CamundaCalledElementBinding("version").CamundaCalledElementVersion("2").EndEvent().Done();

            DeploymentForTenant(TENANT_ONE, callingProcess, SUB_PROCESS);

            DeploymentForTenant(TENANT_TWO, SUB_PROCESS);
            DeploymentForTenant(TENANT_TWO, SUB_PROCESS);

            try
            {
                runtimeService.CreateProcessInstanceByKey("callingProcess").SetProcessDefinitionTenantId(TENANT_ONE).Execute();

                Assert.Fail("expected exception");
            }
            catch (ProcessEngineException e)
            {
                Assert.That(e.Message, Does.Contain("no processes deployed with key = 'subProcess'"));
            }
        }
Ejemplo n.º 11
0
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDeleteProcessDefinitionClearsCache()
        [Test]   public virtual void testDeleteProcessDefinitionClearsCache()
        {
            // given process definition and a process instance
            IBpmnModelInstance bpmnModel = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process").StartEvent().UserTask().EndEvent().Done();

            deployment = repositoryService.CreateDeployment().AddModelInstance("process.bpmn", bpmnModel).Deploy();
            string processDefinitionId = repositoryService.CreateProcessDefinitionQuery(c => c.Key == "process").First().Id;

            DeploymentCache deploymentCache = processEngineConfiguration.DeploymentCache;

            // ensure definitions and models are part of the cache
            Assert.NotNull(deploymentCache.ProcessDefinitionCache.Get(processDefinitionId));
            Assert.NotNull(deploymentCache.BpmnModelInstanceCache.Get(processDefinitionId));

            repositoryService.DeleteProcessDefinition(processDefinitionId, true);

            // then the definitions and models are removed from the cache
            Assert.IsNull(deploymentCache.ProcessDefinitionCache.Get(processDefinitionId));
            Assert.IsNull(deploymentCache.BpmnModelInstanceCache.Get(processDefinitionId));
        }
Ejemplo n.º 12
0
        public virtual void testSetTaskVariablesInServiceTask()
        {
            // given
            IBpmnModelInstance bpmnModelInstance = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess(PROCESS_KEY).StartEvent().UserTask().ServiceTask().CamundaExpression("${execution.SetVariable('foo', 'bar')}").EndEvent().Done();

            testRule.Deploy(bpmnModelInstance);

            identityService.AuthenticatedUserId = "demo";
            runtimeService.StartProcessInstanceByKey(PROCESS_KEY);
            ITask task = taskService.CreateTaskQuery().First();

            // when
            taskService.Complete(task.Id);

            //then
            IHistoricDetail historicDetail = historyService.CreateHistoricDetailQuery().First();

            // no user operation log id is set for this update, as it is not written as part of the user operation
            Assert.IsNull(historicDetail.UserOperationId);
        }
Ejemplo n.º 13
0
        [Test]   public virtual void testFailEvaluateDecisionFromOtherTenantWithVersionBinding()
        {
            IBpmnModelInstance process = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process").StartEvent().BusinessRuleTask().CamundaDecisionRef("decision").CamundaDecisionRefBinding("version").CamundaDecisionRefVersion("2").CamundaAsyncAfter().EndEvent().Done();

            DeploymentForTenant(TENANT_ONE, DMN_FILE, process);

            DeploymentForTenant(TENANT_TWO, DMN_FILE);
            DeploymentForTenant(TENANT_TWO, DMN_FILE);

            try
            {
                runtimeService.CreateProcessInstanceByKey("process").SetProcessDefinitionTenantId(TENANT_ONE).Execute();

                Assert.Fail("expected exception");
            }
            catch (ProcessEngineException e)
            {
                Assert.That(e.Message, Does.Contain("no decision definition deployed with key = 'decision', version = '2' and tenant-id 'tenant1'"));
            }
        }
Ejemplo n.º 14
0
        private void addServiceTaskCompensationHandler(IBpmnModelInstance modelInstance, string boundaryEventId, string compensationHandlerId)
        {
            IBoundaryEvent boundaryEvent = (IBoundaryEvent)modelInstance.GetModelElementById/*<IBoundaryEvent>*/ (boundaryEventId);
            IBaseElement   scope         = (IBaseElement)boundaryEvent.ParentElement;

            IServiceTask compensationHandler = modelInstance.NewInstance <IServiceTask>(typeof(IServiceTask));

            compensationHandler.Id = compensationHandlerId;
            compensationHandler.ForCompensation = true;
            //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.GetName method:
            compensationHandler.CamundaClass = typeof(IncreaseCurrentTimeServiceTask).FullName;
            scope.AddChildElement(compensationHandler);

            IAssociation association = modelInstance.NewInstance <IAssociation>(typeof(IAssociation));

            association.AssociationDirection = AssociationDirection.One;
            association.Source = boundaryEvent;
            association.Target = compensationHandler;
            scope.AddChildElement(association);
        }
Ejemplo n.º 15
0
        public virtual void TestPartialChangesRedeployOldVersion()
        {
            // deployment 1 deploys process version 1
            IBpmnModelInstance model1      = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process1").Done();
            IDeployment        deployment1 = repositoryService.CreateDeployment().AddModelInstance("process1.bpmn20.xml", model1).Name("deployment").Deploy();

            // deployment 2 deploys process version 2
            IBpmnModelInstance changedModel1 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process1").StartEvent().Done();
            IDeployment        deployment2   = repositoryService.CreateDeployment().EnableDuplicateFiltering(true).AddModelInstance("process1.bpmn20.xml", changedModel1).Name("deployment").Deploy();

            // deployment 3 deploys process version 1 again
            IDeployment deployment3 = repositoryService.CreateDeployment().EnableDuplicateFiltering(true).AddModelInstance("process1.bpmn20.xml", model1).Name("deployment").Deploy();

            // should result in three process definitions
            Assert.AreEqual(3, repositoryService.CreateProcessDefinitionQuery(c => c.Key == "process1").Count());

            repositoryService.DeleteDeployment(deployment1.Id);
            repositoryService.DeleteDeployment(deployment2.Id);
            repositoryService.DeleteDeployment(deployment3.Id);
        }
Ejemplo n.º 16
0
        public virtual void testRepositoryService()
        {
            string processDefinitionId = repositoryService.CreateProcessDefinitionQuery(c => c.Key == PROCESS_KEY).First().Id;

            IBpmnModelInstance modelInstance = repositoryService.GetBpmnModelInstance(processDefinitionId);

            Assert.NotNull(modelInstance);

            IEnumerable <IEvent> events = modelInstance.GetModelElementsByType <IEvent>(typeof(IEvent));

            Assert.AreEqual(2, events.Count());

            IEnumerable <ISequenceFlow> sequenceFlows = modelInstance.GetModelElementsByType <ISequenceFlow>(typeof(ISequenceFlow));

            Assert.AreEqual(1, sequenceFlows.Count());

            IStartEvent startEvent = (IStartEvent)modelInstance.GetModelElementById/*<IStartEvent>*/ ("start");

            Assert.NotNull(startEvent);
        }
Ejemplo n.º 17
0
        public virtual void testUpdateConditionalEventExpression()
        {
            // given
            IBpmnModelInstance sourceProcess = ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                               //.ActivityBuilder(USER_TASK_ID)
                                               //.BoundaryEvent(BOUNDARY_ID)
                                               //.Condition(FALSE_CONDITION)
                                               //.UserTask(AFTER_BOUNDARY_TASK)
                                               //.EndEvent()
                                               //.Done()
            ;
            IBpmnModelInstance targetProcess = ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                               //.ActivityBuilder(USER_TASK_ID)
                                               //.BoundaryEvent(BOUNDARY_ID)
                                               //.Condition(VAR_CONDITION)
                                               //.UserTask(AFTER_BOUNDARY_TASK)
                                               //.EndEvent()
                                               //.Done()
            ;

            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(sourceProcess);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(targetProcess);

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities(USER_TASK_ID, USER_TASK_ID)
                .MapActivities(BOUNDARY_ID, BOUNDARY_ID)
                .UpdateEventTrigger()
                .Build();

            // when process is migrated without update event trigger
            testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            // then condition is migrated and has new condition expr
            testHelper.AssertEventSubscriptionMigrated(BOUNDARY_ID, BOUNDARY_ID, null);

            // and it is possible to successfully complete the migrated instance
            testHelper.AnyVariable = testHelper.SnapshotAfterMigration.ProcessInstanceId;
            testHelper.CompleteTask(AFTER_BOUNDARY_TASK);
            testHelper.AssertProcessEnded(testHelper.SnapshotBeforeMigration.ProcessInstanceId);
        }
Ejemplo n.º 18
0
        public virtual void testMigrateBoundaryEventToParallelSubProcess()
        {
            // given
            var sourceProcess = ProcessModels.ParallelSubprocessProcess.Clone();
            var eventTrigger  = eventFactory.AddBoundaryEvent(rule.ProcessEngine, sourceProcess,
                                                              "subProcess1", BOUNDARY_ID);

            ModifiableBpmnModelInstance.Wrap(sourceProcess)
            //.FlowNodeBuilder(BOUNDARY_ID)
            //.UserTask(AFTER_BOUNDARY_TASK)
            //.EndEvent()
            //.Done()
            ;

            IBpmnModelInstance targetProcess = ModifiableBpmnModelInstance.Modify(sourceProcess)
                                               .ChangeElementId(BOUNDARY_ID, NEW_BOUNDARY_ID);

            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(sourceProcess);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(targetProcess);

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities("subProcess1", "subProcess1")
                .MapActivities(USER_TASK_1_ID, USER_TASK_1_ID)
                .MapActivities("subProcess2", "subProcess2")
                .MapActivities(USER_TASK_2_ID, USER_TASK_2_ID)
                .MapActivities(BOUNDARY_ID, NEW_BOUNDARY_ID)
                .UpdateEventTrigger()
                .Build();

            // when
            testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            // then
            eventTrigger.AssertEventTriggerMigrated(testHelper, NEW_BOUNDARY_ID);

            // and it is possible to successfully complete the migrated instance
            testHelper.CompleteTask(USER_TASK_1_ID);
            testHelper.CompleteTask(USER_TASK_2_ID);
            testHelper.AssertProcessEnded(testHelper.SnapshotBeforeMigration.ProcessInstanceId);
        }
Ejemplo n.º 19
0
        public virtual void testUpdateEventSignal()
        {
            // given
            IBpmnModelInstance sourceProcess = ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                               //.ActivityBuilder(USER_TASK_ID)
                                               //.BoundaryEvent(BOUNDARY_ID)
                                               //.Signal(SIGNAL_NAME)
                                               //.UserTask(AFTER_BOUNDARY_TASK)
                                               //.EndEvent()
                                               //.Done()
            ;
            IBpmnModelInstance targetProcess = ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                               //.ActivityBuilder(USER_TASK_ID)
                                               //.BoundaryEvent(BOUNDARY_ID)
                                               //.Signal("new" + SIGNAL_NAME)
                                               //.UserTask(AFTER_BOUNDARY_TASK)
                                               //.EndEvent()
                                               //.Done()
            ;

            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(sourceProcess);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(targetProcess);

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities(USER_TASK_ID, USER_TASK_ID)
                .MapActivities(BOUNDARY_ID, BOUNDARY_ID)
                .UpdateEventTrigger()
                .Build();

            // when
            testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            // then
            testHelper.AssertEventSubscriptionMigrated(BOUNDARY_ID, SIGNAL_NAME, BOUNDARY_ID, "new" + SIGNAL_NAME);

            // and it is possible to successfully complete the migrated instance
            rule.RuntimeService.SignalEventReceived("new" + SIGNAL_NAME);
            testHelper.CompleteTask(AFTER_BOUNDARY_TASK);
            testHelper.AssertProcessEnded(testHelper.SnapshotBeforeMigration.ProcessInstanceId);
        }
Ejemplo n.º 20
0
        public virtual IMigratingBpmnEventTrigger AddEventSubProcess(IProcessEngine engine,
                                                                     IBpmnModelInstance modelInstance, string parentId, string subProcessId, string startEventId)
        {
            ModifiableBpmnModelInstance.Wrap(modelInstance)
            .AddSubProcessTo(parentId)
            //.Id(subProcessId)
            .TriggerByEvent()
            ////.EmbeddedSubProcess()
            //.StartEvent(startEventId)
            //.TimerWithDuration("PT10M")
            .SubProcessDone()
            .Done();

            var trigger = new TimerEventTrigger();

            trigger.Engine      = engine;
            trigger.ActivityId  = startEventId;
            trigger.HandlerType = TimerStartEventSubprocessJobHandler.TYPE;

            return(trigger);
        }
Ejemplo n.º 21
0
        public virtual IMigratingBpmnEventTrigger AddEventSubProcess(IProcessEngine engine,
                                                                     IBpmnModelInstance modelInstance, string parentId, string subProcessId, string startEventId)
        {
            ModifiableBpmnModelInstance.Wrap(modelInstance)
            .AddSubProcessTo(parentId)
            //.Id(subProcessId)
            .TriggerByEvent()
            ////.EmbeddedSubProcess()
            //.StartEvent(startEventId)
            //.Signal(SIGNAL_NAME)
            .SubProcessDone()
            .Done();

            var trigger = new SignalTrigger();

            trigger.engine     = engine;
            trigger.signalName = SIGNAL_NAME;
            trigger.activityId = startEventId;

            return(trigger);
        }
Ejemplo n.º 22
0
        public virtual IMigratingBpmnEventTrigger AddEventSubProcess(IProcessEngine engine,
                                                                     IBpmnModelInstance modelInstance, string parentId, string subProcessId, string startEventId)
        {
            ModifiableBpmnModelInstance.Wrap(modelInstance)
            .AddSubProcessTo(parentId)
            //.Id(subProcessId)
            .TriggerByEvent()
            ////.EmbeddedSubProcess()
            //.StartEvent(startEventId)
            ////.Message(MESSAGE_NAME)
            .SubProcessDone()
            .Done();

            var trigger = new MessageTrigger();

            trigger.Engine      = engine;
            trigger.MessageName = MESSAGE_NAME;
            trigger.ActivityId  = startEventId;

            return(trigger);
        }
Ejemplo n.º 23
0
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDeleteProcessDefinitionCascade()
        [Test]   public virtual void testDeleteProcessDefinitionCascade()
        {
            // given process definition and a process instance
            IBpmnModelInstance bpmnModel = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process").StartEvent().UserTask().EndEvent().Done();

            deployment = repositoryService.CreateDeployment().AddModelInstance("process.bpmn", bpmnModel).Deploy();
            IProcessDefinition processDefinition = repositoryService.CreateProcessDefinitionQuery(c => c.Key == "process").First();

            runtimeService.CreateProcessInstanceByKey("process").ExecuteWithVariablesInReturn();

            //when the corresponding process definition is cascading deleted from the deployment
            repositoryService.DeleteProcessDefinition(processDefinition.Id, true);

            //then exist no process instance and no definition
            Assert.AreEqual(0, runtimeService.CreateProcessInstanceQuery().Count());
            Assert.AreEqual(0, repositoryService.CreateProcessDefinitionQuery().Count());
            if (processEngineConfiguration.HistoryLevel.Id >= HistoryLevelFields.HistoryLevelActivity.Id)
            {
                Assert.AreEqual(0, engineRule.HistoryService.CreateHistoricActivityInstanceQuery().Count());
            }
        }
        public virtual void createBatchModification()
        {
            //given
            IBpmnModelInstance instance = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process1").StartEvent().UserTask("user1").UserTask("user2").EndEvent().Done();
            IProcessDefinition processDefinition = testHelper.DeployAndGetDefinition(instance);

            IList<string> instances = new List<string>();
            for (int i = 0; i < 2; i++)
            {
                IProcessInstance processInstance = engineRule.RuntimeService.StartProcessInstanceByKey("process1");
                instances.Add(processInstance.Id);
            }

            authRule.Init(scenario).WithUser("userId").BindResource("batchId", "*").Start();

            // when
            // Todo: IRuntimeService.CreateModification(..)
            //engineRule.RuntimeService.createModification(processDefinition.Id).StartAfterActivity("user1").processInstanceIds(instances).ExecuteAsync();

            // then
            authRule.AssertScenario(scenario);
        }
        private void assertFlowElementIs(Type elementClass)
        {
            IBpmnModelInstance modelInstance = ModelExecutionContextExecutionListener.ModelInstance;

            Assert.NotNull(modelInstance);

            IModel model = modelInstance.Model;
            IEnumerable <IModelElementInstance> events = modelInstance.GetModelElementsByType(model.GetType(typeof(IEvent)));

            Assert.AreEqual(3, events.Count());
            IEnumerable <IModelElementInstance> gateways = modelInstance.GetModelElementsByType(model.GetType(typeof(IGateway)));

            Assert.AreEqual(1, gateways.Count());
            IEnumerable <IModelElementInstance> tasks = modelInstance.GetModelElementsByType(model.GetType(typeof(ITask)));

            Assert.AreEqual(1, tasks.Count());

            IFlowElement flowElement = ModelExecutionContextExecutionListener.FlowElement;

            Assert.NotNull(flowElement);
            Assert.True(elementClass.IsAssignableFrom(flowElement.GetType()));
        }
Ejemplo n.º 26
0
        public virtual IMigratingBpmnEventTrigger AddEventSubProcess(IProcessEngine engine,
                                                                     IBpmnModelInstance modelInstance, string parentId, string subProcessId, string startEventId)
        {
            ModifiableBpmnModelInstance.Wrap(modelInstance)
            .AddSubProcessTo(parentId)
            //.Id(subProcessId)
            .TriggerByEvent()
            ////.EmbeddedSubProcess()
            //.StartEvent(startEventId)
            //.Condition(VAR_CONDITION)
            .SubProcessDone()
            .Done();

            var trigger = new ConditionalEventTrigger();

            trigger.Engine        = engine;
            trigger.VariableName  = "any";
            trigger.VariableValue = "any";
            trigger.ActivityId    = startEventId;

            return(trigger);
        }
Ejemplo n.º 27
0
        public virtual void testUpdateEventMessageNameWithExpression()
        {
            // given
            var messageNameWithExpression    = "new" + MESSAGE_NAME + "-${var}";
            var sourceProcess                = ProcessModels.OneTaskProcess;
            IBpmnModelInstance targetProcess = ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess)
                                               //.ActivityBuilder(USER_TASK_ID)
                                               //.BoundaryEvent(BOUNDARY_ID)
                                               //.Message(messageNameWithExpression)
                                               //.UserTask(AFTER_BOUNDARY_TASK)
                                               //.EndEvent()
                                               //.Done()
            ;

            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(sourceProcess);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(targetProcess);

            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities(USER_TASK_ID, USER_TASK_ID)
                .Build();

            var variables = new Dictionary <string, object>();

            variables["var"] = "foo";

            // when
            testHelper.CreateProcessInstanceAndMigrate(migrationPlan, variables);

            // the message event subscription's event name has changed
            var resolvedMessageName = "new" + MESSAGE_NAME + "-foo";

            testHelper.AssertEventSubscriptionCreated(BOUNDARY_ID, resolvedMessageName);

            // and it is possible to successfully complete the migrated instance
            rule.RuntimeService.CorrelateMessage(resolvedMessageName);
            testHelper.CompleteTask(AFTER_BOUNDARY_TASK);
            testHelper.AssertProcessEnded(testHelper.SnapshotBeforeMigration.ProcessInstanceId);
        }
Ejemplo n.º 28
0
        public virtual void testMigrateBoundaryEventOnConcurrentScopeUserTaskAndTriggerEvent()
        {
            // given
            var sourceProcess = ProcessModels.ScopeTaskProcess.Clone();
            var eventTrigger  = eventFactory.AddBoundaryEvent(rule.ProcessEngine, sourceProcess,
                                                              USER_TASK_1_ID, BOUNDARY_ID);

            ModifiableBpmnModelInstance.Wrap(sourceProcess)
            //.FlowNodeBuilder(BOUNDARY_ID)
            //.UserTask(AFTER_BOUNDARY_TASK)
            //.EndEvent()
            //.Done()
            ;

            IBpmnModelInstance targetProcess = ModifiableBpmnModelInstance.Modify(sourceProcess)
                                               .ChangeElementId("boundary", "newBoundary");

            var sourceProcessDefinition = testHelper.DeployAndGetDefinition(sourceProcess);
            var targetProcessDefinition = testHelper.DeployAndGetDefinition(targetProcess);


            var migrationPlan =
                rule.RuntimeService.CreateMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id)
                .MapActivities(USER_TASK_1_ID, USER_TASK_1_ID)
                .MapActivities(USER_TASK_2_ID, USER_TASK_2_ID)
                .MapActivities(BOUNDARY_ID, NEW_BOUNDARY_ID)
                .UpdateEventTrigger()
                .Build();

            // when
            var processInstance = testHelper.CreateProcessInstanceAndMigrate(migrationPlan);

            // then it is possible to trigger the event and successfully complete the migrated instance
            eventTrigger.InContextOf(NEW_BOUNDARY_ID)
            .Trigger(processInstance.Id);
            testHelper.CompleteTask(AFTER_BOUNDARY_TASK);
            testHelper.CompleteTask(USER_TASK_2_ID);
            testHelper.AssertProcessEnded(testHelper.SnapshotBeforeMigration.ProcessInstanceId);
        }
Ejemplo n.º 29
0
        public virtual void testEndExecutionListenerIsCalledOnlyOnce()
        {
            //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            IBpmnModelInstance modelInstance = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("conditionalProcessKey")
                                               .StartEvent()
                                               .UserTask()
                                               .CamundaExecutionListenerClass(ExecutionListenerFields.EventNameEnd, typeof(SetVariableDelegate).FullName)
                                               .CamundaExecutionListenerClass(ExecutionListenerFields.EventNameEnd,
                                                                              typeof(RecorderExecutionListener).FullName)
                                               .EndEvent()
                                               .Done();

            modelInstance = ModifiableBpmnModelInstance.Modify(modelInstance)
                            .AddSubProcessTo("conditionalProcessKey")
                            .TriggerByEvent()
                            //.EmbeddedSubProcess()
                            //.StartEvent()
                            //.Interrupting(true)
                            //.ConditionalEventDefinition()
                            //.Condition("${variable == 1}")
                            //.ConditionalEventDefinitionDone()
                            .EndEvent()
                            .Done();

            testHelper.Deploy(modelInstance);

            // given
            var procInst = runtimeService.StartProcessInstanceByKey("conditionalProcessKey");
            IQueryable <ITask> taskQuery = taskService.CreateTaskQuery(c => c.ProcessInstanceId == procInst.Id);

            //when task is completed
            taskService.Complete(taskQuery.First()
                                 .Id);

            //then end listener sets variable and triggers conditional event
            //end listener should called only once
            Assert.AreEqual(1, RecorderExecutionListener.RecordedEvents.Count);
        }
Ejemplo n.º 30
0
        public virtual void testBusinessRuleTask()
        {
            IBpmnModelInstance modelInstance = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("testProcess").StartEvent().BusinessRuleTask("task").EndEvent().Done();

            IBusinessRuleTask task = (IBusinessRuleTask)modelInstance.GetModelElementById/*<IBusinessRuleTask>*/ ("task");

            task.CamundaDecisionRef = "decision";

            DeploymentId = repositoryService.CreateDeployment().AddModelInstance("process.bpmn", modelInstance).AddClasspathResource(DMN_FILE).Deploy().Id;

            Assert.AreEqual(0l, ExecutedDecisionElements);
            Assert.AreEqual(0l, ExecutedDecisionElementsFromDmnEngine);

            runtimeService.StartProcessInstanceByKey("testProcess", VARIABLES);

            Assert.AreEqual(16l, ExecutedDecisionElements);
            Assert.AreEqual(16l, ExecutedDecisionElementsFromDmnEngine);

            processEngineConfiguration.DbMetricsReporter.ReportNow();

            Assert.AreEqual(16l, ExecutedDecisionElements);
            Assert.AreEqual(16l, ExecutedDecisionElementsFromDmnEngine);
        }