Ejemplo n.º 1
0
        /// <summary>
        ///                   +--+
        ///              +--->|c1|---+
        ///              |    +--+   |
        ///              |           v
        /// +-----+   +----+       +----+   +---+
        /// |start|-->|fork|       |join|-->|end|
        /// +-----+   +----+       +----+   +---+
        ///              |           ^
        ///              |    +--+   |
        ///              +--->|c2|---+
        ///                   +--+
        /// </summary>
        public virtual void testSimpleAutmaticConcurrencyEvents()
        {
            EventCollector eventCollector = new EventCollector();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder("events")).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("start").initial().behavior(new Automatic()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("fork").endActivity().createActivity("fork").behavior(new ParallelGateway()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("c1").transition("c2").endActivity().createActivity("c1").behavior(new Automatic()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("join").endActivity().createActivity("c2").behavior(new Automatic()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("join").endActivity().createActivity("join").behavior(new ParallelGateway()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("end").endActivity().createActivity("end").behavior(new End()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).endActivity().buildProcessDefinition();

            PvmProcessInstance 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(c2)");
            expectedEvents.Add("end on Activity(c2)");
            expectedEvents.Add("start on Activity(join)");
            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)");

            assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testVariables()
        public virtual void testVariables()
        {
            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("a").initial().behavior(new WaitState()).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.setVariable("amount", 500L);
            processInstance.setVariable("msg", "hello world");
            processInstance.start();

            assertEquals(500L, processInstance.getVariable("amount"));
            assertEquals("hello world", processInstance.getVariable("msg"));

            PvmExecution activityInstance = processInstance.findExecution("a");

            assertEquals(500L, activityInstance.getVariable("amount"));
            assertEquals("hello world", activityInstance.getVariable("msg"));

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

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

            assertEquals(expectedVariables, activityInstance.Variables);
            assertEquals(expectedVariables, processInstance.Variables);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///           +------------------------------+
        /// +-----+   | +-----------+   +----------+ |   +---+
        /// |start|-->| |startInside|-->|endInsdide| |-->|end|
        /// +-----+   | +-----------+   +----------+ |   +---+
        ///           +------------------------------+
        /// </summary>
        public virtual void testEmbeddedSubProcessEvents()
        {
            EventCollector eventCollector = new EventCollector();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder("events")).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("start").initial().behavior(new Automatic()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("embeddedsubprocess").endActivity().createActivity("embeddedsubprocess").scope().behavior(new EmbeddedSubProcess()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("startInside").behavior(new Automatic()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("endInside").endActivity().createActivity("endInside").behavior(new End()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).endActivity().transition("end").endActivity().createActivity("end").behavior(new End()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).endActivity().buildProcessDefinition();

            PvmProcessInstance 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)");

            assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
        }
Ejemplo n.º 5
0
        public virtual void testSimpleWaitStateConcurrency()
        {
            PvmProcessDefinition 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();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            PvmExecution activityInstanceC1 = processInstance.findExecution("c1");

            assertNotNull(activityInstanceC1);

            PvmExecution activityInstanceC2 = processInstance.findExecution("c2");

            assertNotNull(activityInstanceC2);

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

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

            expectedActivityNames.Add("end");

            assertEquals(expectedActivityNames, activityNames);
        }
Ejemplo n.º 6
0
        public override ExecutionEntity createSubProcessInstance(PvmProcessDefinition processDefinition, string businessKey, string caseInstanceId)
        {
            ExecutionEntity subProcessInstance = (ExecutionEntity)processDefinition.createProcessInstance(businessKey, caseInstanceId);

            // inherit the tenant-id from the process definition
            string tenantId = ((ProcessDefinitionEntity)processDefinition).TenantId;

            if (!string.ReferenceEquals(tenantId, null))
            {
                subProcessInstance.TenantId = tenantId;
            }
            else
            {
                // if process definition has no tenant id, inherit this case instance's tenant id
                subProcessInstance.TenantId = this.tenantId;
            }

            // manage bidirectional super-subprocess relation
            subProcessInstance.setSuperCaseExecution(this);
            setSubProcessInstance(subProcessInstance);

            fireHistoricCaseActivityInstanceUpdate();

            return(subProcessInstance);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        ///
        /// <summary>
        ///                       create evt scope --+
        ///                                          |
        ///                                          v
        ///
        ///           +------------------------------+
        ///           | embedded subprocess          |
        /// +-----+   |  +-----------+   +---------+ |   +----+   +---+
        /// |start|-->|  |startInside|-->|endInside| |-->|wait|-->|end|
        /// +-----+   |  +-----------+   +---------+ |   +----+   +---+
        ///           +------------------------------+
        ///
        ///                                                           ^
        ///                                                           |
        ///                                       destroy evt scope --+
        ///
        /// </summary>
        public virtual void testActivityEndDestroysEventScopes()
        {
            PvmProcessDefinition 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();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            bool eventScopeFound             = false;
            IList <ExecutionImpl> executions = ((ExecutionImpl)processInstance).Executions;

            foreach (ExecutionImpl executionImpl in executions)
            {
                if (executionImpl.EventScope)
                {
                    eventScopeFound = true;
                    break;
                }
            }

            assertTrue(eventScopeFound);

            processInstance.signal(null, null);

            assertTrue(processInstance.Ended);
        }
Ejemplo n.º 9
0
        public virtual void testSimpleAutmaticConcurrency()
        {
            PvmProcessDefinition 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 Automatic()).transition("join").endActivity().createActivity("c2").behavior(new Automatic()).transition("join").endActivity().createActivity("join").behavior(new ParallelGateway()).transition("end").endActivity().createActivity("end").behavior(new End()).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            assertTrue(processInstance.Ended);
        }
Ejemplo n.º 10
0
        /// <summary>
        ///           +----------------------------------------+
        ///           | embeddedsubprocess        +----------+ |
        ///           |                     +---->|endInside1| |
        ///           |                     |     +----------+ |
        ///           |                     |                  |
        /// +-----+   |  +-----------+   +----+   +----------+ |   +---+
        /// |start|-->|  |startInside|-->|fork|-->|endInside2| |-->|end|
        /// +-----+   |  +-----------+   +----+   +----------+ |   +---+
        ///           |                     |                  |
        ///           |                     |     +----------+ |
        ///           |                     +---->|endInside3| |
        ///           |                           +----------+ |
        ///           +----------------------------------------+
        /// </summary>
        public virtual void testMultipleConcurrentEndsInsideEmbeddedSubProcess()
        {
            PvmProcessDefinition 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("endInside2").transition("endInside3").endActivity().createActivity("endInside1").behavior(new End()).endActivity().createActivity("endInside2").behavior(new End()).endActivity().createActivity("endInside3").behavior(new End()).endActivity().transition("end").endActivity().createActivity("end").behavior(new End()).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            assertTrue(processInstance.Ended);
        }
Ejemplo n.º 11
0
        /// <summary>
        ///           +------------------------------+
        ///           | embedded subprocess          |
        /// +-----+   |  +-----------+   +---------+ |
        /// |start|-->|  |startInside|-->|endInside| |
        /// +-----+   |  +-----------+   +---------+ |
        ///           +------------------------------+
        /// </summary>
        public virtual void testEmbeddedSubProcessNoEnd()
        {
            PvmProcessDefinition 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();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            assertTrue(processInstance.Ended);
        }
Ejemplo n.º 12
0
        public virtual void testUnstructuredConcurrencyTwoForks()
        {
            PvmProcessDefinition 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();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            assertNotNull(processInstance.findExecution("end"));
        }
Ejemplo n.º 13
0
        public virtual void testJoinForkCombinedInOneParallelGateway()
        {
            PvmProcessDefinition 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();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            assertNotNull(processInstance.findExecution("end"));
        }
Ejemplo n.º 14
0
        public override PvmExecutionImpl createSubProcessInstance(PvmProcessDefinition processDefinition, string businessKey, string caseInstanceId)
        {
            ExecutionImpl subProcessInstance = (ExecutionImpl)processDefinition.createProcessInstance(businessKey, caseInstanceId);

            // manage bidirectional super-subprocess relation
            subProcessInstance.setSuperCaseExecution(this);
            setSubProcessInstance(subProcessInstance);

            return(subProcessInstance);
        }
Ejemplo n.º 15
0
        /// <summary>
        ///                  +----------------------------+
        ///                  v                            |
        /// +-------+   +------+   +-----+   +-----+    +-------+
        /// | start |-->| loop |-->| one |-->| two |--> | three |
        /// +-------+   +------+   +-----+   +-----+    +-------+
        ///                  |
        ///                  |   +-----+
        ///                  +-->| end |
        ///                      +-----+
        /// </summary>
        public virtual void testWhileLoop()
        {
            PvmProcessDefinition 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();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            assertEquals(new List <string>(), processInstance.findActiveActivityIds());
            assertTrue(processInstance.Ended);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// +-----+   +-----+   +-------+
        /// | one |-->| two |-->| three |
        /// +-----+   +-----+   +-------+
        /// </summary>
        public virtual void testSingleAutomatic()
        {
            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("one").initial().behavior(new Automatic()).transition("two").endActivity().createActivity("two").behavior(new Automatic()).transition("three").endActivity().createActivity("three").behavior(new End()).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            assertEquals(new List <string>(), processInstance.findActiveActivityIds());
            assertTrue(processInstance.Ended);
        }
Ejemplo n.º 17
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");
        }
Ejemplo n.º 18
0
        /// <summary>
        ///           +------------------------------+
        ///           | embedded subprocess          |
        /// +-----+   |  +-----------+   +---------+ |   +---+
        /// |start|-->|  |startInside|-->|endInside| |-->|end|
        /// +-----+   |  +-----------+   +---------+ |   +---+
        ///           +------------------------------+
        /// </summary>
        public virtual void testEmbeddedSubProcess()
        {
            PvmProcessDefinition 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();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

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

            expectedActiveActivityIds.Add("end");

            assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds());
        }
Ejemplo n.º 19
0
        public virtual void testSimpleProcessInstanceEnd()
        {
            EventCollector eventCollector = new EventCollector();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("start").initial().behavior(new Automatic()).transition("wait").endActivity().createActivity("wait").behavior(new WaitState()).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.camunda.bpm.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            Console.Error.WriteLine(eventCollector);

            processInstance.deleteCascade("test");

            Console.Error.WriteLine();
            Console.Error.WriteLine(eventCollector);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// +-----+   +----------+   +---+
        /// |start|-->|scopedWait|-->|end|
        /// +-----+   +----------+   +---+
        /// </summary>
        public virtual void testWaitStateScope()
        {
            PvmProcessDefinition 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();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            PvmExecution execution = processInstance.findExecution("scopedWait");

            assertNotNull(execution);

            execution.signal(null, null);

            assertEquals(new List <string>(), processInstance.findActiveActivityIds());
            assertTrue(processInstance.Ended);
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
0
        /// <summary>
        ///           +----------------------------------------------------------------------+
        ///           | embedded subprocess                                                  |
        ///           |                                                                      |
        ///           |                                create evt scope --+                  |
        ///           |                                                   |                  |
        ///           |                                                   v                  |
        ///           |                                                                      |
        ///           |                  +--------------------------------+                  |
        ///           |                  | nested embedded subprocess     |                  |
        /// +-----+   | +-----------+    |  +-----------------+           |   +----+   +---+ |   +---+
        /// |start|-->| |startInside|--> |  |startNestedInside|           |-->|wait|-->|end| |-->|end|
        /// +-----+   | +-----------+    |  +-----------------+           |   +----+   +---+ |   +---+
        ///           |                  +--------------------------------+                  |
        ///           |                                                                      |
        ///           +----------------------------------------------------------------------+
        ///
        ///                                                                                  ^
        ///                                                                                  |
        ///                                                              destroy evt scope --+
        /// </summary>
        public virtual void testTransitionDestroysEventScope()
        {
            PvmProcessDefinition 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();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

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

            expectedActiveActivityIds.Add("wait");
            assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds());


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

            execution.signal(null, null);

            assertTrue(processInstance.Ended);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// +-----+   +-----+   +-------+   +------+    +------+
        /// | one |-->| two |-->| three |-->| four |--> | five |
        /// +-----+   +-----+   +-------+   +------+    +------+
        /// </summary>
        public virtual void testCombinationOfWaitStatesAndAutomatics()
        {
            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("start").initial().behavior(new Automatic()).transition("one").endActivity().createActivity("one").behavior(new WaitState()).transition("two").endActivity().createActivity("two").behavior(new WaitState()).transition("three").endActivity().createActivity("three").behavior(new Automatic()).transition("four").endActivity().createActivity("four").behavior(new Automatic()).transition("five").endActivity().createActivity("five").behavior(new End()).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            PvmExecution activityInstance = processInstance.findExecution("one");

            assertNotNull(activityInstance);
            activityInstance.signal(null, null);

            activityInstance = processInstance.findExecution("two");
            assertNotNull(activityInstance);
            activityInstance.signal(null, null);

            assertEquals(new List <string>(), processInstance.findActiveActivityIds());
            assertTrue(processInstance.Ended);
        }
Ejemplo n.º 24
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");
        }