use of org.activiti.engine.impl.pvm.PvmExecution in project Activiti by Activiti.
the class PvmScopesAndConcurrencyTest method testConcurrentPathsThroughScope.
/**
* +---------+
* | +----+ |
* +---->| c1 |------+
* | | +----+ | v
* +-------+ +------+ | | +------+ +-----+
* | start |-->| fork | | scope | | join |-->| end |
* +-------+ +------+ | | +------+ +-----+
* | | +----+ | ^
* +---->| c2 |------+
* | +----+ |
* +---------+
*/
public void testConcurrentPathsThroughScope() {
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().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(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("end on Activity(scope)");
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(scope)");
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 testConcurrentPathsGoingOutOfScope.
/**
* +--------------------+
* | +----+ |
* | +---->| c1 |------+
* | | +----+ | v
* +-------+ | +------+ | +------+ +-----+
* | start |-->| fork | scope | | join |-->| end |
* +-------+ | +------+ | +------+ +-----+
* | | +----+ | ^
* | +---->| c2 |------+
* | +----+ |
* +--------------------+
*/
public void testConcurrentPathsGoingOutOfScope() {
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("scope").scope().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().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(scope)");
expectedEvents.add("start on Activity(fork)");
expectedEvents.add("end on Activity(fork)");
expectedEvents.add("start on Activity(c1)");
expectedEvents.add("end on Activity(fork)");
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(scope)");
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(scope)");
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 PvmVariablesTest method testVariables.
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());
}
use of org.activiti.engine.impl.pvm.PvmExecution in project Activiti by Activiti.
the class PvmBasicLinearExecutionTest method testSingleWaitState.
/**
* +-----+ +-----+ +-------+
* | one |-->| two |-->| three |
* +-----+ +-----+ +-------+
*/
public void testSingleWaitState() {
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("one").initial().behavior(new Automatic()).transition("two").endActivity().createActivity("two").behavior(new WaitState()).transition("three").endActivity().createActivity("three").behavior(new End()).endActivity().buildProcessDefinition();
PvmProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.start();
PvmExecution activityInstance = processInstance.findExecution("two");
assertNotNull(activityInstance);
activityInstance.signal(null, null);
assertEquals(new ArrayList<String>(), processInstance.findActiveActivityIds());
assertTrue(processInstance.isEnded());
}
use of org.activiti.engine.impl.pvm.PvmExecution in project Activiti by Activiti.
the class PvmBasicLinearExecutionTest method testCombinationOfWaitStatesAndAutomatics.
/**
* +-----+ +-----+ +-------+ +------+ +------+
* | one |-->| two |-->| three |-->| four |--> | five |
* +-----+ +-----+ +-------+ +------+ +------+
*/
public void testCombinationOfWaitStatesAndAutomatics() {
PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("start").initial().behavior(new Automatic()).transition("one").endActivity().createActivity("one").behavior(new WaitState()).transition("two").endActivity().createActivity("two").behavior(new WaitState()).transition("three").endActivity().createActivity("three").behavior(new Automatic()).transition("four").endActivity().createActivity("four").behavior(new Automatic()).transition("five").endActivity().createActivity("five").behavior(new End()).endActivity().buildProcessDefinition();
PvmProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.start();
PvmExecution activityInstance = processInstance.findExecution("one");
assertNotNull(activityInstance);
activityInstance.signal(null, null);
activityInstance = processInstance.findExecution("two");
assertNotNull(activityInstance);
activityInstance.signal(null, null);
assertEquals(new ArrayList<String>(), processInstance.findActiveActivityIds());
assertTrue(processInstance.isEnded());
}
Aggregations