use of org.activiti.engine.test.pvm.activities.WaitState 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.test.pvm.activities.WaitState in project Activiti by Activiti.
the class PvmProcessInstanceEndTest method testSimpleProcessInstanceEnd.
public void testSimpleProcessInstanceEnd() {
EventCollector eventCollector = new EventCollector();
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().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()).transition("wait").endActivity().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).endActivity().buildProcessDefinition();
PvmProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.start();
System.err.println(eventCollector);
processInstance.deleteCascade("test");
System.err.println();
System.err.println(eventCollector);
}
use of org.activiti.engine.test.pvm.activities.WaitState 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();
}
use of org.activiti.engine.test.pvm.activities.WaitState in project Activiti by Activiti.
the class PvmScopeAndEventsTest method testStartEndWithScopesAndNestedActivitiesNotAtInitial.
/**
* +--------------------------------------------------------------------------------+
* | mostOuterNestedActivity |
* | +----------------------------------------------------------------------------+ |
* | | outerScope (scope) | |
* | | +----------------------------------+ +-----------------------------------+ | |
* | | | firstInnerScope (scope) | | secondInnerScope (scope) | | |
* | | | +------------------------------+ | | +-------------------------------+ | | |
* | | | | firstMostInnerNestedActivity | | | | secondMostInnerNestedActivity | | | |
* | | | | +-------+ +-------------+ | | | | +--------------+ +-----+ | | | |
* | | | | | start |-->| waitInFirst |--------->| waitInSecond |--> | end | | | | |
* | | | | +-------+ +-------------+ | | | | +--------------+ +-----+ | | | |
* | | | +------------------------------+ | | +-------------------------------+ | | |
* | | +----------------------------------+ +-----------------------------------+ | |
* | +----------------------------------------------------------------------------+ |
* +--------------------------------------------------------------------------------+
*
*/
// this test does not start the process at the initial (the activity with id 'start'), but at
// 'waitInFirst'
public void testStartEndWithScopesAndNestedActivitiesNotAtInitial() {
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();
ActivityImpl alternativeInitial = (ActivityImpl) processDefinition.findActivity("waitInFirst");
PvmProcessInstance processInstance = ((ProcessDefinitionImpl) processDefinition).createProcessInstanceForInitial(alternativeInitial);
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(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();
}
use of org.activiti.engine.test.pvm.activities.WaitState in project Activiti by Activiti.
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());
}
Aggregations