Search in sources :

Example 1 with CaseExecutionImpl

use of org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl in project camunda-bpm-platform by camunda.

the class ExecutionImpl method createSubCaseInstance.

public CaseExecutionImpl createSubCaseInstance(CmmnCaseDefinition caseDefinition, String businessKey) {
    CaseExecutionImpl caseInstance = (CaseExecutionImpl) caseDefinition.createCaseInstance(businessKey);
    // manage bidirectional super-process-sub-case-instances relation
    subCaseInstance.setSuperExecution(this);
    setSubCaseInstance(subCaseInstance);
    return caseInstance;
}
Also used : CaseExecutionImpl(org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl)

Example 2 with CaseExecutionImpl

use of org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl in project camunda-bpm-platform by camunda.

the class CaseExecutionCompletionTest method testManualCompleteOnlyTaskA.

/**
 *   +-----------------+
 *   | Case1            \
 *   +-------------------+-----------------+
 *   |                                     |
 *   |     +------------------------+      |
 *   |    / X                        \     |
 *   |   +    +-------+  +-------+    +    |
 *   |   |    |   A   |  |   B   |    |    |
 *   |   +    +-------+  +-------+    +    |
 *   |    \                          /     |
 *   |     +------------------------+      |
 *   |                                     |
 *   +-------------------------------------+
 */
public void testManualCompleteOnlyTaskA() {
    CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
    // given ///////////////////////////////////////////////////////////////
    // a case definition
    CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("complete", stateTransitionCollector).createActivity("X").listener("complete", stateTransitionCollector).behavior(new StageActivityBehavior()).createActivity("A").listener("complete", stateTransitionCollector).behavior(new TaskWaitState()).endActivity().createActivity("B").listener("complete", stateTransitionCollector).behavior(new TaskWaitState()).endActivity().endActivity().buildCaseDefinition();
    // an active case instance
    CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
    caseInstance.create();
    // a case execution associated with Stage X
    CmmnActivityExecution stageX = caseInstance.findCaseExecution("X");
    // a case execution associated with Task A
    CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
    // a case execution associated with Task B
    CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
    // when ////////////////////////////////////////////////////////////////
    // complete task A
    taskA.manualComplete();
    // then ////////////////////////////////////////////////////////////////
    List<String> expectedStateTransitions = new ArrayList<String>();
    // expected state transitions:
    // active --complete(A)--> completed
    expectedStateTransitions.add("active --complete(A)--> completed");
    assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
    // clear lists
    expectedStateTransitions.clear();
    stateTransitionCollector.stateTransitions.clear();
    // task A is completed
    assertTrue(taskA.isCompleted());
    // task B is still active
    assertTrue(taskB.isActive());
    // stage X is still active
    assertTrue(stageX.isActive());
    // stage X does not contain task A anymore
    assertNull(caseInstance.findCaseExecution("A"));
    // task B is still part of the case instance
    assertNotNull(caseInstance.findCaseExecution("B"));
    // stage X is still part of the case instance
    assertNotNull(caseInstance.findCaseExecution("X"));
    // case instance has only one child
    assertEquals(1, ((CaseExecutionImpl) caseInstance).getCaseExecutions().size());
    // stage X has two children
    assertEquals(1, ((CaseExecutionImpl) stageX).getCaseExecutions().size());
    // case instance is still active
    assertTrue(caseInstance.isActive());
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) CaseExecutionImpl(org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl) StageActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) ArrayList(java.util.ArrayList) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)

Example 3 with CaseExecutionImpl

use of org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl in project camunda-bpm-platform by camunda.

the class CaseExecutionCompletionTest method testDisableTaskAAndTaskB.

/**
 *   +-----------------+
 *   | Case1            \
 *   +-------------------+-----------------+
 *   |                                     |
 *   |     +------------------------+      |
 *   |    / X                        \     |
 *   |   +    +-------+  +-------+    +    |
 *   |   |    |   A   |  |   B   |    |    |
 *   |   +    +-------+  +-------+    +    |
 *   |    \                          /     |
 *   |     +------------------------+      |
 *   |                                     |
 *   +-------------------------------------+
 */
public void testDisableTaskAAndTaskB() {
    CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
    // given ///////////////////////////////////////////////////////////////
    // a case definition
    CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("complete", stateTransitionCollector).createActivity("X").listener("complete", stateTransitionCollector).behavior(new StageActivityBehavior()).createActivity("A").listener("complete", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).behavior(new TaskWaitState()).endActivity().createActivity("B").listener("complete", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).behavior(new TaskWaitState()).endActivity().endActivity().buildCaseDefinition();
    // an active case instance
    CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
    caseInstance.create();
    // a case execution associated with Stage X
    CmmnActivityExecution stageX = caseInstance.findCaseExecution("X");
    // a case execution associated with Task A
    CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
    // a case execution associated with Task B
    CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
    // when ////////////////////////////////////////////////////////////////
    // disable task A
    taskA.disable();
    // disable task B
    taskB.disable();
    // then ////////////////////////////////////////////////////////////////
    List<String> expectedStateTransitions = new ArrayList<String>();
    // expected state transitions:
    // active --complete(X)-->     completed
    // active --complete(Case1)--> completed
    expectedStateTransitions.add("active --complete(X)--> completed");
    expectedStateTransitions.add("active --complete(Case1)--> completed");
    assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
    // clear lists
    expectedStateTransitions.clear();
    stateTransitionCollector.stateTransitions.clear();
    // task A is disabled
    assertTrue(taskA.isDisabled());
    // task B is disabled
    assertTrue(taskB.isDisabled());
    // stage X is completed
    assertTrue(stageX.isCompleted());
    // stage X does not contain task A anymore
    assertNull(caseInstance.findCaseExecution("A"));
    // stage X does not contain task B anymore
    assertNull(caseInstance.findCaseExecution("B"));
    // stage X does not contain task X anymore
    assertNull(caseInstance.findCaseExecution("X"));
    // stage X has only one child
    assertEquals(0, ((CaseExecutionImpl) caseInstance).getCaseExecutions().size());
    // case instance is completed
    assertTrue(caseInstance.isCompleted());
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) CaseExecutionImpl(org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl) StageActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) ArrayList(java.util.ArrayList) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)

Example 4 with CaseExecutionImpl

use of org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl in project camunda-bpm-platform by camunda.

the class CaseExecutionCompletionTest method testDisableTaskShouldCompleteCaseInstance.

/**
 *   +-----------------+
 *   | Case1            \
 *   +-------------------+---+
 *   |                       |
 *   |     +-------+         |
 *   |     |   A   |         |
 *   |     +-------+         |
 *   |                       |
 *   +-----------------------+
 */
public void testDisableTaskShouldCompleteCaseInstance() {
    CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
    // given
    // a case definition
    CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("complete", stateTransitionCollector).createActivity("A").listener("disable", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).listener("complete", stateTransitionCollector).behavior(new TaskWaitState()).endActivity().buildCaseDefinition();
    // an active case instance
    CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
    caseInstance.create();
    // task A as a child of the case instance
    CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
    // task A is enabled
    assertTrue(taskA.isEnabled());
    // when
    // complete A
    taskA.disable();
    // then
    List<String> expectedStateTransitions = new ArrayList<String>();
    // expected state transition:
    // enabled --disable(A)-->      disabled
    // active  --complete(Case1)--> completed
    expectedStateTransitions.add("enabled --disable(A)--> disabled");
    expectedStateTransitions.add("active --complete(Case1)--> completed");
    assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
    // task A is disabled
    assertTrue(taskA.isDisabled());
    // case instance is completed
    assertTrue(caseInstance.isCompleted());
    assertNull(caseInstance.findCaseExecution("A"));
    assertTrue(((CaseExecutionImpl) caseInstance).getCaseExecutions().isEmpty());
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) CaseExecutionImpl(org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) ArrayList(java.util.ArrayList) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)

Example 5 with CaseExecutionImpl

use of org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl in project camunda-bpm-platform by camunda.

the class CaseExecutionCompletionTest method testTerminateTaskAAndTaskB.

/**
 *   +-----------------+
 *   | Case1            \
 *   +-------------------+-----------------+
 *   |                                     |
 *   |     +------------------------+      |
 *   |    / X                        \     |
 *   |   +    +-------+  +-------+    +    |
 *   |   |    |   A   |  |   B   |    |    |
 *   |   +    +-------+  +-------+    +    |
 *   |    \                          /     |
 *   |     +------------------------+      |
 *   |                                     |
 *   +-------------------------------------+
 */
public void testTerminateTaskAAndTaskB() {
    CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
    // given ///////////////////////////////////////////////////////////////
    // a case definition
    CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("complete", stateTransitionCollector).createActivity("X").listener("complete", stateTransitionCollector).behavior(new StageActivityBehavior()).createActivity("A").listener("complete", stateTransitionCollector).behavior(new TaskWaitState()).endActivity().createActivity("B").listener("complete", stateTransitionCollector).behavior(new TaskWaitState()).endActivity().endActivity().buildCaseDefinition();
    // an active case instance
    CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
    caseInstance.create();
    // a case execution associated with Stage X
    CmmnActivityExecution stageX = caseInstance.findCaseExecution("X");
    // a case execution associated with Task A
    CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
    // a case execution associated with Task B
    CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
    // when ////////////////////////////////////////////////////////////////
    // terminate task A
    taskA.terminate();
    // terminate task B
    taskB.terminate();
    // then ////////////////////////////////////////////////////////////////
    List<String> expectedStateTransitions = new ArrayList<String>();
    // expected state transitions:
    // active --complete(X)-->     completed
    // active --complete(Case1)--> completed
    expectedStateTransitions.add("active --complete(X)--> completed");
    expectedStateTransitions.add("active --complete(Case1)--> completed");
    assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
    // clear lists
    expectedStateTransitions.clear();
    stateTransitionCollector.stateTransitions.clear();
    // task A is terminated
    assertTrue(taskA.isTerminated());
    // task B is terminated
    assertTrue(taskB.isTerminated());
    // stage X is completed
    assertTrue(stageX.isCompleted());
    // stage X does not contain task A anymore
    assertNull(caseInstance.findCaseExecution("A"));
    // stage X does not contain task B anymore
    assertNull(caseInstance.findCaseExecution("B"));
    // stage X does not contain task X anymore
    assertNull(caseInstance.findCaseExecution("X"));
    // stage X has only one child
    assertEquals(0, ((CaseExecutionImpl) caseInstance).getCaseExecutions().size());
    // case instance is completed
    assertTrue(caseInstance.isCompleted());
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) CaseExecutionImpl(org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl) StageActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) ArrayList(java.util.ArrayList) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)

Aggregations

CaseExecutionImpl (org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl)19 CmmnCaseInstance (org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance)17 CaseDefinitionBuilder (org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)17 CmmnCaseDefinition (org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition)17 CmmnActivityExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution)13 ArrayList (java.util.ArrayList)12 StageActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior)11 Test (org.junit.Test)5 CmmnExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution)2 MilestoneActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.MilestoneActivityBehavior)1 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)1 CmmnOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration)1 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)1