public void TestNonInterruptingVariableConditionWithVariableEvent() { //given process with non interrupting boundary conditional event and defined variable event IBpmnModelInstance modelInstance = Specifier.GetProcessWithVarEvents(false, ConditionalVarEventUpdate); Engine.ManageDeployment(RepositoryService.CreateDeployment().AddModelInstance(ConditionalModel, modelInstance).Deploy()); IProcessInstance procInst = RuntimeService.StartProcessInstanceByKey(ConditionalEventProcessKey); IQueryable <ITask> taskQuery = TaskService.CreateTaskQuery(c => c.ProcessInstanceId == procInst.Id); ITask task = taskQuery.First(); Assert.IsNotNull(task); //when variable with name `variable` is set TaskService.SetVariable(task.Id, VariableName, 1); //create //then nothing happens task = taskQuery.First(); Assert.IsNotNull(task); //when variable is updated twice TaskService.SetVariable(task.Id, VariableName, 1); //update TaskService.SetVariable(task.Id, VariableName, 1); //update //then execution is for two times at user task after conditional event Assert.Equals(2, taskQuery.Where(c => c.Name == TaskAfterCondition).Count()); TasksAfterVariableIsSet = TaskService.CreateTaskQuery().ToList(); Assert.Equals(3, TasksAfterVariableIsSet.Count); Assert.Equals(1, ConditionEventSubscriptionQuery.Count()); }
public void TestVariableConditionWithVariableName() { //given process with boundary conditional event and defined variable name IBpmnModelInstance modelInstance = Specifier.GetProcessWithVarName(true, ConditionExpr); Engine.ManageDeployment(RepositoryService.CreateDeployment().AddModelInstance(ConditionalModel, modelInstance).Deploy()); IProcessInstance procInst = RuntimeService.StartProcessInstanceByKey(ConditionalEventProcessKey); IQueryable <ITask> taskQuery = TaskService.CreateTaskQuery(c => c.ProcessInstanceId == procInst.Id); ITask task = taskQuery.First(); Assert.IsNotNull(task); //AssertNotNull(task); //when variable with name `variable1` is set on execution TaskService.SetVariable(task.Id, VariableName + 1, 1); //then nothing happens task = taskQuery.First(); Assert.IsNotNull(task); Assert.Equals(TaskBeforeCondition, task.Name); Assert.Equals(1, ConditionEventSubscriptionQuery.Count()); //when variable with name `variable` is set on execution TaskService.SetVariable(task.Id, VariableName, 1); //then execution is at user task after conditional event TasksAfterVariableIsSet = taskQuery.ToList(); Assert.Equals(TaskAfterCondition, TasksAfterVariableIsSet.ElementAt(0).Name); Assert.Equals(0, ConditionEventSubscriptionQuery.Count()); }
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()); }
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()); }
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()); }
public virtual void testParallelVariableValue() { //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); IExecution execution1 = RuntimeService.CreateExecutionQuery(c => c.ProcessInstanceId == procInst.Id && c.ActivityId == ConditionalEvent + 1).First(); IExecution execution2 = RuntimeService.CreateExecutionQuery(c => c.ProcessInstanceId == procInst.Id && c.ActivityId == ConditionalEvent + 2).First(); Assert.AreEqual(2, ConditionEventSubscriptionQuery.Count()); //when variable is set to correct value RuntimeService.SetVariable(execution1.Id, VariableName, 1); //then execution of first conditional event is completed execution1 = RuntimeService.CreateExecutionQuery(c => c.ProcessInstanceId == procInst.Id && c.ActivityId == ConditionalEvent + 1).First(); Assert.IsNull(execution1); Assert.AreEqual(1, ConditionEventSubscriptionQuery.Count()); //when second variable is set to correct value RuntimeService.SetVariable(execution2.Id, VariableName, 2); //then execution and process instance is ended, since both conditions was true execution2 = RuntimeService.CreateExecutionQuery(c => c.ProcessInstanceId == procInst.Id && c.ActivityId == ConditionalEvent + 2).First(); Assert.IsNull(execution2); procInst = RuntimeService.CreateProcessInstanceQuery(c => c.ProcessDefinitionId == ConditionalEventProcessKey).First(); Assert.IsNull(procInst); Assert.AreEqual(0, ConditionEventSubscriptionQuery.Count()); }
public virtual void testFalseCondition() { //given process with intermediate conditional event IProcessInstance procInst = RuntimeService.StartProcessInstanceByKey(ConditionalEventProcessKey); IQueryable <ITask> taskQuery = TaskService.CreateTaskQuery(); ITask task = taskQuery.Where(c => c.ProcessInstanceId == procInst.Id).First(); Assert.NotNull(task); Assert.AreEqual(TaskBeforeCondition, task.Name); //when task before condition is completed TaskService.Complete(task.Id); //then next wait state is on conditional event, since condition is false //and a condition event subscription is create IExecution execution = RuntimeService.CreateExecutionQuery(c => c.ProcessInstanceId == procInst.Id && c.ActivityId == ConditionalEvent).First(); Assert.NotNull(execution); Assert.AreEqual(1, ConditionEventSubscriptionQuery.Count()); }
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()); }