Search in sources :

Example 1 with EventScopeCreatingSubprocess

use of org.activiti.engine.test.pvm.activities.EventScopeCreatingSubprocess 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());
}
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) ArrayList(java.util.ArrayList) 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) PvmExecution(org.activiti.engine.impl.pvm.PvmExecution)

Example 2 with EventScopeCreatingSubprocess

use of org.activiti.engine.test.pvm.activities.EventScopeCreatingSubprocess 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)

Aggregations

ProcessDefinitionBuilder (org.activiti.engine.impl.pvm.ProcessDefinitionBuilder)2 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)2 PvmProcessInstance (org.activiti.engine.impl.pvm.PvmProcessInstance)2 Automatic (org.activiti.engine.test.pvm.activities.Automatic)2 EventScopeCreatingSubprocess (org.activiti.engine.test.pvm.activities.EventScopeCreatingSubprocess)2 WaitState (org.activiti.engine.test.pvm.activities.WaitState)2 ArrayList (java.util.ArrayList)1 PvmExecution (org.activiti.engine.impl.pvm.PvmExecution)1 ExecutionImpl (org.activiti.engine.impl.pvm.runtime.ExecutionImpl)1 EmbeddedSubProcess (org.activiti.engine.test.pvm.activities.EmbeddedSubProcess)1