use of org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder 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.model.CaseDefinitionBuilder 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.model.CaseDefinitionBuilder 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());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testManualCompleteActiveCaseInstanceWithEnabledTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testManualCompleteActiveCaseInstanceWithEnabledTask() {
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());
// when
// complete caseInstance (manualCompletion == true)
caseInstance.manualComplete();
// then
List<String> expectedStateTransitions = new ArrayList<String>();
// expected state transition:
// active --complete(Case1)--> completed
expectedStateTransitions.add("active --complete(Case1)--> completed");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// the case instance
assertTrue(caseInstance.isCompleted());
// task A is not a child of the case instance anymore
assertNull(caseInstance.findCaseExecution("A"));
}
use of org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testAutoCompletionStageWithoutChildren.
/**
* +-----------------+
* | Case1 \
* +-------------------+-----------------+
* | |
* | +------------------------+ |
* | / X \ |
* | + + |
* | | | |
* | + + |
* | \ / |
* | +------------------------+ |
* | |
* +-------------------------------------+
*/
public void testAutoCompletionStageWithoutChildren() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("complete", stateTransitionCollector).createActivity("X").listener("complete", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).behavior(new StageActivityBehavior()).endActivity().buildCaseDefinition();
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
CmmnActivityExecution stageX = caseInstance.findCaseExecution("X");
// when
stageX.manualStart();
// then
assertTrue(caseInstance.isCompleted());
assertTrue(stageX.isCompleted());
List<String> expectedStateTransitions = new ArrayList<String>();
// expected state transition:
// active --complete(X)--> completed
// active --complete(Case1)--> completed
expectedStateTransitions.add("active --complete(X)--> completed");
expectedStateTransitions.add("active --complete(Case1)--> completed");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
}
Aggregations