// 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)");