Search in sources :

Example 16 with WaitState

use of org.activiti.engine.test.pvm.activities.WaitState 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());
}
Also used : WaitState(org.activiti.engine.test.pvm.activities.WaitState) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) HashMap(java.util.HashMap) PvmProcessDefinition(org.activiti.engine.impl.pvm.PvmProcessDefinition) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) PvmExecution(org.activiti.engine.impl.pvm.PvmExecution)

Example 17 with WaitState

use of org.activiti.engine.test.pvm.activities.WaitState 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());
}
Also used : WaitState(org.activiti.engine.test.pvm.activities.WaitState) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) 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 18 with WaitState

use of org.activiti.engine.test.pvm.activities.WaitState 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());
}
Also used : WaitState(org.activiti.engine.test.pvm.activities.WaitState) PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) 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 19 with WaitState

use of org.activiti.engine.test.pvm.activities.WaitState in project Activiti by Activiti.

the class PvmEmbeddedSubProcessTest method testNestedSubProcessNoEnd.

/** 
   *           +-------------------------------------------------------+
   *           | embedded subprocess                                   |
   *           |                  +--------------------------------+   |
   *           |                  | nested embedded subprocess     |   |
   * +-----+   | +-----------+    |  +-----------+   +---------+   |   |   +---+
   * |start|-->| |startInside|--> |  |startInside|-->|endInside|   |   |-->|end|
   * +-----+   | +-----------+    |  +-----------+   +---------+   |   |   +---+
   *           |                  +--------------------------------+   |
   *           |                                                       |
   *           +-------------------------------------------------------+
   */
public void testNestedSubProcessNoEnd() {
    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 EmbeddedSubProcess()).createActivity("startNestedInside").behavior(new Automatic()).transition("endInside").endActivity().createActivity("endInside").behavior(new End()).endActivity().endActivity().transition("end").endActivity().createActivity("end").behavior(new WaitState()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    List<String> expectedActiveActivityIds = new ArrayList<String>();
    expectedActiveActivityIds.add("end");
    assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds());
}
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) End(org.activiti.engine.test.pvm.activities.End) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic)

Example 20 with WaitState

use of org.activiti.engine.test.pvm.activities.WaitState in project Activiti by Activiti.

the class PvmEmbeddedSubProcessTest method testEmbeddedSubProcess.

/** 
   *           +------------------------------+
   *           | embedded subprocess          |
   * +-----+   |  +-----------+   +---------+ |   +---+
   * |start|-->|  |startInside|-->|endInside| |-->|end|
   * +-----+   |  +-----------+   +---------+ |   +---+
   *           +------------------------------+
   */
public void testEmbeddedSubProcess() {
    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("endInside").endActivity().createActivity("endInside").behavior(new End()).endActivity().transition("end").endActivity().createActivity("end").behavior(new WaitState()).endActivity().buildProcessDefinition();
    PvmProcessInstance processInstance = processDefinition.createProcessInstance();
    processInstance.start();
    List<String> expectedActiveActivityIds = new ArrayList<String>();
    expectedActiveActivityIds.add("end");
    assertEquals(expectedActiveActivityIds, processInstance.findActiveActivityIds());
}
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) End(org.activiti.engine.test.pvm.activities.End) ProcessDefinitionBuilder(org.activiti.engine.impl.pvm.ProcessDefinitionBuilder) Automatic(org.activiti.engine.test.pvm.activities.Automatic)

Aggregations

ProcessDefinitionBuilder (org.activiti.engine.impl.pvm.ProcessDefinitionBuilder)24 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)24 PvmProcessInstance (org.activiti.engine.impl.pvm.PvmProcessInstance)24 WaitState (org.activiti.engine.test.pvm.activities.WaitState)24 Automatic (org.activiti.engine.test.pvm.activities.Automatic)23 PvmExecution (org.activiti.engine.impl.pvm.PvmExecution)15 ArrayList (java.util.ArrayList)13 End (org.activiti.engine.test.pvm.activities.End)13 ParallelGateway (org.activiti.engine.test.pvm.activities.ParallelGateway)11 EmbeddedSubProcess (org.activiti.engine.test.pvm.activities.EmbeddedSubProcess)4 EventScopeCreatingSubprocess (org.activiti.engine.test.pvm.activities.EventScopeCreatingSubprocess)2 HashMap (java.util.HashMap)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)1 ExecutionImpl (org.activiti.engine.impl.pvm.runtime.ExecutionImpl)1