use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testManualCompleteEnabledTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testManualCompleteEnabledTask() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("complete", stateTransitionCollector).createActivity("A").listener("complete", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).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());
try {
// when
// completing task A
taskA.manualComplete();
fail("It should not be possible to complete an enabled task.");
} catch (CaseIllegalStateTransitionException e) {
// then
// task A is still enabled
assertTrue(taskA.isEnabled());
}
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testManualCompleteTaskAAndTaskB.
/**
* +-----------------+
* | Case1 \
* +-------------------+-----------------+
* | |
* | +------------------------+ |
* | / X \ |
* | + +-------+ +-------+ + |
* | | | A | | B | | |
* | + +-------+ +-------+ + |
* | \ / |
* | +------------------------+ |
* | |
* +-------------------------------------+
*/
public void testManualCompleteTaskAAndTaskB() {
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();
// complete task B
taskB.manualComplete();
// then ////////////////////////////////////////////////////////////////
List<String> expectedStateTransitions = new ArrayList<String>();
// expected state transitions:
// active --complete(A)--> completed
// active --complete(B)--> completed
// active --complete(X)--> completed
// active --complete(Case1)--> completed
expectedStateTransitions.add("active --complete(A)--> completed");
expectedStateTransitions.add("active --complete(B)--> 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 completed
assertTrue(taskA.isCompleted());
// task B is completed
assertTrue(taskB.isCompleted());
// 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());
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testCompleteAlreadyCompletedCaseInstance.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testCompleteAlreadyCompletedCaseInstance() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("complete", stateTransitionCollector).createActivity("A").listener("complete", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).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());
// case instance is already completed
caseInstance.manualComplete();
try {
// when
caseInstance.complete();
fail("It should not be possible to complete an already completed case instance.");
} catch (CaseIllegalStateTransitionException e) {
// then
// the case instance is still completed
assertTrue(caseInstance.isCompleted());
}
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testManualCompleteActiveCaseInstanceWithActiveTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testManualCompleteActiveCaseInstanceWithActiveTask() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("complete", stateTransitionCollector).createActivity("A").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");
try {
// when
caseInstance.manualComplete();
fail("It should not be possible to complete a case instance containing an active task.");
} catch (CaseIllegalStateTransitionException e) {
// then
// the case instance is still active
assertTrue(caseInstance.isActive());
assertFalse(caseInstance.isCompleted());
}
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testCompleteActiveCaseInstanceWithEnabledTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testCompleteActiveCaseInstanceWithEnabledTask() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("complete", stateTransitionCollector).createActivity("A").listener("complete", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).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());
try {
// when
// complete caseInstance
caseInstance.complete();
} catch (Exception e) {
// then
// case instance is still active
assertTrue(caseInstance.isActive());
assertNotNull(caseInstance.findCaseExecution("A"));
}
}
Aggregations