コード例 #1
0
        public virtual void TestExceptionHandling()
        {
            // If variable value is != 'throw-exception', process goes
            // through service task and ends immidiately
            IDictionary <string, ITypedValue> vars = new Dictionary <string, ITypedValue>();

            vars["var"] = new StringValueImpl("no-exception");


            var ins = runtimeService.StartProcessInstanceByKey("exceptionHandling", vars);

            Assert.AreEqual(0, runtimeService.CreateProcessInstanceQuery(c => c.Id == ins.Id)
                            .Count());

            // If variable value == 'throw-exception', process executes
            // service task, which generates and catches exception,
            // and takes sequence flow to IUser task
            vars["var"] = new StringValueImpl("throw-exception");

            runtimeService.StartProcessInstanceByKey("exceptionHandling", vars);
            ITask task = taskService.CreateTaskQuery()
                         .First();

            // Assert.AreEqual("Fix Exception", task.Name);
            Assert.AreEqual("subtask two", task.Name);
        }
コード例 #2
0
        protected internal virtual IProcessInstance startTestProcess(string input)
        {
            var dic = new Dictionary <string, ITypedValue>();

            dic["input"] = new StringValueImpl(input);
            return(runtimeService.StartProcessInstanceByKey("testProcess"
                                                            , dic));
        }
コード例 #3
0
        public virtual void TestBackwardsCompatibleExpression()
        {
            IDictionary <string, ITypedValue> variables = new Dictionary <string, ITypedValue>();

            variables["var"] = new StringValueImpl("---");

            IProcessInstance pi = runtimeService.StartProcessInstanceByKey("BackwardsCompatibleExpressionProcess",
                                                                           variables);

            Assert.AreEqual("..---..", runtimeService.GetVariable(pi.Id, "result"));
        }
コード例 #4
0
        public virtual void TestJavaServiceDelegation()
        {
            IDictionary <string, ITypedValue> vars = new Dictionary <string, ITypedValue>();

            vars["input"] = new StringValueImpl("Activiti BPM Engine");
            var pi        = runtimeService.StartProcessInstanceByKey("javaServiceDelegation", vars);
            var execution =
                runtimeService.CreateExecutionQuery(c => c.ProcessInstanceId == pi.Id && c.ActivityId == "waitState")
                .FirstOrDefault();

            Assert.AreEqual("ACTIVITI BPM ENGINE", runtimeService.GetVariable(execution?.Id, "input"));
        }
コード例 #5
0
        public virtual void TestSetServiceResultToProcessVariables()
        {
            IDictionary <string, ITypedValue> variables = new Dictionary <string, ITypedValue>();

            variables["bean"] = new StringValueImpl("ok");


            IProcessInstance pi = runtimeService.StartProcessInstanceByKey("setServiceResultToProcessVariables",
                                                                           variables);

            Assert.AreEqual("ok", runtimeService.GetVariable(pi.Id, "result"));
        }
コード例 #6
0
        protected internal virtual IProcessInstance startTestProcess(string input)
        {
            var dic = new Dictionary <string, ITypedValue>();

            dic["input"] = new StringValueImpl(input);
            IProcessInstance processInstance = runtimeService.StartProcessInstanceByKey("testProcess", dic);

            // get the result from an execution listener that is invoked at the end of the business rule activity
            results = DecisionResultTestListener.DecisionResult;
            Assert.NotNull(results);

            return(processInstance);
        }
コード例 #7
0
        public virtual void TestUelExpression()
        {
            IDictionary <string, ITypedValue> variables = new Dictionary <string, ITypedValue>();

            variables["input"] = new StringValueImpl("right");

            IProcessInstance pi = runtimeService.StartProcessInstanceByKey("condSeqFlowUelExpr", variables);

            ITask task = taskService.CreateTaskQuery(c => c.ProcessInstanceId == pi.Id).First();

            Assert.NotNull(task);
            Assert.AreEqual("task right", task.Name);
        }
コード例 #8
0
        public virtual void TestJavaServiceMethodDelegation()
        {
            IDictionary <string, ITypedValue> vars = new Dictionary <string, ITypedValue>();

            vars["name"]       = new StringValueImpl("kermit");
            vars["gender"]     = new StringValueImpl("male");
            vars["genderBean"] = new ObjectValueImpl(new GenderBean());
            var pi        = runtimeService.StartProcessInstanceByKey("javaServiceMethodDelegation", vars);
            var execution =
                runtimeService.CreateExecutionQuery(c => c.ProcessInstanceId == pi.Id && c.ActivityId == "waitState")
                .FirstOrDefault();

            Assert.AreEqual("YOUR GENDER IS: MALE", runtimeService.GetVariable(execution?.Id, "result"));
        }
コード例 #9
0
ファイル: SignalEventTest.cs プロジェクト: zf321/ESS.FW.Bpm
        public virtual void testSignalCatchBoundaryWithVariables()
        {
            Dictionary <string, ITypedValue> variables1 = new Dictionary <string, ITypedValue>();

            variables1["processName"] = new StringValueImpl("catchSignal");
            IProcessInstance pi = runtimeService.StartProcessInstanceByKey("catchSignal", variables1);

            Dictionary <string, ITypedValue> variables2 = new Dictionary <string, ITypedValue>();

            variables2["processName"] = new StringValueImpl("throwSignal");
            runtimeService.StartProcessInstanceByKey("throwSignal", variables2);

            Assert.AreEqual("catchSignal", runtimeService.GetVariable(pi.Id, "processName"));
        }
コード例 #10
0
ファイル: AsyncAfterTest.cs プロジェクト: zf321/ESS.FW.Bpm
        public virtual void testAsyncAfterServiceTaskMultipleTransitions()
        {
            IDictionary <string, ITypedValue> varMap = new Dictionary <string, ITypedValue>();

            varMap["flowToTake"] = new StringValueImpl("flowToTake");

            IProcessInstance pi = runtimeService.StartProcessInstanceByKey("testProcess", varMap);

            // the service task is completely invoked
            AssertListenerStartInvoked(pi);
            AssertBehaviorInvoked(pi);
            AssertListenerEndInvoked(pi);

            // and the execution is Waiting *after* the service task
            IJob continuationJob = managementService.CreateJobQuery().First();

            Assert.NotNull(continuationJob);

            // if we execute the job, the process instance continues along the selected path
            managementService.ExecuteJob(continuationJob.Id);

            Assert.NotNull(runtimeService.CreateExecutionQuery(c => c.ActivityId == "taskAfterFlow2").First());
            Assert.IsNull(runtimeService.CreateExecutionQuery(c => c.ActivityId == "taskAfterFlow3").First());

            // end the process
            runtimeService.Signal(pi.Id);

            //////////////////////////////////////////////////////////////

            // start process instance
            varMap = new Dictionary <string, ITypedValue>();
            varMap["flowToTake"] = new StringValueImpl("flow3");
            pi = runtimeService.StartProcessInstanceByKey("testProcess", varMap);

            // the service task is completely invoked
            AssertListenerStartInvoked(pi);
            AssertBehaviorInvoked(pi);
            AssertListenerEndInvoked(pi);

            // and the execution is Waiting *after* the service task
            continuationJob = managementService.CreateJobQuery().First();
            Assert.NotNull(continuationJob);

            // if we execute the job, the process instance continues along the selected path
            managementService.ExecuteJob(continuationJob.Id);

            Assert.IsNull(runtimeService.CreateExecutionQuery(c => c.ActivityId == "taskAfterFlow2").First());
            Assert.NotNull(runtimeService.CreateExecutionQuery(c => c.ActivityId == "taskAfterFlow3").First());
        }
コード例 #11
0
        public virtual void TestScriptResourceExpression()
        {
            string[] directions = new string[] { "left", "right" };
            IDictionary <string, ITypedValue> variables = new Dictionary <string, ITypedValue>();

            foreach (string direction in directions)
            {
                variables["foo"] = new StringValueImpl(direction);
                runtimeService.StartProcessInstanceByKey("process", variables);

                ITask task = taskService.CreateTaskQuery().First();
                Assert.AreEqual(direction, task.TaskDefinitionKey);
                taskService.Complete(task.Id);
            }
        }
コード例 #12
0
        public virtual void testNoExpressionTrueThrowsException()
        {
            IDictionary <string, ITypedValue> variables = new Dictionary <string, ITypedValue>();

            variables["input"] = new StringValueImpl("non-existing-value");
            //  IDictionary<string, object> variables = CollectionUtil.singletonMap("input", "non-existing-value");
            try
            {
                runtimeService.StartProcessInstanceByKey("condSeqFlowUelExpr", variables);
                Assert.Fail("Expected ProcessEngineException");
            }
            catch (ProcessEngineException e)
            {
                AssertTextPresent("No conditional sequence flow leaving the Flow Node 'theStart' could be selected for continuing the process", e.Message);
            }
            catch (System.Exception ex)
            {
            }
        }
コード例 #13
0
        public virtual void TestExpressionFieldInjection()
        {
            //IDictionary<string, object> vars = new Dictionary<string, object>();
            //vars["name"] = "kermit";
            //vars["gender"] = "male";
            //vars["genderBean"] = new GenderBean();

            IDictionary <string, ITypedValue> vars = new Dictionary <string, ITypedValue>();

            vars["name"]       = new StringValueImpl("kermit");
            vars["gender"]     = new StringValueImpl("male");
            vars["genderBean"] = new ObjectValueImpl(new GenderBean());

            // var pi = runtimeService.StartProcessInstanceByKey("simpleSubProcess", vars);

            var pi        = runtimeService.StartProcessInstanceByKey("expressionFieldInjection", vars);
            var execution =
                runtimeService.CreateExecutionQuery(c => c.ProcessInstanceId == pi.Id && c.ActivityId == "waitState")
                .First();

            Assert.AreEqual("timrek .rM olleH", runtimeService.GetVariable(execution.Id, "var2"));
            Assert.AreEqual("elam :si redneg ruoY", runtimeService.GetVariable(execution.Id, "var1"));
        }
コード例 #14
0
ファイル: VariableScopeTest.cs プロジェクト: zf321/ESS.FW.Bpm
        public virtual void TestVariableNamesScope()
        {
            // After starting the process, the task in the subprocess should be active
            IDictionary <string, ITypedValue> varMap = new Dictionary <string, ITypedValue>();

            varMap["test"]       = new StringValueImpl("test");
            varMap["helloWorld"] = new StringValueImpl("helloWorld");
            var pi             = runtimeService.StartProcessInstanceByKey("simpleSubProcess", varMap);
            var subProcessTask = taskService.CreateTaskQuery(c => c.ProcessInstanceId == pi.Id)
                                 .First();//.Where(c=>c.ProcessInstanceId==pi.Id).First();

            runtimeService.SetVariableLocal(pi.ProcessInstanceId, "mainProcessLocalVariable", "Hello World");

            Assert.AreEqual("Task in subprocess", subProcessTask.Name);

            runtimeService.SetVariableLocal(subProcessTask.ExecutionId, "subProcessLocalVariable", "Hello SubProcess");

            // Returns a set of local variablenames of pi
            var result =
                processEngineConfiguration.CommandExecutorTxRequired.Execute(new GetVariableNamesCommand(this,
                                                                                                         pi.ProcessInstanceId, true));

            // pi contains local the variablenames "test", "helloWorld" and "mainProcessLocalVariable" but not "subProcessLocalVariable"
            Assert.True(result.Contains("test"));
            Assert.True(result.Contains("helloWorld"));
            Assert.True(result.Contains("mainProcessLocalVariable"));
            Assert.IsFalse(result.Contains("subProcessLocalVariable"));

            // Returns a set of global variablenames of pi
            result =
                processEngineConfiguration.CommandExecutorTxRequired.Execute(new GetVariableNamesCommand(this,
                                                                                                         pi.ProcessInstanceId, false));

            // pi contains global the variablenames "test", "helloWorld" and "mainProcessLocalVariable" but not "subProcessLocalVariable"
            Assert.True(result.Contains("test"));
            Assert.True(result.Contains("mainProcessLocalVariable"));
            Assert.True(result.Contains("helloWorld"));
            Assert.IsFalse(result.Contains("subProcessLocalVariable"));

            // Returns a set of local variablenames of subProcessTask execution
            result =
                processEngineConfiguration.CommandExecutorTxRequired.Execute(new GetVariableNamesCommand(this,
                                                                                                         subProcessTask.ExecutionId, true));

            // subProcessTask execution contains local the variablenames "test", "subProcessLocalVariable" but not "helloWorld" and "mainProcessLocalVariable"
            Assert.True(result.Contains("test")); // the variable "test" was set locally by SetLocalVariableTask
            Assert.True(result.Contains("subProcessLocalVariable"));
            Assert.IsFalse(result.Contains("helloWorld"));
            Assert.IsFalse(result.Contains("mainProcessLocalVariable"));

            // Returns a set of global variablenames of subProcessTask execution
            result =
                processEngineConfiguration.CommandExecutorTxRequired.Execute(new GetVariableNamesCommand(this,
                                                                                                         subProcessTask.ExecutionId, false));

            // subProcessTask execution contains global all defined variablenames
            Assert.True(result.Contains("test")); // the variable "test" was set locally by SetLocalVariableTask
            Assert.True(result.Contains("subProcessLocalVariable"));
            Assert.True(result.Contains("helloWorld"));
            Assert.True(result.Contains("mainProcessLocalVariable"));

            taskService.Complete(subProcessTask.Id);
        }