Search in sources :

Example 1 with PvmProcessInstance

use of org.activiti.engine.impl.pvm.PvmProcessInstance in project Activiti by Activiti.

the class PvmTest method testPvmAutomatic.

public void testPvmAutomatic() {
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("a").initial().behavior(new Automatic()).transition("b").endActivity().createActivity("b").behavior(new Automatic()).transition("c").endActivity().createActivity("c").behavior(new WaitState()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    assertNotNull(processInstance.findExecution("c"));
}
Also used : PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder)

Example 2 with PvmProcessInstance

use of org.activiti.engine.impl.pvm.PvmProcessInstance in project Activiti by Activiti.

the class PvmTest method testPvmDecision.

public void testPvmDecision() {
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("start").initial().behavior(new Automatic()).transition("checkCredit").endActivity().createActivity("checkCredit").behavior(new Decision()).transition("askDaughterOut", "wow").transition("takeToGolf", "nice").transition("ignore", "default").endActivity().createActivity("takeToGolf").behavior(new WaitState()).endActivity().createActivity("askDaughterOut").behavior(new WaitState()).endActivity().createActivity("ignore").behavior(new WaitState()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.setVariable("creditRating", "Aaa-");
    processInstance.start();
    assertNotNull(processInstance.findExecution("takeToGolf"));
    processInstance = processDefinition.createProcessInstance();
    processInstance.setVariable("creditRating", "AAA+");
    processInstance.start();
    assertNotNull(processInstance.findExecution("askDaughterOut"));
    processInstance = processDefinition.createProcessInstance();
    processInstance.setVariable("creditRating", "bb-");
    processInstance.start();
    assertNotNull(processInstance.findExecution("ignore"));
}
Also used : PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder)

Example 3 with PvmProcessInstance

use of org.activiti.engine.impl.pvm.PvmProcessInstance in project Activiti by Activiti.

the class PvmScopesAndConcurrencyTest method testConcurrentPathsComingOutOfScope.

/**
   *         +---------+ 
   *         |scope    |  +--+
   *         |      +---->|c1|
   *         |      |  |  +--+
   *         |      |  |
   * +-----+ |  +----+ |  +--+ 
   * |start|--->|fork|--->|c2|
   * +-----+ |  +----+ |  +--+
   *         |      |  |
   *         |      |  |  +--+
   *         |      +---->|c3|
   *         |         |  +--+
   *         +---------+
   */
public void testConcurrentPathsComingOutOfScope() {
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("start").initial().behavior(new Automatic()).transition("fork").endActivity().createActivity("scope").scope().createActivity("fork").behavior(new ParallelGateway()).transition("c1").transition("c2").transition("c3").endActivity().endActivity().createActivity("c1").behavior(new WaitState()).endActivity().createActivity("c2").behavior(new WaitState()).endActivity().createActivity("c3").behavior(new WaitState()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    List<String> activeActivityIds = processInstance.findActiveActivityIds();
    List<String> expectedActiveActivityIds = new ArrayList<String>();
    expectedActiveActivityIds.add("c3");
    expectedActiveActivityIds.add("c1");
    expectedActiveActivityIds.add("c2");
    assertEquals(expectedActiveActivityIds, activeActivityIds);
}
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)

Example 4 with PvmProcessInstance

use of org.activiti.engine.impl.pvm.PvmProcessInstance in project Activiti by Activiti.

the class PvmScopesAndConcurrencyTest method testConcurrentPathsThroughNonScopeNestedActivity.

/**
   *                      +---------+
   *                      | +----+  |
   *                  +---->| c1 |------+
   *                  |   | +----+  |   v
   * +-------+   +------+ |         | +------+   +-----+
   * | start |-->| fork | | noscope | | join |-->| end |
   * +-------+   +------+ |         | +------+   +-----+
   *                  |   | +----+  |   ^
   *                  +---->| c2 |------+
   *                      | +----+  |
   *                      +---------+
   */
public void testConcurrentPathsThroughNonScopeNestedActivity() {
    EventCollector eventCollector = new EventCollector();
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("scopes and concurrency").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("noscope").executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("c1").behavior(new WaitState()).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 WaitState()).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("join").endActivity().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(scopes and concurrency)");
    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(noscope)");
    expectedEvents.add("start on Activity(c1)");
    expectedEvents.add("end on Activity(fork)");
    expectedEvents.add("start on Activity(noscope)");
    expectedEvents.add("start on Activity(c2)");
    assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
    eventCollector.events.clear();
    PvmExecution execution = processInstance.findExecution("c1");
    execution.signal(null, null);
    expectedEvents = new ArrayList<String>();
    expectedEvents.add("end on Activity(c1)");
    expectedEvents.add("end on Activity(noscope)");
    expectedEvents.add("start on Activity(join)");
    assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
    eventCollector.events.clear();
    execution = processInstance.findExecution("c2");
    execution.signal(null, null);
    expectedEvents = new ArrayList<String>();
    expectedEvents.add("end on Activity(c2)");
    expectedEvents.add("end on Activity(noscope)");
    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(scopes and concurrency)");
    assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
    eventCollector.events.clear();
    assertTrue(processInstance.isEnded());
}
Also used : WaitState(org.activiti.engine.test.pvm.activities.WaitState) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ArrayList(java.util.ArrayList) PvmExecution(org.activiti.engine.impl.pvm.PvmExecution) 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 5 with PvmProcessInstance

use of org.activiti.engine.impl.pvm.PvmProcessInstance in project Activiti by Activiti.

the class PvmScopesAndConcurrencyTest method testConcurrentPathsJoiningInsideScope.

/**
   *                      +--------------------+
   *                      | +----+             |
   *                  +---->| c1 |------+      |
   *                  |   | +----+      v      |
   * +-------+   +------+ |           +------+ | +-----+
   * | start |-->| fork | |  scope    | join |-->| end |
   * +-------+   +------+ |           +------+ | +-----+
   *                  |   | +----+      ^      |
   *                  +---->| c2 |------+      |
   *                      | +----+             |
   *                      +--------------------+
   */
public void testConcurrentPathsJoiningInsideScope() {
    EventCollector eventCollector = new EventCollector();
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("scopes and concurrency").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("scope").scope().executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("c1").behavior(new WaitState()).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 WaitState()).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().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(scopes and concurrency)");
    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(scope)");
    expectedEvents.add("start on Activity(c1)");
    expectedEvents.add("end on Activity(fork)");
    expectedEvents.add("start on Activity(scope)");
    expectedEvents.add("start on Activity(c2)");
    assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
    eventCollector.events.clear();
    PvmExecution execution = processInstance.findExecution("c1");
    execution.signal(null, null);
    expectedEvents = new ArrayList<String>();
    expectedEvents.add("end on Activity(c1)");
    expectedEvents.add("start on Activity(join)");
    assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
    eventCollector.events.clear();
    execution = processInstance.findExecution("c2");
    // this process gets blocked in the join
    execution.signal(null, null);
}
Also used : WaitState(org.activiti.engine.test.pvm.activities.WaitState) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ArrayList(java.util.ArrayList) PvmExecution(org.activiti.engine.impl.pvm.PvmExecution) 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

PvmProcessInstance (org.activiti.engine.impl.pvm.PvmProcessInstance)42 ProcessDefinitionBuilder (org.activiti.engine.impl.pvm.ProcessDefinitionBuilder)40 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)40 Automatic (org.activiti.engine.test.pvm.activities.Automatic)36 End (org.activiti.engine.test.pvm.activities.End)24 WaitState (org.activiti.engine.test.pvm.activities.WaitState)24 ArrayList (java.util.ArrayList)16 PvmExecution (org.activiti.engine.impl.pvm.PvmExecution)16 ParallelGateway (org.activiti.engine.test.pvm.activities.ParallelGateway)15 EmbeddedSubProcess (org.activiti.engine.test.pvm.activities.EmbeddedSubProcess)9 EventScopeCreatingSubprocess (org.activiti.engine.test.pvm.activities.EventScopeCreatingSubprocess)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ActivitiException (org.activiti.engine.ActivitiException)1 AbstractDataAssociation (org.activiti.engine.impl.bpmn.data.AbstractDataAssociation)1 DeploymentManager (org.activiti.engine.impl.persistence.deploy.DeploymentManager)1 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)1 ExecutionImpl (org.activiti.engine.impl.pvm.runtime.ExecutionImpl)1