Search in sources :

Example 6 with PvmProcessDefinition

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

the class PvmEventScopesTest method testTransitionDestroysEventScope.

/**
 *           +----------------------------------------------------------------------+
 *           | embedded subprocess                                                  |
 *           |                                                                      |
 *           |                                create evt scope --+                  |
 *           |                                                   |                  |
 *           |                                                   v                  |
 *           |                                                                      |
 *           |                  +--------------------------------+                  |
 *           |                  | nested embedded subprocess     |                  |
 * +-----+   | +-----------+    |  +-----------------+           |   +----+   +---+ |   +---+
 * |start|-->| |startInside|--> |  |startNestedInside|           |-->|wait|-->|end| |-->|end|
 * +-----+   | +-----------+    |  +-----------------+           |   +----+   +---+ |   +---+
 *           |                  +--------------------------------+                  |
 *           |                                                                      |
 *           +----------------------------------------------------------------------+
 *
 *                                                                                  ^
 *                                                                                  |
 *                                                              destroy evt scope --+
 */
public 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();
    List<String> expectedActiveActivityIds = new ArrayList<String>();
    expectedActiveActivityIds.add("wait");
    assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds());
    PvmExecution execution = processInstance.findExecution("wait");
    execution.signal(null, null);
    assertTrue(processInstance.isEnded());
}
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) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) EventScopeCreatingSubprocess(org.camunda.bpm.engine.test.standalone.pvm.activities.EventScopeCreatingSubprocess) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic) PvmExecution(org.camunda.bpm.engine.impl.pvm.PvmExecution)

Example 7 with PvmProcessDefinition

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

the class PvmEventScopesTest method testActivityEndDestroysEventScopes.

/**
 *                       create evt scope --+
 *                                          |
 *                                          v
 *
 *           +------------------------------+
 *           | embedded subprocess          |
 * +-----+   |  +-----------+   +---------+ |   +----+   +---+
 * |start|-->|  |startInside|-->|endInside| |-->|wait|-->|end|
 * +-----+   |  +-----------+   +---------+ |   +----+   +---+
 *           +------------------------------+
 *
 *                                                           ^
 *                                                           |
 *                                       destroy evt scope --+
 */
public 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();
    boolean eventScopeFound = false;
    List<ExecutionImpl> executions = ((ExecutionImpl) processInstance).getExecutions();
    for (ExecutionImpl executionImpl : executions) {
        if (executionImpl.isEventScope()) {
            eventScopeFound = true;
            break;
        }
    }
    assertTrue(eventScopeFound);
    processInstance.signal(null, null);
    assertTrue(processInstance.isEnded());
}
Also used : WaitState(org.camunda.bpm.engine.test.standalone.pvm.activities.WaitState) PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) ExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) EventScopeCreatingSubprocess(org.camunda.bpm.engine.test.standalone.pvm.activities.EventScopeCreatingSubprocess) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)

Example 8 with PvmProcessDefinition

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

the class PvmScopeWaitStateTest method testWaitStateScope.

/**
 * +-----+   +----------+   +---+
 * |start|-->|scopedWait|-->|end|
 * +-----+   +----------+   +---+
 */
public 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 ArrayList<String>(), processInstance.findActiveActivityIds());
    assertTrue(processInstance.isEnded());
}
Also used : WaitState(org.camunda.bpm.engine.test.standalone.pvm.activities.WaitState) PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) 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) PvmExecution(org.camunda.bpm.engine.impl.pvm.PvmExecution)

Example 9 with PvmProcessDefinition

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

the class PvmActivityInstanceTest method testWhileLoop.

/**
 *                  +----------------------------+
 *                  v                            |
 * +-------+   +------+   +-----+   +-----+    +-------+
 * | start |-->| loop |-->| one |-->| two |--> | three |
 * +-------+   +------+   +-----+   +-----+    +-------+
 *                  |
 *                  |   +-----+
 *                  +-->| end |
 *                      +-----+
 */
public void testWhileLoop() {
    ActivityInstanceVerification verifier = new ActivityInstanceVerification();
    TransitionInstanceVerifyer transitionVerifier = new TransitionInstanceVerifyer();
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("start").initial().behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).startTransition("loop").executionListener(ExecutionListener.EVENTNAME_TAKE, transitionVerifier).endTransition().endActivity().createActivity("loop").behavior(new While("count", 0, 10)).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).startTransition("one", "more").executionListener(ExecutionListener.EVENTNAME_TAKE, transitionVerifier).endTransition().startTransition("end", "done").executionListener(ExecutionListener.EVENTNAME_TAKE, transitionVerifier).endTransition().endActivity().createActivity("one").behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("two").endActivity().createActivity("two").behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("three").endActivity().createActivity("three").behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("loop").endActivity().createActivity("end").behavior(new End()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    assertEquals(new ArrayList<String>(), processInstance.findActiveActivityIds());
    assertTrue(processInstance.isEnded());
    verifier.assertStartInstanceCount(1, "start");
    verifier.assertProcessInstanceParent("start", processInstance);
    verifier.assertStartInstanceCount(11, "loop");
    verifier.assertProcessInstanceParent("loop", processInstance);
    verifier.assertStartInstanceCount(10, "one");
    verifier.assertProcessInstanceParent("one", processInstance);
    verifier.assertStartInstanceCount(10, "two");
    verifier.assertProcessInstanceParent("two", processInstance);
    verifier.assertStartInstanceCount(10, "three");
    verifier.assertProcessInstanceParent("three", processInstance);
    verifier.assertStartInstanceCount(1, "end");
    verifier.assertProcessInstanceParent("end", processInstance);
}
Also used : PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) TransitionInstanceVerifyer(org.camunda.bpm.engine.test.standalone.pvm.verification.TransitionInstanceVerifyer) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) End(org.camunda.bpm.engine.test.standalone.pvm.activities.End) While(org.camunda.bpm.engine.test.standalone.pvm.activities.While) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)

Example 10 with PvmProcessDefinition

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

the class PvmActivityInstanceTest method testScopeActivity.

/**
 * +-----+   +-----+   +-------+
 * | one |-->| two |-->| three |
 * +-----+   +-----+   +-------+
 */
public void testScopeActivity() {
    ActivityInstanceVerification verifier = new ActivityInstanceVerification();
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("one").initial().behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("two").endActivity().createActivity("two").scope().behavior(new WaitState()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("three").endActivity().createActivity("three").behavior(new End()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    PvmExecution childExecution = processInstance.findExecution("two");
    String parentActivityInstanceId = ((ExecutionImpl) childExecution).getParentActivityInstanceId();
    assertEquals(((ExecutionImpl) processInstance).getId(), parentActivityInstanceId);
    childExecution.signal(null, null);
    verifier.assertStartInstanceCount(1, "one");
    verifier.assertStartInstanceCount(1, "two");
    verifier.assertProcessInstanceParent("two", processInstance);
    verifier.assertStartInstanceCount(1, "three");
}
Also used : WaitState(org.camunda.bpm.engine.test.standalone.pvm.activities.WaitState) PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) ExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl) 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) PvmExecution(org.camunda.bpm.engine.impl.pvm.PvmExecution)

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