Exemple #1
0
        /// <summary>
        ///                  +----------------------------+
        ///                  v                            |
        /// +-------+   +------+   +-----+   +-----+    +-------+
        /// | start |-->| loop |-->| one |-->| two |--> | three |
        /// +-------+   +------+   +-----+   +-----+    +-------+
        ///                  |
        ///                  |   +-----+
        ///                  +-->| end |
        ///                      +-----+
        /// </summary>
        public virtual void testWhileLoop()
        {
            ActivityInstanceVerification verifier           = new ActivityInstanceVerification();
            TransitionInstanceVerifyer   transitionVerifier = new TransitionInstanceVerifyer();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("start").initial().behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).startTransition("loop").executionListener([email protected]_Fields.EVENTNAME_TAKE, transitionVerifier).endTransition().endActivity().createActivity("loop").behavior(new While("count", 0, 10)).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).startTransition("one", "more").executionListener([email protected]_Fields.EVENTNAME_TAKE, transitionVerifier).endTransition().startTransition("end", "done").executionListener([email protected]_Fields.EVENTNAME_TAKE, transitionVerifier).endTransition().endActivity().createActivity("one").behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("two").endActivity().createActivity("two").behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("three").endActivity().createActivity("three").behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("loop").endActivity().createActivity("end").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            assertEquals(new List <string>(), processInstance.findActiveActivityIds());
            assertTrue(processInstance.Ended);

            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 #2
0
        /// <summary>
        ///           +-------------------------------------------------------+
        ///           | embedded subprocess                                   |
        ///           |                  +--------------------------------+   |
        ///           |                  | nested embedded subprocess     |   |
        /// +-----+   | +-----------+    |  +-----------+   +---------+   |   |   +---+
        /// |start|-->| |startInside|--> |  |startInside|-->|endInside|   |   |-->|end|
        /// +-----+   | +-----------+    |  +-----------+   +---------+   |   |   +---+
        ///           |                  +--------------------------------+   |
        ///           |                                                       |
        ///           +-------------------------------------------------------+
        /// </summary>
        public virtual void testNestedSubProcessNoEnd()
        {
            ActivityInstanceVerification verifier = new ActivityInstanceVerification();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("start").initial().behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("embeddedsubprocess").endActivity().createActivity("embeddedsubprocess").scope().behavior(new EmbeddedSubProcess()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).createActivity("startInside").behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("nestedSubProcess").endActivity().createActivity("nestedSubProcess").scope().behavior(new EmbeddedSubProcess()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).createActivity("startNestedInside").behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("endInside").endActivity().createActivity("endInside").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().endActivity().transition("end").endActivity().createActivity("end").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();
            assertTrue(processInstance.Ended);

            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");
            verifier.assertStartInstanceCount(1, "endInside");
            verifier.assertParent("endInside", "nestedSubProcess");
            verifier.assertStartInstanceCount(1, "end");
            verifier.assertProcessInstanceParent("end", processInstance);
        }
Exemple #3
0
 public ActivityInstance(ActivityInstanceVerification outerInstance, string executionId, string actInstanceId, string parentId, bool isCompleteScope)
 {
     this.outerInstance   = outerInstance;
     this.id              = actInstanceId;
     this.executionId     = executionId;
     this.parentId        = parentId;
     this.isCompleteScope = isCompleteScope;
 }
Exemple #4
0
        /// <summary>
        /// +-------+   +-----+
        /// | start |-->| end |
        /// +-------+   +-----+
        /// </summary>
        public virtual void testSingleEnd()
        {
            ActivityInstanceVerification verifier = new ActivityInstanceVerification();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("start").initial().behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("end").endActivity().createActivity("end").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            verifier.assertNonCompletingActivityInstance("start", 1);
            verifier.assertIsCompletingActivityInstance("end", 1);
        }
Exemple #5
0
        /// <summary>
        /// +-----+   +-----+   +-------+
        /// | one |-->| two |-->| three |
        /// +-----+   +-----+   +-------+
        /// </summary>
        public virtual void testSequence()
        {
            ActivityInstanceVerification verifier = new ActivityInstanceVerification();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("one").initial().behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("two").endActivity().createActivity("two").behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("three").endActivity().createActivity("three").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            verifier.assertStartInstanceCount(1, "one");
            verifier.assertStartInstanceCount(1, "two");
            verifier.assertStartInstanceCount(1, "three");
        }
Exemple #6
0
        /// <summary>
        ///           +-------------------------------------------------+
        ///           | embeddedsubprocess        +----------+          |
        ///           |                     +---->|endInside1|          |
        ///           |                     |     +----------+          |
        ///           |                     |                           |
        /// +-----+   |  +-----------+   +----+   +----+   +----------+ |   +---+
        /// |start|-->|  |startInside|-->|fork|-->|wait|-->|endInside2| |-->|end|
        /// +-----+   |  +-----------+   +----+   +----+   +----------+ |   +---+
        ///           |                     |                           |
        ///           |                     |     +----------+          |
        ///           |                     +---->|endInside3|          |
        ///           |                           +----------+          |
        ///           +-------------------------------------------------+
        /// </summary>
        public virtual void testMultipleConcurrentEndsInsideEmbeddedSubProcessWithWaitState()
        {
            ActivityInstanceVerification verifier = new ActivityInstanceVerification();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("start").initial().behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("embeddedsubprocess").endActivity().createActivity("embeddedsubprocess").scope().behavior(new EmbeddedSubProcess()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).createActivity("startInside").behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("fork").endActivity().createActivity("fork").behavior(new ParallelGateway()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("endInside1").transition("wait").transition("endInside3").endActivity().createActivity("endInside1").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().createActivity("wait").behavior(new WaitState()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("endInside2").endActivity().createActivity("endInside2").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().createActivity("endInside3").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().transition("end").endActivity().createActivity("end").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            assertFalse(processInstance.Ended);
            PvmExecution execution = processInstance.findExecution("wait");

            execution.signal(null, null);

            assertTrue(processInstance.Ended);

            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);
        }
Exemple #7
0
        /// <summary>
        ///           +----------+
        ///           | userTask |
        ///           |          |
        /// +-----+   |          |    +------+
        /// |start|-->|          |--->| end1 |
        /// +-----+   | +-----+  |
        ///           +-|timer|--+
        ///             +-----+
        ///                |          +------+
        ///                +--------->| end2 |
        ///                           +------+
        /// </summary>
        public virtual void testBoundaryEvent()
        {
            ActivityInstanceVerification verifier = new ActivityInstanceVerification();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("start").initial().behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("userTask").endActivity().createActivity("userTask").scope().behavior(new EmbeddedSubProcess()).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("end1").endActivity().createActivity("timer").behavior(new WaitState()).executionListener([email protected]_Fields.EVENTNAME_END, verifier).attachedTo("userTask", true).transition("end2").endActivity().createActivity("end1").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().createActivity("end2").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            PvmExecution userTaskExecution = processInstance.findExecution("userTask");

            ((PvmExecutionImpl)userTaskExecution).executeActivity(processDefinition.findActivity("timer"));

            PvmExecution timerExecution = processInstance.findExecution("timer");

            timerExecution.signal(null, null);

            verifier.assertNonCompletingActivityInstance("start", 1);
            verifier.assertNonCompletingActivityInstance("userTask", 1);
            verifier.assertIsCompletingActivityInstance("end2", 1);
        }
Exemple #8
0
        /// <summary>
        /// +-----+   +-----+   +-------+
        /// | one |-->| two |-->| three |
        /// +-----+   +-----+   +-------+
        /// </summary>
        public virtual void testScopeActivity()
        {
            ActivityInstanceVerification verifier = new ActivityInstanceVerification();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("one").initial().behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("two").endActivity().createActivity("two").scope().behavior(new WaitState()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("three").endActivity().createActivity("three").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            PvmExecution childExecution           = processInstance.findExecution("two");
            string       parentActivityInstanceId = ((ExecutionImpl)childExecution).ParentActivityInstanceId;

            assertEquals(((ExecutionImpl)processInstance).Id, parentActivityInstanceId);

            childExecution.signal(null, null);

            verifier.assertStartInstanceCount(1, "one");
            verifier.assertStartInstanceCount(1, "two");
            verifier.assertProcessInstanceParent("two", processInstance);
            verifier.assertStartInstanceCount(1, "three");
        }