Example #1
0
        public void ReturnExecutorTestReplay()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver1, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver2, process);

            //退件到初始活动
            process = WfRuntime.GetProcessByProcessID(process.ID);
            WfReturnExecutor returnExec = new WfReturnExecutor(process.CurrentActivity, process.Activities[0]);

            returnExec.Execute();

            Assert.IsTrue(process.CurrentActivity.CreatorInstanceID != "");
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban));

            process = WfRuntime.GetProcessByProcessID(process.ID);
            IWfActivity act = process.Activities.FindActivityByDescriptorKey(process.CurrentActivity.Descriptor.AssociatedActivityKey);

            Assert.AreEqual(act.Assignees.Count, process.CurrentActivity.Assignees.Count);

            Assert.AreEqual(process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity.AssociatedActivityKey, act.Descriptor.ToTransitions[0].ToActivity.Key);
            Assert.IsTrue(process.Activities.FindActivityByDescriptorKey(process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity.Key).Assignees.Count > 0);
        }
Example #2
0
        private static void CheckOperationAndStatusAfterWithdrawProcess(string processId, string fromActivityId, string toActivityId)
        {
            IWfProcess process = WfRuntime.GetProcessByProcessID(processId);
            bool       flag    = false;

            for (int i = 0; i < process.Activities.Count; i++)
            {
                if (flag)
                {
                    Assert.AreEqual(WfActivityStatus.NotRunning, process.Activities[i].Status);
                    Assert.IsFalse(ProcessTestHelper.ExistsActivityUserTasks(process.Activities[i].ID, TaskStatus.Ban));
                }
                if (process.Activities[i].ID == toActivityId)
                {
                    Assert.AreEqual(WfActivityStatus.Running, process.Activities[i].Status);
                    Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.Activities[i].ID, TaskStatus.Ban));
                    flag = true;
                }

                if (process.Activities[i].ID == fromActivityId)
                {
                    Assert.IsFalse(ProcessTestHelper.ExistsActivityUserTasks(process.Activities[i].ID, TaskStatus.Ban));
                    Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.Activities[i].ID, TaskStatus.Yue));
                    break;
                }
            }
        }
Example #3
0
        public void ReturnExecutorTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver1, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver2, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.requestor, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            WfReturnExecutor returnExec = new WfReturnExecutor(process.CurrentActivity, process.Activities[1]);

            returnExec.Execute();

            process = WfRuntime.GetProcessByProcessID(process.ID);
            Assert.IsTrue(process.CurrentActivity.CreatorInstanceID != "");
            Assert.AreEqual(process.ElapsedActivities[process.ElapsedActivities.Count - 1].ID, process.CurrentActivity.CreatorInstanceID);

            WfMainStreamActivityDescriptorCollection coll = process.Descriptor.GetMainStreamActivities();

            Assert.AreEqual(6, coll.Count);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban));
        }
Example #4
0
        public void WaitAllCompleteOfSerialBranchProcessTest()
        {
            IWfProcess wfProcess = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Serial, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);

            AssertProcessStatus(wfProcess);

            CheckProcessRelationOperationAndStatus(wfProcess, false);

            //第一个子流程办结
            wfProcess.Activities[1].BranchProcessGroups[0].Branches[0].CompleteProcess(true);
            WfRuntime.PersistWorkflows();

            wfProcess = WfRuntime.GetProcessByProcessID(wfProcess.ID);
            Assert.AreEqual(WfProcessStatus.Completed, wfProcess.CurrentActivity.BranchProcessGroups[0].Branches[0].Status);
            Assert.AreEqual(WfProcessStatus.Running, wfProcess.CurrentActivity.BranchProcessGroups[0].Branches[1].Status);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProcess.CurrentActivity.BranchProcessGroups[0].Branches[1].InitialActivity.ID, TaskStatus.Ban));


            //第二个子流程办结
            wfProcess.CurrentActivity.BranchProcessGroups[0].Branches[1].CompleteProcess(true);
            WfRuntime.PersistWorkflows();


            ProcessTestHelper.ProcessPendingActivity(wfProcess.CurrentActivity.ID);

            IWfProcess wfProc = WfRuntime.GetProcessByProcessID(wfProcess.ID);

            Assert.AreEqual(WfProcessStatus.Completed, wfProc.CurrentActivity.BranchProcessGroups[0].Branches[0].Status);
            Assert.AreEqual(WfProcessStatus.Completed, wfProc.CurrentActivity.BranchProcessGroups[0].Branches[1].Status);

            Assert.AreEqual(WfActivityStatus.Running, wfProc.CurrentActivity.Status);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProc.CurrentActivity.ID, TaskStatus.Ban));
        }
Example #5
0
 private void CheckOperationAndStatusAfterCancelProcess(IWfProcess process)
 {
     Assert.AreEqual(WfProcessStatus.Aborted, process.Status);
     Assert.AreEqual(WfActivityStatus.Aborted, process.CurrentActivity.Status);
     Assert.IsFalse(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban));
     if (process.CurrentActivity.Descriptor.ActivityType != WfActivityType.CompletedActivity)
     {
         Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Yue));
     }
 }
Example #6
0
        public void WaitNoneCompleteOfSerialBranchProcessTest()
        {
            IWfProcess wfProcess = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Serial, WfBranchProcessBlockingType.WaitNoneOfBranchProcessComplete);

            Assert.AreEqual(WfActivityStatus.Running, wfProcess.CurrentActivity.Status);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProcess.CurrentActivity.ID, TaskStatus.Ban));

            Assert.AreEqual(WfProcessStatus.Running, wfProcess.CurrentActivity.BranchProcessGroups[0].Branches[0].Status);
            Assert.AreEqual(WfProcessStatus.NotRunning, wfProcess.CurrentActivity.BranchProcessGroups[0].Branches[1].Status);
        }
Example #7
0
        private static void CheckOperationAndStatusBeforeCancelProcess(IWfProcess process)
        {
            Assert.AreEqual(WfProcessStatus.Running, process.Status);

            if (process.CurrentActivity.BranchProcessGroups.IsBlocking(WfBranchGroupBlockingType.WaitAllBranchGroupsComplete))
            {
                Assert.AreEqual(WfActivityStatus.Pending, process.CurrentActivity.Status);
                Assert.IsFalse(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban));
            }
            else
            {
                Assert.AreEqual(WfActivityStatus.Running, process.CurrentActivity.Status);
                Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban));
            }
        }
Example #8
0
        public void AddApproverExecutorTest()
        {
            //Initial  NormalActivity  NormalActivity1 NormalActivity2 NormalActivity3 Completed
            IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;

            IWfProcessDescriptor     procDesp = WfProcessTestCommon.CreateProcessDescriptor();
            WfUserResourceDescriptor userDesp = new WfUserResourceDescriptor(user);

            procDesp.InitialActivity.Resources.Add(userDesp);

            WfProcessStartupParams  startParams = WfProcessTestCommon.GetInstanceOfWfProcessStartupParams(procDesp);
            WfStartWorkflowExecutor exec        = new WfStartWorkflowExecutor(null, startParams);
            IWfProcess proc = exec.Execute();             //启动流程

            IWfProcess wfp = WfRuntime.GetProcessByProcessID(proc.ID);

            MoveToExecutor(wfp);            //流转一步 ,即第2个节点

            IWfProcess           p         = WfRuntime.GetProcessByProcessID(proc.ID);
            WfAssigneeCollection assignees = new WfAssigneeCollection();

            assignees.Add((IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object);

            WfAddApproverExecutor addExec = new WfAddApproverExecutor(p.CurrentActivity, p.CurrentActivity, assignees);

            addExec.Execute();             //加签,即流转到加签点上

            IWfProcess process = WfRuntime.GetProcessByProcessID(p.ID);

            Assert.AreEqual(process.Descriptor.GetMainStreamActivities().Count, process.Activities.Count - 2, "动态添加两个活动,因被加签人要回到加签人");
            Assert.AreEqual(2, process.ElapsedActivities.Count);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban));
            Assert.IsTrue(process.CurrentActivity.Descriptor.ToTransitions.Count == 1);
            Assert.IsNotNull(process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity);

            IWfProcess wfProcess9 = WfRuntime.GetProcessByProcessID(process.ID);

            WfWithdrawExecutor withdrawExec = new WfWithdrawExecutor(wfProcess9.CurrentActivity, wfProcess9.CurrentActivity);

            withdrawExec.Execute();

            IWfProcess wfProcess1 = WfRuntime.GetProcessByProcessID(wfProcess9.ID);

            Assert.AreEqual(wfProcess1.Activities.Count, wfProcess1.Descriptor.GetMainStreamActivities().Count, "此处应该撤回到加签的活动点上,同时被加签的两个点都应该移除");
            Assert.AreEqual(1, wfProcess1.ElapsedActivities.Count);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProcess1.CurrentActivity.ID, TaskStatus.Ban));
            Assert.IsTrue(wfProcess1.CurrentActivity.Descriptor.ToTransitions.Count == 1);
        }
Example #9
0
        public void WfActivityAssigneesResourceTest()
        {
            IWfProcess process = GetProcessInstanceWithAssigneesResource();

            Assert.AreEqual(process.CurrentActivity.Assignees[0].User.ID, process.CurrentActivity.Descriptor.Resources.ToUsers()[0].ID);

            IWfActivityDescriptor actDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;
            WfTransferParams      par     = new WfTransferParams(actDesp);

            par.Assignees.Add(actDesp.FromTransitions[0].FromActivity.Resources.ToUsers()[0]);
            process.MoveTo(par);

            WfRuntime.PersistWorkflows();
            process = WfRuntime.GetProcessByProcessID(process.ID);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban));
        }
Example #10
0
        private static void CheckProcessRelationOperationAndStatus(IWfProcess wfProcess, bool isParallel)
        {
            Assert.AreEqual(WfActivityStatus.Pending, wfProcess.CurrentActivity.Status);
            Assert.IsFalse(ProcessTestHelper.ExistsActivityUserTasks(wfProcess.CurrentActivity.ID, TaskStatus.Ban));

            if (isParallel)
            {
                wfProcess.CurrentActivity.BranchProcessGroups[0].Branches.Exists(p => p.Status == WfProcessStatus.Running);
                wfProcess.CurrentActivity.BranchProcessGroups[0].Branches.Exists(p => ProcessTestHelper.ExistsActivityUserTasks(p.ID, TaskStatus.Ban));
            }
            else
            {
                Assert.AreEqual(WfProcessStatus.Running, wfProcess.CurrentActivity.BranchProcessGroups[0].Branches[0].Status);
                Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProcess.CurrentActivity.BranchProcessGroups[0].Branches[0].CurrentActivity.ID, TaskStatus.Ban));
                Assert.AreEqual(WfProcessStatus.NotRunning, wfProcess.Activities[1].BranchProcessGroups[0].Branches[1].Status);
            }
        }
Example #11
0
        public void WaitAnyoneCompleteOfSerialBranchProcessTest()
        {
            IWfProcess wfProcess = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Serial, WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete);

            CheckProcessRelationOperationAndStatus(wfProcess, false);

            //
            ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(wfProcess.CurrentActivity, WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete);
            ProcessTestHelper.ProcessPendingActivity(wfProcess.CurrentActivity.ID);

            IWfProcess wfProc = WfRuntime.GetProcessByProcessID(wfProcess.ID);

            Assert.AreEqual(WfProcessStatus.Completed, wfProc.CurrentActivity.BranchProcessGroups[0].Branches[0].Status);
            Assert.AreEqual(WfProcessStatus.Running, wfProc.CurrentActivity.BranchProcessGroups[0].Branches[1].Status);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProcess.CurrentActivity.BranchProcessGroups[0].Branches[1].InitialActivity.ID, TaskStatus.Ban));
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProc.CurrentActivity.ID, TaskStatus.Ban));
        }
Example #12
0
        public void WaitAllCompleteOfParallelBranchProcessTest()
        {
            IWfProcess wfProcess = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);

            AssertProcessStatus(wfProcess);

            CheckProcessRelationOperationAndStatus(wfProcess, true);

            //
            ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(wfProcess.CurrentActivity, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);
            ProcessTestHelper.ProcessPendingActivity(wfProcess.CurrentActivity.ID);

            IWfProcess wfProc = WfRuntime.GetProcessByProcessID(wfProcess.ID);

            Assert.AreEqual(WfActivityStatus.Running, wfProc.CurrentActivity.Status);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProc.CurrentActivity.ID, TaskStatus.Ban));
            wfProc.CurrentActivity.BranchProcessGroups[0].Branches.Exists(p => p.Status == WfProcessStatus.Completed);
        }
Example #13
0
        private static IWfProcess GetProcessInstance(bool movetoCompletedActivity)
        {
            IWfProcess process = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete);

            process = WfRuntime.GetProcessByProcessID(process.ID);

            if (movetoCompletedActivity)
            {
                //使第二个节点可以正常流转
                ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(process.CurrentActivity, WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete);
                ProcessTestHelper.ProcessPendingActivity(process.CurrentActivity.ID);

                IWfProcess wfProc = WfRuntime.GetProcessByProcessID(process.ID);

                Assert.AreEqual(WfActivityStatus.Running, wfProc.Activities[1].Status);
                Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProc.CurrentActivity.ID, TaskStatus.Ban));
                Assert.AreEqual(WfProcessStatus.Completed, wfProc.CurrentActivity.BranchProcessGroups[0].Branches[0].Status);
                Assert.AreEqual(WfProcessStatus.Running, wfProc.CurrentActivity.BranchProcessGroups[0].Branches[1].Status);


                //初始节点已完成,从第二个节点开始
                for (int i = 2; i < process.Activities.Count; i++)
                {
                    if (process.Activities[i].Descriptor.ActivityType != WfActivityType.CompletedActivity)
                    {
                        process = WfRuntime.GetProcessByProcessID(process.ID);
                        WfTransferParams transferPara = new WfTransferParams(process.Activities[i].Descriptor);
                        transferPara.Assignees.Add((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object);

                        process.MoveTo(transferPara);
                        WfRuntime.PersistWorkflows();
                    }
                }
            }

            process = WfRuntime.GetProcessByProcessID(process.ID);
            return(process);
        }
Example #14
0
        public void SingleStepWithDrawByDynamicAdd()
        {
            //Initial  NormalActivity  NormalActivity1 NormalActivity2 NormalActivity3 Completed
            IUser  user           = (IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object;
            string procResourceId = GetStartWorkflowResourceID(user);

            WfProcessCollection processes = WfRuntime.GetProcessByResourceID(procResourceId);
            string processId = processes[0].ID;

            MoveToExecutor(processes[0]);
            Assert.AreEqual(1, processes[0].ElapsedActivities.Count);            //initial

            processes = WfRuntime.GetProcessByResourceID(procResourceId);
            List <IUser> users;

            ConsignExecutor(processes[0], out users);

            IWfProcess proc = WfRuntime.GetProcessByProcessID(processId);

            Assert.AreEqual(2, proc.ElapsedActivities.Count);            //NormalActivity
            ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(proc.CurrentActivity, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);
            WfRuntime.PersistWorkflows();
            ProcessTestHelper.ProcessPendingActivity(proc.CurrentActivity.ID);

            proc = WfRuntime.GetProcessByProcessID(processId);
            WfWithdrawExecutor withdrawExec = new WfWithdrawExecutor(proc.CurrentActivity, proc.CurrentActivity);            //"NO"

            withdrawExec.Execute();

            proc = WfRuntime.GetProcessByProcessID(processId);
            Assert.AreEqual(1, proc.ElapsedActivities.Count);
            Assert.AreEqual(proc.Descriptor.GetMainStreamActivities().Count, proc.Activities.Count);
            Assert.AreEqual(proc.ElapsedActivities[0].Descriptor.ToTransitions[0].ToActivity.Key, proc.CurrentActivity.Descriptor.Key);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(proc.CurrentActivity.ID, TaskStatus.Ban));
            Assert.IsTrue(proc.CurrentActivity.Descriptor.ToTransitions.Count == 1);
        }