public void TestVariableConditionWithVariableEvent()
        {
            //given process with boundary conditional event and defined variable event
            IBpmnModelInstance modelInstance = Specifier.GetProcessWithVarEvents(true, ConditionalVarEventUpdate);

            Engine.ManageDeployment(RepositoryService.CreateDeployment().AddModelInstance(ConditionalModel, modelInstance).Deploy());

            IDictionary <string, object> variables = ESS.FW.Bpm.Engine.Variable.Variables.CreateVariables();

            variables[VariableName + 1] = 0;
            IProcessInstance   procInst  = RuntimeService.StartProcessInstanceByKey(ConditionalEventProcessKey, variables);
            IQueryable <ITask> taskQuery = TaskService.CreateTaskQuery(c => c.ProcessInstanceId == procInst.Id);
            ITask task = taskQuery.First();

            Assert.IsNotNull(task);

            //when variable with name `variable` is set on execution
            RuntimeService.SetVariable(procInst.Id, VariableName, 1);

            //then nothing happens
            task = taskQuery.First();
            Assert.IsNotNull(task);
            Assert.Equals(TaskBeforeCondition, task.Name);
            Assert.Equals(1, ConditionEventSubscriptionQuery.Count());

            //when variable with name `variable1` is updated
            RuntimeService.SetVariable(procInst.Id, VariableName + 1, 1);

            //then execution is at user task after conditional intermediate event
            TasksAfterVariableIsSet = taskQuery.ToList();
            Assert.Equals(TaskAfterCondition, TasksAfterVariableIsSet.ElementAt(0).Name);
            Assert.Equals(0, ConditionEventSubscriptionQuery.Count());
        }
Пример #2
0
        public virtual void testVariableValue()
        {
            //given process with intermediate conditional event and variable with wrong value
            IDictionary <string, object> variables = ESS.FW.Bpm.Engine.Variable.Variables.CreateVariables();

            variables[VariableName] = 0;
            IProcessInstance procInst = RuntimeService.StartProcessInstanceByKey(ConditionalEventProcessKey, variables);

            //wait state is on conditional event, since condition is false
            IExecution execution = RuntimeService.CreateExecutionQuery(c => c.ProcessInstanceId == procInst.Id && c.ActivityId == ConditionalEvent).First();

            Assert.NotNull(execution);
            Assert.AreEqual(1, ConditionEventSubscriptionQuery.Count());

            //when variable is set to correct value
            RuntimeService.SetVariable(execution.Id, VariableName, 1);

            //then process instance is completed, since condition was true
            execution = RuntimeService.CreateExecutionQuery(c => c.ProcessInstanceId == procInst.Id && c.ActivityId == ConditionalEvent).First();
            Assert.IsNull(execution);

            procInst = RuntimeService.CreateProcessInstanceQuery(c => c.ProcessDefinitionId == ConditionalEventProcessKey).First();
            Assert.IsNull(procInst);
            Assert.AreEqual(0, ConditionEventSubscriptionQuery.Count());
        }
Пример #3
0
        public virtual void testCleanUpConditionalEventSubscriptions()
        {
            //given process with intermediate conditional event and variable with wrong value
            IDictionary <string, object> variables = ESS.FW.Bpm.Engine.Variable.Variables.CreateVariables();

            variables[VariableName] = 0;
            IProcessInstance procInst = RuntimeService.StartProcessInstanceByKey(ConditionalEventProcessKey, variables);

            //wait state is on conditional event, since condition is false
            IExecution execution = RuntimeService.CreateExecutionQuery(c => c.ProcessInstanceId == procInst.Id && c.ActivityId == ConditionalEvent).First();

            Assert.NotNull(execution);

            //condition subscription is created
            Assert.AreEqual(1, ConditionEventSubscriptionQuery.Count());

            //when variable is set to correct value
            RuntimeService.SetVariable(execution.Id, VariableName, 1);

            //then execution is on next IUser task and the subscription is deleted
            ITask task = TaskService.CreateTaskQuery(c => c.ProcessInstanceId == procInst.Id).First();

            Assert.NotNull(task);
            Assert.AreEqual(TaskAfterCondition, task.Name);
            Assert.AreEqual(0, ConditionEventSubscriptionQuery.Count());

            //and task can be completed which ends process instance
            TaskService.Complete(task.Id);
            Assert.IsNull(TaskService.CreateTaskQuery().First());
            Assert.IsNull(RuntimeService.CreateProcessInstanceQuery().First());
        }
Пример #4
0
        public virtual void testParallelVariableSetValueOnParent()
        {
            //given process with intermediate conditional event and variable with wrong value
            IDictionary <string, object> variables = ESS.FW.Bpm.Engine.Variable.Variables.CreateVariables();

            variables[VariableName] = 0;
            IProcessInstance procInst = RuntimeService.StartProcessInstanceByKey(ConditionalEventProcessKey, variables);

            //when variable is set to correct value
            RuntimeService.SetVariable(procInst.Id, VariableName, 1);

            //then execution of conditional event is completed
            IExecution execution = RuntimeService.CreateExecutionQuery(c => c.ProcessInstanceId == procInst.Id && c.ActivityId == ConditionalEvent + 1).First();

            Assert.IsNull(execution);

            //when second variable is set to correct value
            RuntimeService.SetVariable(procInst.Id, VariableName, 2);

            //then execution and process instance is ended, since both conditions was true
            execution = RuntimeService.CreateExecutionQuery(c => c.ProcessInstanceId == procInst.Id && c.ActivityId == ConditionalEvent + 2).First();
            Assert.IsNull(execution);
            procInst = RuntimeService.CreateProcessInstanceQuery(c => c.ProcessDefinitionId == ConditionalEventProcessKey).First();
            Assert.IsNull(procInst);
        }
Пример #5
0
        public virtual void testSubProcessVariableSetValueOnParent()
        {
            //given process with intermediate conditional event and variable with wrong value
            IDictionary <string, object> variables = ESS.FW.Bpm.Engine.Variable.Variables.CreateVariables();

            variables[VariableName] = 0;
            IProcessInstance procInst = RuntimeService.StartProcessInstanceByKey(ConditionalEventProcessKey, variables);

            //when variable is set to correct value
            RuntimeService.SetVariable(procInst.Id, VariableName, 1);

            //then process instance is ended, since condition was true
            procInst = RuntimeService.CreateProcessInstanceQuery(c => c.ProcessDefinitionId == ConditionalEventProcessKey).First();
            Assert.IsNull(procInst);
        }
        public void TestNonInterruptingVariableConditionWithVariableName()
        {
            //given process with non interrupting boundary conditional event and defined variable name and true condition
            IBpmnModelInstance modelInstance = Specifier.GetProcessWithVarName(false, TrueCondition);

            Engine.ManageDeployment(RepositoryService.CreateDeployment().AddModelInstance(ConditionalModel, modelInstance).Deploy());

            //when process is started
            IProcessInstance   procInst  = RuntimeService.StartProcessInstanceByKey(ConditionalEventProcessKey);
            IQueryable <ITask> taskQuery = TaskService.CreateTaskQuery(c => c.ProcessInstanceId == procInst.Id);

            //then first event is triggered since condition is true
            IList <ITask> tasks = taskQuery.ToList();

            Assert.Equals(2, tasks.Count);

            //when variable with name `variable1` is set on execution
            RuntimeService.SetVariable(procInst.Id, VariableName + 1, 1);

            //then nothing happens
            tasks = taskQuery.ToList();
            Assert.Equals(2, tasks.Count);
            Assert.Equals(1, ConditionEventSubscriptionQuery.Count());

            //when variable with name `variable` is set, updated and deleted
            RuntimeService.SetVariable(procInst.Id, VariableName, 1); //create
            RuntimeService.SetVariable(procInst.Id, VariableName, 1); //update
            RuntimeService.RemoveVariable(procInst.Id, VariableName); //delete

            //then execution is for four times at user task after conditional event
            //one from default behavior and three times from the variable events
            Assert.Equals(4, TaskService.CreateTaskQuery(c => c.Name == TaskAfterCondition).Count());
            TasksAfterVariableIsSet = taskQuery.ToList();
            Assert.Equals(5, TasksAfterVariableIsSet.Count);
            Assert.Equals(1, ConditionEventSubscriptionQuery.Count());
        }