use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance 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());
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance in project camunda-bpm-platform by camunda.
the class CaseInstanceCloseTest method testCloseStage.
/**
* +-----------------+
* | Case1 \
* +-------------------+-----------------+
* | |
* | +------------------------+ |
* | / X \ |
* | + +-------+ +-------+ + |
* | | | A | | B | | |
* | + +-------+ +-------+ + |
* | \ / |
* | +------------------------+ |
* | |
* +-------------------------------------+
*/
@Test
public void testCloseStage() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("close", stateTransitionCollector).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();
CmmnActivityExecution stageX = caseInstance.findCaseExecution("X");
try {
// when
stageX.close();
fail("It should not be possible to close a stage.");
} catch (CaseIllegalStateTransitionException e) {
}
// then
assertTrue(stateTransitionCollector.stateTransitions.isEmpty());
assertTrue(caseInstance.isActive());
assertNotNull(caseInstance.findCaseExecution("X"));
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance in project camunda-bpm-platform by camunda.
the class CaseInstanceCloseTest method testCloseSuspendedCaseInstance.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
@Test
public void testCloseSuspendedCaseInstance() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("close", stateTransitionCollector).createActivity("A").behavior(new TaskWaitState()).endActivity().buildCaseDefinition();
// an active case instance
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
caseInstance.suspend();
assertTrue(caseInstance.isSuspended());
// when
// close case
caseInstance.close();
// then
List<String> expectedStateTransitions = new ArrayList<String>();
// expected state transition:
// suspended --close(Case1)--> closed
expectedStateTransitions.add("suspended --close(Case1)--> closed");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
assertTrue(caseInstance.isClosed());
assertNull(caseInstance.findCaseExecution("A"));
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance in project camunda-bpm-platform by camunda.
the class CaseInstanceCloseTest method testCloseCompletedCaseInstance.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
@Test
public void testCloseCompletedCaseInstance() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("close", stateTransitionCollector).createActivity("A").behavior(new TaskWaitState()).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).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");
// disable task A -> completes case instance
taskA.disable();
assertTrue(caseInstance.isCompleted());
// when
// close case
caseInstance.close();
// then
List<String> expectedStateTransitions = new ArrayList<String>();
// expected state transition:
// completed --close(Case1)--> closed
expectedStateTransitions.add("completed --close(Case1)--> closed");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
assertTrue(caseInstance.isClosed());
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance in project camunda-bpm-platform by camunda.
the class CaseInstanceCloseTest method testCloseTerminatedCaseInstance.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
@Test
public void testCloseTerminatedCaseInstance() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("close", stateTransitionCollector).createActivity("A").behavior(new TaskWaitState()).endActivity().buildCaseDefinition();
// an active case instance
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
caseInstance.terminate();
assertTrue(caseInstance.isTerminated());
// when
// close case
caseInstance.close();
// then
List<String> expectedStateTransitions = new ArrayList<String>();
// expected state transition:
// terminated --close(Case1)--> closed
expectedStateTransitions.add("terminated --close(Case1)--> closed");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
assertTrue(caseInstance.isClosed());
}
Aggregations