Search in sources :

Example 1 with TransitionInstanceVerifyer

use of org.camunda.bpm.engine.test.standalone.pvm.verification.TransitionInstanceVerifyer in project camunda-bpm-platform by camunda.

the class PvmActivityInstanceTest method testWhileLoop.

/**
 *                  +----------------------------+
 *                  v                            |
 * +-------+   +------+   +-----+   +-----+    +-------+
 * | start |-->| loop |-->| one |-->| two |--> | three |
 * +-------+   +------+   +-----+   +-----+    +-------+
 *                  |
 *                  |   +-----+
 *                  +-->| end |
 *                      +-----+
 */
public void testWhileLoop() {
    ActivityInstanceVerification verifier = new ActivityInstanceVerification();
    TransitionInstanceVerifyer transitionVerifier = new TransitionInstanceVerifyer();
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("start").initial().behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).startTransition("loop").executionListener(ExecutionListener.EVENTNAME_TAKE, transitionVerifier).endTransition().endActivity().createActivity("loop").behavior(new While("count", 0, 10)).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).startTransition("one", "more").executionListener(ExecutionListener.EVENTNAME_TAKE, transitionVerifier).endTransition().startTransition("end", "done").executionListener(ExecutionListener.EVENTNAME_TAKE, transitionVerifier).endTransition().endActivity().createActivity("one").behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("two").endActivity().createActivity("two").behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("three").endActivity().createActivity("three").behavior(new Automatic()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).transition("loop").endActivity().createActivity("end").behavior(new End()).executionListener(ExecutionListener.EVENTNAME_START, verifier).executionListener(ExecutionListener.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    assertEquals(new ArrayList<String>(), processInstance.findActiveActivityIds());
    assertTrue(processInstance.isEnded());
    verifier.assertStartInstanceCount(1, "start");
    verifier.assertProcessInstanceParent("start", processInstance);
    verifier.assertStartInstanceCount(11, "loop");
    verifier.assertProcessInstanceParent("loop", processInstance);
    verifier.assertStartInstanceCount(10, "one");
    verifier.assertProcessInstanceParent("one", processInstance);
    verifier.assertStartInstanceCount(10, "two");
    verifier.assertProcessInstanceParent("two", processInstance);
    verifier.assertStartInstanceCount(10, "three");
    verifier.assertProcessInstanceParent("three", processInstance);
    verifier.assertStartInstanceCount(1, "end");
    verifier.assertProcessInstanceParent("end", processInstance);
}
Also used : PvmProcessInstance(org.camunda.bpm.engine.impl.pvm.PvmProcessInstance) TransitionInstanceVerifyer(org.camunda.bpm.engine.test.standalone.pvm.verification.TransitionInstanceVerifyer) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) End(org.camunda.bpm.engine.test.standalone.pvm.activities.End) While(org.camunda.bpm.engine.test.standalone.pvm.activities.While) ProcessDefinitionBuilder(org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)

Aggregations

ProcessDefinitionBuilder (org.camunda.bpm.engine.impl.pvm.ProcessDefinitionBuilder)1 PvmProcessDefinition (org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition)1 PvmProcessInstance (org.camunda.bpm.engine.impl.pvm.PvmProcessInstance)1 Automatic (org.camunda.bpm.engine.test.standalone.pvm.activities.Automatic)1 End (org.camunda.bpm.engine.test.standalone.pvm.activities.End)1 While (org.camunda.bpm.engine.test.standalone.pvm.activities.While)1 TransitionInstanceVerifyer (org.camunda.bpm.engine.test.standalone.pvm.verification.TransitionInstanceVerifyer)1