Search in sources :

Example 36 with PvmProcessDefinition

use of org.activiti.engine.impl.pvm.PvmProcessDefinition in project Activiti by Activiti.

the class PvmEmbeddedSubProcessTest method testMultipleConcurrentEndsInsideEmbeddedSubProcessWithWaitState.

/** 
   *           +-------------------------------------------------+
   *           | embeddedsubprocess        +----------+          |
   *           |                     +---->|endInside1|          |
   *           |                     |     +----------+          |
   *           |                     |                           |
   * +-----+   |  +-----------+   +----+   +----+   +----------+ |   +---+
   * |start|-->|  |startInside|-->|fork|-->|wait|-->|endInside2| |-->|end|
   * +-----+   |  +-----------+   +----+   +----+   +----------+ |   +---+
   *           |                     |                           |
   *           |                     |     +----------+          |
   *           |                     +---->|endInside3|          |
   *           |                           +----------+          |
   *           +-------------------------------------------------+
   */
public void testMultipleConcurrentEndsInsideEmbeddedSubProcessWithWaitState() {
    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("fork").endActivity().createActivity("fork").behavior(new ParallelGateway()).transition("endInside1").transition("wait").transition("endInside3").endActivity().createActivity("endInside1").behavior(new End()).endActivity().createActivity("wait").behavior(new WaitState()).transition("endInside2").endActivity().createActivity("endInside2").behavior(new End()).endActivity().createActivity("endInside3").behavior(new End()).endActivity().transition("end").endActivity().createActivity("end").behavior(new End()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    assertFalse(processInstance.isEnded());
    PvmExecution execution = processInstance.findExecution("wait");
    execution.signal(null, null);
    assertTrue(processInstance.isEnded());
}
Also used : EmbeddedSubProcess(org.activiti.engine.test.pvm.activities.EmbeddedSubProcess) WaitState(org.activiti.engine.test.pvm.activities.WaitState) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ParallelGateway(org.activiti.engine.test.pvm.activities.ParallelGateway) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) End(org.activiti.engine.test.pvm.activities.End) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic) PvmExecution(org.activiti.engine.impl.pvm.PvmExecution)

Example 37 with PvmProcessDefinition

use of org.activiti.engine.impl.pvm.PvmProcessDefinition in project Activiti by Activiti.

the class PvmEventScopesTest method testActivityEndDestroysEventScopes.

/** 
   * 
   *                       create evt scope --+
   *                                          |   
   *                                          v                                        
   *                                          
   *           +------------------------------+
   *           | embedded subprocess          |
   * +-----+   |  +-----------+   +---------+ |   +----+   +---+
   * |start|-->|  |startInside|-->|endInside| |-->|wait|-->|end|
   * +-----+   |  +-----------+   +---------+ |   +----+   +---+
   *           +------------------------------+
   *           
   *                                                           ^  
   *                                                           |
   *                                       destroy evt scope --+  
   *           
   */
public void testActivityEndDestroysEventScopes() {
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("start").initial().behavior(new Automatic()).transition("embeddedsubprocess").endActivity().createActivity("embeddedsubprocess").scope().behavior(new EventScopeCreatingSubprocess()).createActivity("startInside").behavior(new Automatic()).transition("endInside").endActivity().createActivity("endInside").behavior(new Automatic()).endActivity().transition("wait").endActivity().createActivity("wait").behavior(new WaitState()).transition("end").endActivity().createActivity("end").behavior(new Automatic()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    boolean eventScopeFound = false;
    List<ExecutionImpl> executions = ((ExecutionImpl) processInstance).getExecutions();
    for (ExecutionImpl executionImpl : executions) {
        if (executionImpl.isEventScope()) {
            eventScopeFound = true;
            break;
        }
    }
    assertTrue(eventScopeFound);
    processInstance.signal(null, null);
    assertTrue(processInstance.isEnded());
}
Also used : WaitState(org.activiti.engine.test.pvm.activities.WaitState) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ExecutionImpl(org.activiti.engine.impl.pvm.runtime.ExecutionImpl) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) EventScopeCreatingSubprocess(org.activiti.engine.test.pvm.activities.EventScopeCreatingSubprocess) Automatic(org.activiti.engine.test.pvm.activities.Automatic)

Example 38 with PvmProcessDefinition

use of org.activiti.engine.impl.pvm.PvmProcessDefinition in project Activiti by Activiti.

the class PvmEventTest method testStartEndEvents.

/**
   * +-------+   +-----+
   * | start |-->| end |
   * +-------+   +-----+
   */
public void testStartEndEvents() {
    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("end").executionListener(eventCollector).endTransition().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(events)");
    expectedEvents.add("start on Activity(start)");
    expectedEvents.add("end on Activity(start)");
    expectedEvents.add("take on (start)-->(end)");
    expectedEvents.add("start on Activity(end)");
    expectedEvents.add("end on Activity(end)");
    expectedEvents.add("end on ProcessDefinition(events)");
    assertEquals("expected " + expectedEvents + ", but was \n" + eventCollector + "\n", expectedEvents, eventCollector.events);
}
Also used : PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ArrayList(java.util.ArrayList) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) End(org.activiti.engine.test.pvm.activities.End) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic)

Example 39 with PvmProcessDefinition

use of org.activiti.engine.impl.pvm.PvmProcessDefinition in project Activiti by Activiti.

the class PvmParallelTest method testSimpleAutmaticConcurrency.

public void testSimpleAutmaticConcurrency() {
    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 Automatic()).transition("join").endActivity().createActivity("c2").behavior(new Automatic()).transition("join").endActivity().createActivity("join").behavior(new ParallelGateway()).transition("end").endActivity().createActivity("end").behavior(new End()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    assertTrue(processInstance.isEnded());
}
Also used : PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ParallelGateway(org.activiti.engine.test.pvm.activities.ParallelGateway) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) End(org.activiti.engine.test.pvm.activities.End) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic)

Example 40 with PvmProcessDefinition

use of org.activiti.engine.impl.pvm.PvmProcessDefinition in project Activiti by Activiti.

the class PvmParallelTest method testUnstructuredConcurrencyTwoForks.

public void testUnstructuredConcurrencyTwoForks() {
    PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder().createActivity("start").initial().behavior(new Automatic()).transition("fork1").endActivity().createActivity("fork1").behavior(new ParallelGateway()).transition("c1").transition("c2").transition("fork2").endActivity().createActivity("c1").behavior(new Automatic()).transition("join").endActivity().createActivity("c2").behavior(new Automatic()).transition("join").endActivity().createActivity("fork2").behavior(new ParallelGateway()).transition("c3").transition("c4").endActivity().createActivity("c3").behavior(new Automatic()).transition("join").endActivity().createActivity("c4").behavior(new Automatic()).transition("join").endActivity().createActivity("join").behavior(new ParallelGateway()).transition("end").endActivity().createActivity("end").behavior(new WaitState()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    assertNotNull(processInstance.findExecution("end"));
}
Also used : WaitState(org.activiti.engine.test.pvm.activities.WaitState) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ParallelGateway(org.activiti.engine.test.pvm.activities.ParallelGateway) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic)

Aggregations

PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)42 ProcessDefinitionBuilder (org.activiti.engine.impl.pvm.ProcessDefinitionBuilder)40 PvmProcessInstance (org.activiti.engine.impl.pvm.PvmProcessInstance)40 Automatic (org.activiti.engine.test.pvm.activities.Automatic)36 End (org.activiti.engine.test.pvm.activities.End)24 WaitState (org.activiti.engine.test.pvm.activities.WaitState)24 ArrayList (java.util.ArrayList)16 PvmExecution (org.activiti.engine.impl.pvm.PvmExecution)16 ParallelGateway (org.activiti.engine.test.pvm.activities.ParallelGateway)15 EmbeddedSubProcess (org.activiti.engine.test.pvm.activities.EmbeddedSubProcess)9 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)3 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)2 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)2 EventScopeCreatingSubprocess (org.activiti.engine.test.pvm.activities.EventScopeCreatingSubprocess)2 HashMap (java.util.HashMap)1 ActivitiException (org.activiti.engine.ActivitiException)1 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)1 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)1 ExecutionImpl (org.activiti.engine.impl.pvm.runtime.ExecutionImpl)1 ReusableSubProcess (org.activiti.engine.test.pvm.activities.ReusableSubProcess)1