Search in sources :

Example 1 with PvmExecution

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

the class PvmActivityInstanceCompleteTest method testBoundaryEvent.

/**
 *           +----------+
 *           | userTask |
 *           |          |
 * +-----+   |          |    +------+
 * |start|-->|          |--->| end1 |
 * +-----+   | +-----+  |
 *           +-|timer|--+
 *             +-----+
 *                |          +------+
 *                +--------->| end2 |
 *                           +------+
 */
public void testBoundaryEvent() {
    ActivityInstanceVerification verifier = new ActivityInstanceVerification();
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("start").initial().behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("userTask").endActivity().createActivity("userTask").scope().behavior(new EmbeddedSubProcess()).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("end1").endActivity().createActivity("timer").behavior(new WaitState()).executionListener(ExecutionListener.EVENTNAME_END, verifier).attachedTo("userTask", true).transition("end2").endActivity().createActivity("end1").behavior(new End()).executionListener(ExecutionListener.EVENTNAME_END, verifier).endActivity().createActivity("end2").behavior(new End()).executionListener(ExecutionListener.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    PvmExecution userTaskExecution = processInstance.findExecution("userTask");
    ((PvmExecutionImpl) userTaskExecution).executeActivity(processDefinition.findActivity("timer"));
    PvmExecution timerExecution = processInstance.findExecution("timer");
    timerExecution.signal(null, null);
    verifier.assertNonCompletingActivityInstance("start", 1);
    verifier.assertNonCompletingActivityInstance("userTask", 1);
    verifier.assertIsCompletingActivityInstance("end2", 1);
}
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) 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) PvmExecution(org.camunda.bpm.engine.impl.pvm.PvmExecution)

Example 2 with PvmExecution

use of org.camunda.bpm.engine.impl.pvm.PvmExecution 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 3 with PvmExecution

use of org.camunda.bpm.engine.impl.pvm.PvmExecution 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 4 with PvmExecution

use of org.camunda.bpm.engine.impl.pvm.PvmExecution 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)

Example 5 with PvmExecution

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

the class PvmVariablesTest method testVariables.

@Test
public 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"));
    Map<String, Object> expectedVariables = new HashMap<String, Object>();
    expectedVariables.put("amount", 500L);
    expectedVariables.put("msg", "hello world");
    assertEquals(expectedVariables, activityInstance.getVariables());
    assertEquals(expectedVariables, processInstance.getVariables());
}
Also used : WaitState(org.camunda.bpm.engine.test.standalone.pvm.activities.WaitState) PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) HashMap(java.util.HashMap) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) PvmExecution(org.camunda.bpm.engine.impl.pvm.PvmExecution) Test(org.junit.Test)

Aggregations

ProcessDefinitionBuilder (org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder)11 PvmExecution (org.camunda.bpm.engine.impl.pvm.PvmExecution)11 PvmProcessDefinition (org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition)11 PvmProcessInstance (org.camunda.bpm.engine.impl.pvm.PvmProcessInstance)11 WaitState (org.camunda.bpm.engine.test.standalone.pvm.activities.WaitState)11 Automatic (org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)9 End (org.camunda.bpm.engine.test.standalone.pvm.activities.End)7 EmbeddedSubProcess (org.camunda.bpm.engine.test.standalone.pvm.activities.EmbeddedSubProcess)4 ParallelGateway (org.camunda.bpm.engine.test.standalone.pvm.activities.ParallelGateway)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 ExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl)1 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)1 EventScopeCreatingSubprocess (org.camunda.bpm.engine.test.standalone.pvm.activities.EventScopeCreatingSubprocess)1 Test (org.junit.Test)1