Search in sources :

Example 36 with ProcessDefinitionBuilder

use of org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder in project camunda-bpm-platform by camunda.

the class PvmEmbeddedSubProcessTest method testNestedSubProcessNoEnd.

/**
 *           +-------------------------------------------------------+
 *           | embedded subprocess                                   |
 *           |                  +--------------------------------+   |
 *           |                  | nested embedded subprocess     |   |
 * +-----+   | +-----------+    |  +-----------+   +---------+   |   |   +---+
 * |start|-->| |startInside|--> |  |startInside|-->|endInside|   |   |-->|end|
 * +-----+   | +-----------+    |  +-----------+   +---------+   |   |   +---+
 *           |                  +--------------------------------+   |
 *           |                                                       |
 *           +-------------------------------------------------------+
 */
public void testNestedSubProcessNoEnd() {
    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 EmbeddedSubProcess()).createActivity("startNestedInside").behavior(new Automatic()).transition("endInside").endActivity().createActivity("endInside").behavior(new End()).endActivity().endActivity().transition("end").endActivity().createActivity("end").behavior(new WaitState()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    List<String> expectedActiveActivityIds = new ArrayList<String>();
    expectedActiveActivityIds.add("end");
    assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds());
}
Also used : EmbeddedSubProcess(org.camunda.bpm.engine.test.standalone.pvm.activities.EmbeddedSubProcess) WaitState(org.camunda.bpm.engine.test.standalone.pvm.activities.WaitState) PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) ArrayList(java.util.ArrayList) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) End(org.camunda.bpm.engine.test.standalone.pvm.activities.End) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)

Example 37 with ProcessDefinitionBuilder

use of org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder in project camunda-bpm-platform by camunda.

the class PvmEmbeddedSubProcessTest method testStartInScope.

/**
 *           +------------------------------+
 *           | embedded subprocess          |
 * +-----+   |  +-----------+   +---------+ |   +---+
 * |start|-->|  |startInside|-->|endInside| |-->|end|
 * +-----+   |  +-----------+   +---------+ |   +---+
 *           +------------------------------+
 */
public void testStartInScope() {
    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 = ((ProcessDefinitionImpl) processDefinition).createProcessInstanceForInitial((ActivityImpl) processDefinition.findActivity("startInside"));
    processInstance.start();
    List<String> expectedActiveActivityIds = new ArrayList<String>();
    expectedActiveActivityIds.add("end");
    assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds());
}
Also used : EmbeddedSubProcess(org.camunda.bpm.engine.test.standalone.pvm.activities.EmbeddedSubProcess) WaitState(org.camunda.bpm.engine.test.standalone.pvm.activities.WaitState) PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) ProcessDefinitionImpl(org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl) ArrayList(java.util.ArrayList) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) End(org.camunda.bpm.engine.test.standalone.pvm.activities.End) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)

Example 38 with ProcessDefinitionBuilder

use of org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder in project camunda-bpm-platform by camunda.

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.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();
    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(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);
}
Also used : PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) ParallelGateway(org.camunda.bpm.engine.test.standalone.pvm.activities.ParallelGateway) ArrayList(java.util.ArrayList) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) End(org.camunda.bpm.engine.test.standalone.pvm.activities.End) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)

Example 39 with ProcessDefinitionBuilder

use of org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder in project camunda-bpm-platform by camunda.

the class PvmEventTest method testEmbeddedSubProcessEventsDelete.

/**
 *           +-----------------------------------------------+
 * +-----+   | +-----------+   +------------+   +----------+ |   +---+
 * |start|-->| |startInside|-->| taskInside |-->|endInsdide| |-->|end|
 * +-----+   | +-----------+   +------------+   +----------+ |   +---+
 *           +-----------------------------------------------+
 */
public void testEmbeddedSubProcessEventsDelete() {
    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("taskInside").endActivity().createActivity("taskInside").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).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();
    ExecutionImpl execution = (ExecutionImpl) processInstance;
    FoxDeleteProcessInstanceCmd cmd = new FoxDeleteProcessInstanceCmd(null, null);
    List<PvmExecutionImpl> collectExecutionToDelete = cmd.collectExecutionToDelete(execution);
    for (PvmExecutionImpl interpretableExecution : collectExecutionToDelete) {
        interpretableExecution.deleteCascade2("");
    }
    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(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)");
    assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
}
Also used : EmbeddedSubProcess(org.camunda.bpm.engine.test.standalone.pvm.activities.EmbeddedSubProcess) WaitState(org.camunda.bpm.engine.test.standalone.pvm.activities.WaitState) PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) FoxDeleteProcessInstanceCmd(org.camunda.bpm.engine.impl.cmd.FoxDeleteProcessInstanceCmd) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ArrayList(java.util.ArrayList) ExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) End(org.camunda.bpm.engine.test.standalone.pvm.activities.End) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)

Example 40 with ProcessDefinitionBuilder

use of org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder in project camunda-bpm-platform by camunda.

the class PvmParallelTest method testSimpleAutmaticConcurrency.

public 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.isEnded());
}
Also used : PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) ParallelGateway(org.camunda.bpm.engine.test.standalone.pvm.activities.ParallelGateway) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) End(org.camunda.bpm.engine.test.standalone.pvm.activities.End) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)

Aggregations

ProcessDefinitionBuilder (org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder)45 PvmProcessDefinition (org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition)45 PvmProcessInstance (org.camunda.bpm.engine.impl.pvm.PvmProcessInstance)45 Automatic (org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)43 End (org.camunda.bpm.engine.test.standalone.pvm.activities.End)30 WaitState (org.camunda.bpm.engine.test.standalone.pvm.activities.WaitState)22 EmbeddedSubProcess (org.camunda.bpm.engine.test.standalone.pvm.activities.EmbeddedSubProcess)18 ParallelGateway (org.camunda.bpm.engine.test.standalone.pvm.activities.ParallelGateway)12 PvmExecution (org.camunda.bpm.engine.impl.pvm.PvmExecution)11 ArrayList (java.util.ArrayList)9 ExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl)3 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)2 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)2 EventScopeCreatingSubprocess (org.camunda.bpm.engine.test.standalone.pvm.activities.EventScopeCreatingSubprocess)2 While (org.camunda.bpm.engine.test.standalone.pvm.activities.While)2 HashMap (java.util.HashMap)1 FoxDeleteProcessInstanceCmd (org.camunda.bpm.engine.impl.cmd.FoxDeleteProcessInstanceCmd)1 Decision (org.camunda.bpm.engine.test.standalone.pvm.activities.Decision)1 ReusableSubProcess (org.camunda.bpm.engine.test.standalone.pvm.activities.ReusableSubProcess)1 TransitionInstanceVerifyer (org.camunda.bpm.engine.test.standalone.pvm.verification.TransitionInstanceVerifyer)1