public virtual void TestSequence()
        {
            var verifier = new ActivityInstanceVerification();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("one")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("two")
                .EndActivity()
                .CreateActivity("two")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("three")
                .EndActivity()
                .CreateActivity("three")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            verifier.AssertStartInstanceCount(1, "one");
            verifier.AssertStartInstanceCount(1, "two");
            verifier.AssertStartInstanceCount(1, "three");
        }
Exemple #2
0
        public virtual void TestEmbeddedSubProcessNoEnd()
        {
            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .Transition("endInside")
                .EndActivity()
                .CreateActivity("endInside")
                .Behavior(new End())
                .EndActivity()
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.True(processInstance.IsEnded);
        }
Exemple #3
0
        public virtual void TestSimpleProcessInstanceEnd()
        {
            var eventCollector = new EventCollector();

            var processDefinition =
                new ProcessDefinitionBuilder().ExecutionListener(
                    PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("Wait")
                .EndActivity()
                .CreateActivity("Wait")
                .Behavior(new WaitState())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Console.Error.WriteLine(eventCollector);

            processInstance.DeleteCascade("test");

            Console.Error.WriteLine();
            Console.Error.WriteLine(eventCollector);
        }
Exemple #4
0
        public virtual void TestSingleWaitState()
        {
            var processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("one")
                .Initial()
                .Behavior(new Automatic())
                .Transition("two")
                .EndActivity()
                .CreateActivity("two")
                .Behavior(new WaitState())
                .Transition("three")
                .EndActivity()
                .CreateActivity("three")
                .Behavior(new End())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            var activityInstance = processInstance.FindExecution("two");

            Assert.NotNull(activityInstance);

            activityInstance.Signal(null, null);

            Assert.AreEqual(new List <string>(), processInstance.FindActiveActivityIds());
            Assert.True(processInstance.IsEnded);
        }
Exemple #5
0
        public virtual void TestParallelEnd()
        {
            var processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("fork")
                .EndActivity()
                .CreateActivity("fork")
                .Behavior(new ParallelGateway())
                .Transition("end1")
                .Transition("end2")
                .EndActivity()
                .CreateActivity("end1")
                .Behavior(new End())
                .EndActivity()
                .CreateActivity("end2")
                .Behavior(new End())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.True(processInstance.IsEnded);
        }
        public virtual void TestWaitStateScope()
        {
            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("scopedWait")
                .EndActivity()
                .CreateActivity("scopedWait")
                .Scope()
                .Behavior(new WaitState())
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IPvmExecution execution = processInstance.FindExecution("scopedWait");

            Assert.NotNull(execution);

            execution.Signal(null, null);

            Assert.AreEqual(new List <string>(), processInstance.FindActiveActivityIds());
            Assert.True(processInstance.IsEnded);
        }
Exemple #7
0
        public virtual void TestVariables()
        {
            var processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("a")
                .Initial()
                .Behavior(new WaitState())
                .EndActivity()
                .BuildProcessDefinition();

            PvmExecutionImpl processInstance = (PvmExecutionImpl)processDefinition.CreateProcessInstance();

            processInstance.SetVariable("amount", 500L);
            processInstance.SetVariable("msg", "hello world");
            processInstance.Start();

            Assert.AreEqual(500L, processInstance.GetVariable("amount"));
            Assert.AreEqual("hello world", processInstance.GetVariable("msg"));

            var activityInstance = processInstance.FindExecution("a");

            Assert.AreEqual(500L, activityInstance.GetVariable("amount"));
            Assert.AreEqual("hello world", activityInstance.GetVariable("msg"));

            IDictionary <string, object> expectedVariables = new Dictionary <string, object>();

            expectedVariables["amount"] = 500L;
            expectedVariables["msg"]    = "hello world";

            //TODO JAVA 行为不一样
            //Assert.AreEqual(expectedVariables, activityInstance.Variables);
            //Assert.AreEqual(expectedVariables, processInstance.Variables);
        }
Exemple #8
0
        public void TestPvmWaitState()
        {
            IPvmProcessDefinition processDefinition = new ProcessDefinitionBuilder()
                                                      .CreateActivity("a")
                                                      .Initial()
                                                      .Behavior(new WaitState())
                                                      .Transition("b")
                                                      .EndActivity()
                                                      .CreateActivity("b")
                                                      .Behavior(new WaitState())
                                                      .Transition("c")
                                                      .EndActivity()
                                                      .CreateActivity("c")
                                                      .Behavior(new WaitState())
                                                      .EndActivity()
                                                      .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IPvmExecution activityInstance = processInstance.FindExecution("a");

            Assert.NotNull(activityInstance);

            activityInstance.Signal(null, null);

            activityInstance = processInstance.FindExecution("b");
            Assert.NotNull(activityInstance);

            activityInstance.Signal(null, null);

            activityInstance = processInstance.FindExecution("c");
            Assert.NotNull(activityInstance);
        }
Exemple #9
0
        public virtual void TestEmbeddedSubProcess()
        {
            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .Transition("endInside")
                .EndActivity()
                .CreateActivity("endInside")
                .Behavior(new End())
                .EndActivity()
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new WaitState())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IList <string> expectedActiveActivityIds = new List <string>();

            expectedActiveActivityIds.Add("end");

            Assert.AreEqual(expectedActiveActivityIds, processInstance.FindActiveActivityIds());
        }
Exemple #10
0
        public virtual void TestJoinForkCombinedInOneParallelGateway()
        {
            var processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("fork")
                .EndActivity()
                .CreateActivity("fork")
                .Behavior(new ParallelGateway())
                .Transition("c1")
                .Transition("c2")
                .Transition("c3")
                .EndActivity()
                .CreateActivity("c1")
                .Behavior(new Automatic())
                .Transition("join1")
                .EndActivity()
                .CreateActivity("c2")
                .Behavior(new Automatic())
                .Transition("join1")
                .EndActivity()
                .CreateActivity("c3")
                .Behavior(new Automatic())
                .Transition("join2")
                .EndActivity()
                .CreateActivity("join1")
                .Behavior(new ParallelGateway())
                .Transition("c4")
                .Transition("c5")
                .Transition("c6")
                .EndActivity()
                .CreateActivity("c4")
                .Behavior(new Automatic())
                .Transition("join2")
                .EndActivity()
                .CreateActivity("c5")
                .Behavior(new Automatic())
                .Transition("join2")
                .EndActivity()
                .CreateActivity("c6")
                .Behavior(new Automatic())
                .Transition("join2")
                .EndActivity()
                .CreateActivity("join2")
                .Behavior(new ParallelGateway())
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new WaitState())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.NotNull(processInstance.FindExecution("end"));
        }
        public virtual void TestNestedSubProcessBothNoEnd()
        {
            var verifier = new ActivityInstanceVerification();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("nestedSubProcess")
                .EndActivity()
                .CreateActivity("nestedSubProcess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .CreateActivity("startNestedInside")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .EndActivity()
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.True(processInstance.IsEnded);

            verifier.AssertStartInstanceCount(1, "start");
            verifier.AssertProcessInstanceParent("start", processInstance);
            verifier.AssertStartInstanceCount(1, "embeddedsubprocess");
            verifier.AssertProcessInstanceParent("embeddedsubprocess", processInstance);
            verifier.AssertStartInstanceCount(1, "startInside");
            verifier.AssertParent("startInside", "embeddedsubprocess");
            verifier.AssertStartInstanceCount(1, "nestedSubProcess");
            verifier.AssertParent("nestedSubProcess", "embeddedsubprocess");
            verifier.AssertStartInstanceCount(1, "startNestedInside");
            verifier.AssertParent("startNestedInside", "nestedSubProcess");
        }
Exemple #12
0
        public void TestPvmDecision()
        {
            IPvmProcessDefinition processDefinition = new ProcessDefinitionBuilder()
                                                      .CreateActivity("start")
                                                      .Initial()
                                                      .Behavior(new Automatic())
                                                      .Transition("checkCredit")
                                                      .EndActivity()
                                                      .CreateActivity("checkCredit")
                                                      .Behavior(new Decision())
                                                      .Transition("askDaughterOut", "wow")
                                                      .Transition("takeToGolf", "nice")
                                                      .Transition("ignore", "default")
                                                      .EndActivity()
                                                      .CreateActivity("takeToGolf")
                                                      .Behavior(new WaitState())
                                                      .EndActivity()
                                                      .CreateActivity("askDaughterOut")
                                                      .Behavior(new WaitState())
                                                      .EndActivity()
                                                      .CreateActivity("ignore")
                                                      .Behavior(new WaitState())
                                                      .EndActivity()
                                                      .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.SetVariable("creditRating", "Aaa-");
            processInstance.Start();
            Assert.NotNull(processInstance.FindExecution("takeToGolf"));

            processInstance = processDefinition.CreateProcessInstance();
            processInstance.SetVariable("creditRating", "AAA+");
            processInstance.Start();
            Assert.NotNull(processInstance.FindExecution("askDaughterOut"));

            processInstance = processDefinition.CreateProcessInstance();
            processInstance.SetVariable("creditRating", "bb-");
            processInstance.Start();
            Assert.NotNull(processInstance.FindExecution("ignore"));
        }
Exemple #13
0
        public virtual void TestTransitionDestroysEventScope()
        {
            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .Transition("nestedSubProcess")
                .EndActivity()
                .CreateActivity("nestedSubProcess")
                .Scope()
                .Behavior(new EventScopeCreatingSubprocess())
                .CreateActivity("startNestedInside")
                .Behavior(new Automatic())
                .EndActivity()
                .Transition("Wait")
                .EndActivity()
                .CreateActivity("Wait")
                .Behavior(new WaitState())
                .Transition("endInside")
                .EndActivity()
                .CreateActivity("endInside")
                .Behavior(new Automatic())
                .EndActivity()
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new Automatic())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IList <string> expectedActiveActivityIds = new List <string>();

            expectedActiveActivityIds.Add("Wait");
            Assert.AreEqual(expectedActiveActivityIds, processInstance.FindActiveActivityIds());


            IPvmExecution execution = processInstance.FindExecution("Wait");

            execution.Signal(null, null);

            Assert.True(processInstance.IsEnded);
        }
Exemple #14
0
        public virtual void TestMultipleConcurrentEndsInsideEmbeddedSubProcessWithWaitState()
        {
            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .Transition("fork")
                .EndActivity()
                .CreateActivity("fork")
                .Behavior(new ParallelGateway())
                .Transition("endInside1")
                .Transition("Wait")
                .Transition("endInside3")
                .EndActivity()
                .CreateActivity("endInside1")
                .Behavior(new End())
                .EndActivity()
                .CreateActivity("Wait")
                .Behavior(new WaitState())
                .Transition("endInside2")
                .EndActivity()
                .CreateActivity("endInside2")
                .Behavior(new End())
                .EndActivity()
                .CreateActivity("endInside3")
                .Behavior(new End())
                .EndActivity()
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.IsFalse(processInstance.IsEnded);
            IPvmExecution execution = processInstance.FindExecution("Wait");

            execution.Signal(null, null);

            Assert.True(processInstance.IsEnded);
        }
Exemple #15
0
        public virtual void TestSimpleWaitStateConcurrency()
        {
            var processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("fork")
                .EndActivity()
                .CreateActivity("fork")
                .Behavior(new ParallelGateway())
                .Transition("c1")
                .Transition("c2")
                .EndActivity()
                .CreateActivity("c1")
                .Behavior(new WaitState())
                .Transition("join")
                .EndActivity()
                .CreateActivity("c2")
                .Behavior(new WaitState())
                .Transition("join")
                .EndActivity()
                .CreateActivity("join")
                .Behavior(new ParallelGateway())
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new WaitState())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IPvmExecution activityInstanceC1 = processInstance.FindExecution("c1");

            Assert.NotNull(activityInstanceC1);

            IPvmExecution activityInstanceC2 = processInstance.FindExecution("c2");

            Assert.NotNull(activityInstanceC2);

            activityInstanceC1.Signal(null, null);
            activityInstanceC2.Signal(null, null);

            IList <string> activityNames         = processInstance.FindActiveActivityIds();
            IList <string> expectedActivityNames = new List <string>();

            expectedActivityNames.Add("end");

            Assert.AreEqual(expectedActivityNames, activityNames);
        }
Exemple #16
0
        public virtual void TestActivityEndDestroysEventScopes()
        {
            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EventScopeCreatingSubprocess())
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .Transition("endInside")
                .EndActivity()
                .CreateActivity("endInside")
                .Behavior(new Automatic())
                .EndActivity()
                .Transition("Wait")
                .EndActivity()
                .CreateActivity("Wait")
                .Behavior(new WaitState())
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new Automatic())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            var eventScopeFound = false;
            var executions      = ((ExecutionImpl)processInstance).Executions;

            foreach (var executionImpl in executions)
            {
                if (executionImpl.IsEventScope)
                {
                    eventScopeFound = true;
                    break;
                }
            }

            Assert.True(eventScopeFound);

            processInstance.Signal(null, null);

            Assert.True(processInstance.IsEnded);
        }
Exemple #17
0
        public virtual void TestUnstructuredConcurrencyTwoForks()
        {
            var processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("fork1")
                .EndActivity()
                .CreateActivity("fork1")
                .Behavior(new ParallelGateway())
                .Transition("c1")
                .Transition("c2")
                .Transition("fork2")
                .EndActivity()
                .CreateActivity("c1")
                .Behavior(new Automatic())
                .Transition("join")
                .EndActivity()
                .CreateActivity("c2")
                .Behavior(new Automatic())
                .Transition("join")
                .EndActivity()
                .CreateActivity("fork2")
                .Behavior(new ParallelGateway())
                .Transition("c3")
                .Transition("c4")
                .EndActivity()
                .CreateActivity("c3")
                .Behavior(new Automatic())
                .Transition("join")
                .EndActivity()
                .CreateActivity("c4")
                .Behavior(new Automatic())
                .Transition("join")
                .EndActivity()
                .CreateActivity("join")
                .Behavior(new ParallelGateway())
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new WaitState())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.NotNull(processInstance.FindExecution("end"));
        }
        public virtual void TestBoundaryEvent()
        {
            var verifier = new ActivityInstanceVerification();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("userTask")
                .EndActivity()
                .CreateActivity("userTask")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("end1")
                .EndActivity()
                .CreateActivity("timer")
                .Behavior(new WaitState())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .AttachedTo("userTask", true)
                .Transition("end2")
                .EndActivity()
                .CreateActivity("end1")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .CreateActivity("end2")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            var userTaskExecution = processInstance.FindExecution("userTask");

            ((PvmExecutionImpl)userTaskExecution).ExecuteActivity(processDefinition.FindActivity("timer"));

            var timerExecution = processInstance.FindExecution("timer");

            timerExecution.Signal(null, null);

            verifier.AssertNonCompletingActivityInstance("start", 1);
            verifier.AssertNonCompletingActivityInstance("userTask", 1);
            verifier.AssertIsCompletingActivityInstance("end2", 1);
        }
        public virtual void TestSingleEndAfterParallelJoin()
        {
            var verifier = new ActivityInstanceVerification();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("fork")
                .EndActivity()
                .CreateActivity("fork")
                .Behavior(new ParallelGateway())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("a1")
                .Transition("a2")
                .EndActivity()
                .CreateActivity("a1")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("join")
                .EndActivity()
                .CreateActivity("a2")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("join")
                .EndActivity()
                .CreateActivity("join")
                .Behavior(new ParallelGateway())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            verifier.AssertNonCompletingActivityInstance("start", 1);
            verifier.AssertNonCompletingActivityInstance("fork", 1);
            verifier.AssertNonCompletingActivityInstance("a1", 1);
            verifier.AssertNonCompletingActivityInstance("a2", 1);
            verifier.AssertNonCompletingActivityInstance("join", 2);
            verifier.AssertIsCompletingActivityInstance("end", 1);
        }
        public virtual void TestSimpleSubProcess()
        {
            var verifier = new ActivityInstanceVerification();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("endInside")
                .EndActivity()
                .CreateActivity("endInside")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            verifier.AssertNonCompletingActivityInstance("start", 1);
            verifier.AssertNonCompletingActivityInstance("embeddedsubprocess", 1);
            verifier.AssertNonCompletingActivityInstance("startInside", 1);
            verifier.AssertIsCompletingActivityInstance("endInside", 1);
            verifier.AssertIsCompletingActivityInstance("end", 1);
        }
        public virtual void TestScopeActivity()
        {
            var verifier = new ActivityInstanceVerification();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("one")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("two")
                .EndActivity()
                .CreateActivity("two")
                .Scope()
                .Behavior(new WaitState())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("three")
                .EndActivity()
                .CreateActivity("three")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IPvmExecution childExecution           = processInstance.FindExecution("two");
            var           parentActivityInstanceId = ((ExecutionImpl)childExecution).ParentActivityInstanceId;

            Assert.AreEqual(((ExecutionImpl)processInstance).Id, parentActivityInstanceId);

            childExecution.Signal(null, null);

            verifier.AssertStartInstanceCount(1, "one");
            verifier.AssertStartInstanceCount(1, "two");
            verifier.AssertProcessInstanceParent("two", processInstance);
            verifier.AssertStartInstanceCount(1, "three");
        }
Exemple #22
0
        public virtual void TestStartEnd()
        {
            var processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.AreEqual(new List <string>(), processInstance.FindActiveActivityIds());
            Assert.True(processInstance.IsEnded);
        }
Exemple #23
0
        public virtual void TestStartEndEvents()
        {
            var eventCollector = new EventCollector();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder("events").ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .StartTransition("end")
                .ExecutionListener(eventCollector)
                .EndTransition()
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IList <string> expectedEvents = new List <string>();

            expectedEvents.Add("start on ProcessDefinition(events)");
            expectedEvents.Add("start on Activity(start)");
            expectedEvents.Add("end on Activity(start)");
            expectedEvents.Add("take on (start)-->(end)");
            expectedEvents.Add("start on Activity(end)");
            expectedEvents.Add("end on Activity(end)");
            expectedEvents.Add("end on ProcessDefinition(events)");

            Assert.AreEqual(string.Join(",", expectedEvents), string.Join(",", eventCollector.Events));
        }
Exemple #24
0
        public virtual void TestWhileLoop()
        {
            var processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("loop")
                .EndActivity()
                .CreateActivity("loop")
                .Behavior(new While("Count", 0, 10))
                .Transition("one", "more")
                .Transition("end", "done")
                .EndActivity()
                .CreateActivity("one")
                .Behavior(new Automatic())
                .Transition("two")
                .EndActivity()
                .CreateActivity("two")
                .Behavior(new Automatic())
                .Transition("three")
                .EndActivity()
                .CreateActivity("three")
                .Behavior(new Automatic())
                .Transition("loop")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.AreEqual(new List <string>(), processInstance.FindActiveActivityIds());
            Assert.True(processInstance.IsEnded);
        }
        public virtual void TestWhileLoop()
        {
            var verifier           = new ActivityInstanceVerification();
            var transitionVerifier = new TransitionInstanceVerifyer();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .StartTransition("loop")
                .ExecutionListener(ExecutionListenerFields.EventNameTake, transitionVerifier)
                .EndTransition()
                .EndActivity()
                .CreateActivity("loop")
                .Behavior(new While("Count", 0, 10))
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .StartTransition("one", "more")
                .ExecutionListener(ExecutionListenerFields.EventNameTake, transitionVerifier)
                .EndTransition()
                .StartTransition("end", "done")
                .ExecutionListener(ExecutionListenerFields.EventNameTake, transitionVerifier)
                .EndTransition()
                .EndActivity()
                .CreateActivity("one")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("two")
                .EndActivity()
                .CreateActivity("two")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("three")
                .EndActivity()
                .CreateActivity("three")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("loop")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.AreEqual(new List <string>(), processInstance.FindActiveActivityIds());
            Assert.True(processInstance.IsEnded);

            verifier.AssertStartInstanceCount(1, "start");
            verifier.AssertProcessInstanceParent("start", processInstance);

            verifier.AssertStartInstanceCount(11, "loop");
            verifier.AssertProcessInstanceParent("loop", processInstance);

            verifier.AssertStartInstanceCount(10, "one");
            verifier.AssertProcessInstanceParent("one", processInstance);

            verifier.AssertStartInstanceCount(10, "two");
            verifier.AssertProcessInstanceParent("two", processInstance);

            verifier.AssertStartInstanceCount(10, "three");
            verifier.AssertProcessInstanceParent("three", processInstance);

            verifier.AssertStartInstanceCount(1, "end");
            verifier.AssertProcessInstanceParent("end", processInstance);
        }
Exemple #26
0
        public virtual void TestSimpleAutmaticConcurrencyEvents()
        {
            var eventCollector = new EventCollector();

            var processDefinition =
                new ProcessDefinitionBuilder("events").ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .Transition("fork")
                .EndActivity()
                .CreateActivity("fork")
                .Behavior(new ParallelGateway())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .Transition("c1")
                .Transition("c2")
                .EndActivity()
                .CreateActivity("c1")
                .Behavior(new Automatic())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .Transition("join")
                .EndActivity()
                .CreateActivity("c2")
                .Behavior(new Automatic())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .Transition("join")
                .EndActivity()
                .CreateActivity("join")
                .Behavior(new ParallelGateway())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IList <string> expectedEvents = new List <string>();

            expectedEvents.Add("start on ProcessDefinition(events)");
            expectedEvents.Add("start on Activity(start)");
            expectedEvents.Add("end on Activity(start)");
            expectedEvents.Add("start on Activity(fork)");
            expectedEvents.Add("end on Activity(fork)");
            expectedEvents.Add("start on Activity(join)");
            expectedEvents.Add("start on Activity(c2)");
            expectedEvents.Add("end on Activity(c2)");
            expectedEvents.Add("start on Activity(c1)");
            expectedEvents.Add("end on Activity(c1)");
            expectedEvents.Add("start on Activity(join)");
            expectedEvents.Add("end on Activity(join)");
            expectedEvents.Add("end on Activity(join)");
            expectedEvents.Add("start on Activity(end)");
            expectedEvents.Add("end on Activity(end)");
            expectedEvents.Add("end on ProcessDefinition(events)");

            Assert.AreEqual(string.Join(",", expectedEvents),
                            string.Join(",", eventCollector.Events));
        }
Exemple #27
0
        public virtual void TestEmbeddedSubProcessEventsDelete()
        {
            var eventCollector = new EventCollector();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder("events").ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .Transition("taskInside")
                .EndActivity()
                .CreateActivity("taskInside")
                .Behavior(new WaitState())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .Transition("endInside")
                .EndActivity()
                .CreateActivity("endInside")
                .Behavior(new End())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .EndActivity()
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            var execution = (ExecutionImpl)processInstance;
            var cmd       = new FoxDeleteProcessInstanceCmd(null, null);
            IList <PvmExecutionImpl> collectExecutionToDelete = cmd.CollectExecutionToDelete(execution);

            foreach (var interpretableExecution in collectExecutionToDelete)
            {
                interpretableExecution.DeleteCascade2("");
            }

            IList <string> expectedEvents = new List <string>();

            expectedEvents.Add("start on ProcessDefinition(events)");
            expectedEvents.Add("start on Activity(start)");
            expectedEvents.Add("end on Activity(start)");
            expectedEvents.Add("start on Activity(embeddedsubprocess)");
            expectedEvents.Add("start on Activity(startInside)");
            expectedEvents.Add("end on Activity(startInside)");
            expectedEvents.Add("start on Activity(taskInside)");
            expectedEvents.Add("end on Activity(taskInside)");
            expectedEvents.Add("end on Activity(embeddedsubprocess)");
            expectedEvents.Add("end on ProcessDefinition(events)");

            Assert.AreEqual(string.Join(",", expectedEvents),
                            string.Join(",", eventCollector.Events), "expected " + expectedEvents + ", but was \n" + eventCollector + "\n");
        }
Exemple #28
0
        public virtual void TestEmbeddedSubProcessEvents()
        {
            var eventCollector = new EventCollector();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder("events").ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .Transition("endInside")
                .EndActivity()
                .CreateActivity("endInside")
                .Behavior(new End())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .EndActivity()
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .ExecutionListener(PvmEvent.EventNameStart, eventCollector)
                .ExecutionListener(PvmEvent.EventNameEnd, eventCollector)
                .EndActivity()
                .BuildProcessDefinition();

            var processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IList <string> expectedEvents = new List <string>();

            expectedEvents.Add("start on ProcessDefinition(events)");
            expectedEvents.Add("start on Activity(start)");
            expectedEvents.Add("end on Activity(start)");
            expectedEvents.Add("start on Activity(embeddedsubprocess)");
            expectedEvents.Add("start on Activity(startInside)");
            expectedEvents.Add("end on Activity(startInside)");
            expectedEvents.Add("start on Activity(endInside)");
            expectedEvents.Add("end on Activity(endInside)");
            expectedEvents.Add("end on Activity(embeddedsubprocess)");
            expectedEvents.Add("start on Activity(end)");
            expectedEvents.Add("end on Activity(end)");
            expectedEvents.Add("end on ProcessDefinition(events)");

            Assert.AreEqual(string.Join(",", expectedEvents),
                            string.Join(",", eventCollector.Events), "expected " + expectedEvents + ", but was \n" + eventCollector + "\n");
        }
        public virtual void TestMultipleConcurrentEndsInsideEmbeddedSubProcessWithWaitState()
        {
            var verifier = new ActivityInstanceVerification();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("fork")
                .EndActivity()
                .CreateActivity("fork")
                .Behavior(new ParallelGateway())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("endInside1")
                .Transition("Wait")
                .Transition("endInside3")
                .EndActivity()
                .CreateActivity("endInside1")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .CreateActivity("Wait")
                .Behavior(new WaitState())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("endInside2")
                .EndActivity()
                .CreateActivity("endInside2")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .CreateActivity("endInside3")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.IsFalse(processInstance.IsEnded);
            IPvmExecution execution = processInstance.FindExecution("Wait");

            execution.Signal(null, null);

            Assert.True(processInstance.IsEnded);

            verifier.AssertStartInstanceCount(1, "start");
            verifier.AssertProcessInstanceParent("start", processInstance);

            verifier.AssertStartInstanceCount(1, "embeddedsubprocess");
            verifier.AssertProcessInstanceParent("embeddedsubprocess", processInstance);

            verifier.AssertStartInstanceCount(1, "startInside");
            verifier.AssertParent("startInside", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "fork");
            verifier.AssertParent("fork", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "Wait");
            verifier.AssertParent("Wait", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "endInside1");
            verifier.AssertParent("endInside1", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "endInside2");
            verifier.AssertParent("endInside2", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "endInside3");
            verifier.AssertParent("endInside3", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "end");
            verifier.AssertProcessInstanceParent("end", processInstance);
        }