use of org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior in project camunda-bpm-platform by camunda.
the class CaseInstanceTest method testCaseInstanceWithOneState.
/**
* +-----------------+
* | Case1 \
* +-------------------+-----------------+
* | |
* | +------------------------+ |
* | / X \ |
* | + +-------+ +-------+ + |
* | | | A | | B | | |
* | + +-------+ +-------+ + |
* | \ / |
* | +------------------------+ |
* | |
* +-------------------------------------+
*/
@Test
public void testCaseInstanceWithOneState() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("create", stateTransitionCollector).createActivity("X").listener("create", stateTransitionCollector).listener("enable", stateTransitionCollector).listener("manualStart", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).behavior(new StageActivityBehavior()).createActivity("A").listener("create", stateTransitionCollector).listener("enable", stateTransitionCollector).listener("manualStart", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).behavior(new TaskWaitState()).endActivity().createActivity("B").listener("create", stateTransitionCollector).listener("enable", stateTransitionCollector).listener("manualStart", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).behavior(new TaskWaitState()).endActivity().endActivity().buildCaseDefinition();
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
// expected state transitions after the creation of a case instance:
// () --create(Case1)--> active
// () --create(X)--> available
// available --enable(X)--> enabled
List<String> expectedStateTransitions = initAndAssertExpectedTransitions(stateTransitionCollector);
// clear lists
emptyCollector(stateTransitionCollector, expectedStateTransitions);
CaseExecutionImpl planItemX = assertCaseXState(caseInstance);
List<CaseExecutionImpl> childPlanItems;
// manual start of x
planItemX.manualStart();
// X should be active
assertTrue(planItemX.isActive());
// expected state transitions after a manual start of X:
// enabled --manualStart(X)--> active
// () --create(A)--> available
// available --enable(A)--> enabled
// () --create(B)--> available
// available --enable(B)--> enabled
expectedStateTransitions.add("enabled --manualStart(X)--> active");
expectedStateTransitions.add("() --create(A)--> available");
expectedStateTransitions.add("available --enable(A)--> enabled");
expectedStateTransitions.add("() --create(B)--> available");
expectedStateTransitions.add("available --enable(B)--> enabled");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// clear lists
emptyCollector(stateTransitionCollector, expectedStateTransitions);
// X should have two chil plan items
childPlanItems = planItemX.getCaseExecutions();
assertEquals(2, childPlanItems.size());
for (CmmnExecution childPlanItem : childPlanItems) {
// both children should be enabled
assertTrue(childPlanItem.isEnabled());
// manual start of a child
childPlanItem.manualStart();
// the child should be active
assertTrue(childPlanItem.isActive());
// X should be the parent of both children
assertEquals(planItemX, childPlanItem.getParent());
}
// expected state transitions after the manual starts of A and B:
// enabled --manualStart(A)--> active
// enabled --manualStart(B)--> active
expectedStateTransitions.add("enabled --manualStart(A)--> active");
expectedStateTransitions.add("enabled --manualStart(B)--> active");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
}
use of org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior in project camunda-bpm-platform by camunda.
the class CaseExecutionResumeTest method testResumeStage.
@Test
public void testResumeStage() {
// given ///////////////////////////////////////////////////////////////
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").createActivity("X").behavior(new StageActivityBehavior()).createActivity("A").behavior(new TaskWaitState()).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).endActivity().createActivity("B").behavior(new TaskWaitState()).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).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");
stageX.suspend();
// a case execution associated with Task A
CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
assertTrue(taskA.isSuspended());
// a case execution associated with Task B
CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
assertTrue(taskB.isSuspended());
// when
stageX.resume();
// then
assertTrue(caseInstance.isActive());
assertTrue(stageX.isActive());
assertTrue(taskA.isEnabled());
assertTrue(taskB.isEnabled());
}
use of org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior in project camunda-bpm-platform by camunda.
the class CaseExecutionSuspensionTest method testSuspendTask.
@Test
public void testSuspendTask() {
// given ///////////////////////////////////////////////////////////////
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").createActivity("X").behavior(new StageActivityBehavior()).createActivity("A").behavior(new TaskWaitState()).endActivity().createActivity("B").behavior(new TaskWaitState()).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).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
taskA.suspend();
// then
assertTrue(caseInstance.isActive());
assertTrue(stageX.isActive());
assertTrue(taskA.isSuspended());
assertTrue(taskB.isEnabled());
}
use of org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior in project camunda-bpm-platform by camunda.
the class CaseExecutionSuspensionTest method testSuspendStage.
@Test
public void testSuspendStage() {
// given ///////////////////////////////////////////////////////////////
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").createActivity("X").behavior(new StageActivityBehavior()).createActivity("A").behavior(new TaskWaitState()).endActivity().createActivity("B").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
stageX.suspend();
// then
assertTrue(caseInstance.isActive());
assertTrue(stageX.isSuspended());
assertTrue(taskA.isSuspended());
assertTrue(taskB.isSuspended());
}
use of org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior in project camunda-bpm-platform by camunda.
the class CaseExecutionSuspensionTest method testSuspendCaseInstance.
@Test
public void testSuspendCaseInstance() {
// given ///////////////////////////////////////////////////////////////
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").createActivity("X").behavior(new StageActivityBehavior()).createActivity("A").behavior(new TaskWaitState()).endActivity().createActivity("B").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
caseInstance.suspend();
// then
assertTrue(caseInstance.isSuspended());
assertTrue(stageX.isSuspended());
assertTrue(taskA.isSuspended());
assertTrue(taskB.isSuspended());
}
Aggregations