use of org.activiti.engine.impl.pvm.PvmExecution 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());
}
use of org.activiti.engine.impl.pvm.PvmExecution 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);
}
use of org.activiti.engine.impl.pvm.PvmExecution in project Activiti by Activiti.
the class PvmEventTest method testNestedActivitiesEventsOnTransitionEvents.
/**
* +--------------+
* |outerscope |
* | +----------+ |
* | |innerscope| |
* +-----+ | | +----+ | | +---+
* |start|---->|wait|------>|end|
* +-----+ | | +----+ | | +---+
* | +----------+ |
* +--------------+
*/
public void testNestedActivitiesEventsOnTransitionEvents() {
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).startTransition("wait").executionListener(eventCollector).endTransition().endActivity().createActivity("outerscope").executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("innerscope").scope().executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("wait").behavior(new WaitState()).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("end").endActivity().endActivity().endActivity().createActivity("end").behavior(new WaitState()).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("take on (start)-->(wait)");
expectedEvents.add("start on Activity(outerscope)");
expectedEvents.add("start on Activity(innerscope)");
expectedEvents.add("start on Activity(wait)");
assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
PvmExecution execution = processInstance.findExecution("wait");
execution.signal(null, null);
expectedEvents.add("end on Activity(wait)");
expectedEvents.add("end on Activity(innerscope)");
expectedEvents.add("end on Activity(outerscope)");
assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
}
use of org.activiti.engine.impl.pvm.PvmExecution 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);
}
use of org.activiti.engine.impl.pvm.PvmExecution in project Activiti by Activiti.
the class PvmScopeAndEventsTest method testStartEndWithScopesAndNestedActivities.
/**
* +--------------------------------------------------------------------------------+
* | mostOuterNestedActivity |
* | +----------------------------------------------------------------------------+ |
* | | outerScope (scope) | |
* | | +----------------------------------+ +-----------------------------------+ | |
* | | | firstInnerScope (scope) | | secondInnerScope (scope) | | |
* | | | +------------------------------+ | | +-------------------------------+ | | |
* | | | | firstMostInnerNestedActivity | | | | secondMostInnerNestedActivity | | | |
* | | | | +-------+ +-------------+ | | | | +--------------+ +-----+ | | | |
* | | | | | start |-->| waitInFirst |--------->| waitInSecond |--> | end | | | | |
* | | | | +-------+ +-------------+ | | | | +--------------+ +-----+ | | | |
* | | | +------------------------------+ | | +-------------------------------+ | | |
* | | +----------------------------------+ +-----------------------------------+ | |
* | +----------------------------------------------------------------------------+ |
* +--------------------------------------------------------------------------------+
*
*/
public void testStartEndWithScopesAndNestedActivities() {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder("scopes and events").executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("mostOuterNestedActivity").executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("outerScope").executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("firstInnerScope").executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("firstMostInnerNestedActivity").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("waitInFirst").endActivity().createActivity("waitInFirst").behavior(new WaitState()).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).transition("waitInSecond").endActivity().endActivity().endActivity().createActivity("secondInnerScope").executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("secondMostInnerNestedActivity").executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, eventCollector).executionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, eventCollector).createActivity("waitInSecond").behavior(new WaitState()).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().endActivity().endActivity().endActivity().endActivity().buildProcessDefinition();
PvmProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.start();
List<String> expectedEvents = new ArrayList<String>();
expectedEvents.add("start on ProcessDefinition(scopes and events)");
expectedEvents.add("start on Activity(mostOuterNestedActivity)");
expectedEvents.add("start on Activity(outerScope)");
expectedEvents.add("start on Activity(firstInnerScope)");
expectedEvents.add("start on Activity(firstMostInnerNestedActivity)");
expectedEvents.add("start on Activity(start)");
expectedEvents.add("end on Activity(start)");
expectedEvents.add("start on Activity(waitInFirst)");
assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
eventCollector.events.clear();
PvmExecution execution = processInstance.findExecution("waitInFirst");
execution.signal(null, null);
expectedEvents = new ArrayList<String>();
expectedEvents.add("end on Activity(waitInFirst)");
expectedEvents.add("end on Activity(firstMostInnerNestedActivity)");
expectedEvents.add("end on Activity(firstInnerScope)");
expectedEvents.add("start on Activity(secondInnerScope)");
expectedEvents.add("start on Activity(secondMostInnerNestedActivity)");
expectedEvents.add("start on Activity(waitInSecond)");
assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
eventCollector.events.clear();
execution = processInstance.findExecution("waitInSecond");
execution.signal(null, null);
expectedEvents = new ArrayList<String>();
expectedEvents.add("end on Activity(waitInSecond)");
expectedEvents.add("start on Activity(end)");
expectedEvents.add("end on Activity(end)");
expectedEvents.add("end on Activity(secondMostInnerNestedActivity)");
expectedEvents.add("end on Activity(secondInnerScope)");
expectedEvents.add("end on Activity(outerScope)");
expectedEvents.add("end on Activity(mostOuterNestedActivity)");
expectedEvents.add("end on ProcessDefinition(scopes and events)");
assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
eventCollector.events.clear();
}
Aggregations