Exemplo n.º 1
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());
        }
Exemplo n.º 2
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());
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public virtual void TestSimpleProcess()
        {
            RuntimeService.StartProcessInstanceByKey("simpleProcess");

            var task = TaskService.CreateTaskQuery().First();

            Assert.AreEqual("My Task", task.Name);

            TaskService.Complete(task.Id);
            Assert.AreEqual(0, RuntimeService.CreateProcessInstanceQuery().Count());
        }
Exemplo n.º 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);
        }