Search in sources :

Example 1 with ParallelGateway

use of org.activiti.engine.test.pvm.activities.ParallelGateway in project Activiti by Activiti.

the class PvmEventTest method testSimpleAutmaticConcurrencyEvents.

/**
   *                   +--+
   *              +--->|c1|---+
   *              |    +--+   |
   *              |           v
   * +-----+   +----+       +----+   +---+
   * |start|-->|fork|       |join|-->|end|
   * +-----+   +----+       +----+   +---+
   *              |           ^
   *              |    +--+   |
   *              +--->|c2|---+
   *                   +--+
   */
public void testSimpleAutmaticConcurrencyEvents() {
    EventCollector eventCollector = new EventCollector();
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("events").executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("start").initial().behavior(new Automatic()).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("fork").endActivity().createActivity("fork").behavior(new ParallelGateway()).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("c1").transition("c2").endActivity().createActivity("c1").behavior(new Automatic()).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("join").endActivity().createActivity("c2").behavior(new Automatic()).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("join").endActivity().createActivity("join").behavior(new ParallelGateway()).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("end").endActivity().createActivity("end").behavior(new End()).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    List<String> expectedEvents = new ArrayList<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(c1)");
    expectedEvents.add("end on Activity(c1)");
    expectedEvents.add("start on Activity(join)");
    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("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);
}
Also used : PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ParallelGateway(org.activiti.engine.test.pvm.activities.ParallelGateway) ArrayList(java.util.ArrayList) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) End(org.activiti.engine.test.pvm.activities.End) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic)

Example 2 with ParallelGateway

use of org.activiti.engine.test.pvm.activities.ParallelGateway in project Activiti by Activiti.

the class PvmParallelEndTest method testParallelEnd.

/**
   *                   +----+
   *              +--->|end1|
   *              |    +----+
   *              |        
   * +-----+   +----+      
   * |start|-->|fork|      
   * +-----+   +----+      
   *              |        
   *              |    +----+
   *              +--->|end2|
   *                   +----+
   */
public void testParallelEnd() {
    PvmProcessDefinition 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();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    assertTrue(processInstance.isEnded());
}
Also used : PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ParallelGateway(org.activiti.engine.test.pvm.activities.ParallelGateway) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) End(org.activiti.engine.test.pvm.activities.End) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic)

Example 3 with ParallelGateway

use of org.activiti.engine.test.pvm.activities.ParallelGateway in project Activiti by Activiti.

the class PvmParallelTest method testUnstructuredConcurrencyTwoJoins.

public void testUnstructuredConcurrencyTwoJoins() {
    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").endActivity().createActivity("c4").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"));
}
Also used : WaitState(org.activiti.engine.test.pvm.activities.WaitState) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ParallelGateway(org.activiti.engine.test.pvm.activities.ParallelGateway) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic)

Example 4 with ParallelGateway

use of org.activiti.engine.test.pvm.activities.ParallelGateway in project Activiti by Activiti.

the class PvmParallelTest method testSimpleWaitStateConcurrency.

public 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);
    List<String> activityNames = processInstance.findActiveActivityIds();
    List<String> expectedActivityNames = new ArrayList<String>();
    expectedActivityNames.add("end");
    assertEquals(expectedActivityNames, activityNames);
}
Also used : WaitState(org.activiti.engine.test.pvm.activities.WaitState) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ParallelGateway(org.activiti.engine.test.pvm.activities.ParallelGateway) ArrayList(java.util.ArrayList) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic) PvmExecution(org.activiti.engine.impl.pvm.PvmExecution)

Example 5 with ParallelGateway

use of org.activiti.engine.test.pvm.activities.ParallelGateway in project Activiti by Activiti.

the class PvmEmbeddedSubProcessTest method testMultipleConcurrentEndsInsideEmbeddedSubProcess.

/** 
   *           +----------------------------------------+
   *           | embeddedsubprocess        +----------+ |
   *           |                     +---->|endInside1| |
   *           |                     |     +----------+ |
   *           |                     |                  |
   * +-----+   |  +-----------+   +----+   +----------+ |   +---+
   * |start|-->|  |startInside|-->|fork|-->|endInside2| |-->|end|
   * +-----+   |  +-----------+   +----+   +----------+ |   +---+
   *           |                     |                  |
   *           |                     |     +----------+ |
   *           |                     +---->|endInside3| |
   *           |                           +----------+ |
   *           +----------------------------------------+
   */
public 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.isEnded());
}
Also used : EmbeddedSubProcess(org.activiti.engine.test.pvm.activities.EmbeddedSubProcess) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ParallelGateway(org.activiti.engine.test.pvm.activities.ParallelGateway) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) End(org.activiti.engine.test.pvm.activities.End) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic)

Aggregations

ProcessDefinitionBuilder (org.activiti.engine.impl.pvm.ProcessDefinitionBuilder)15 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)15 PvmProcessInstance (org.activiti.engine.impl.pvm.PvmProcessInstance)15 Automatic (org.activiti.engine.test.pvm.activities.Automatic)15 ParallelGateway (org.activiti.engine.test.pvm.activities.ParallelGateway)15 WaitState (org.activiti.engine.test.pvm.activities.WaitState)11 End (org.activiti.engine.test.pvm.activities.End)9 ArrayList (java.util.ArrayList)8 PvmExecution (org.activiti.engine.impl.pvm.PvmExecution)6 EmbeddedSubProcess (org.activiti.engine.test.pvm.activities.EmbeddedSubProcess)2