use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testCompleteEnabledTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testCompleteEnabledTask() {
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.complete();
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.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.
the class CaseInstanceCloseTest method testCloseActiveCaseInstance.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
@Test
public void testCloseActiveCaseInstance() {
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();
assertTrue(caseInstance.isActive());
try {
// when
caseInstance.close();
} catch (CaseIllegalStateTransitionException e) {
}
// then
assertTrue(stateTransitionCollector.stateTransitions.isEmpty());
assertTrue(caseInstance.isActive());
assertNotNull(caseInstance.findCaseExecution("A"));
}
use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.
the class CaseInstanceCloseTest method testCloseTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
@Test
public void testCloseTask() {
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();
CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
try {
// when
taskA.close();
fail("It should not be possible to close a task.");
} catch (CaseIllegalStateTransitionException e) {
}
// then
assertTrue(stateTransitionCollector.stateTransitions.isEmpty());
assertTrue(caseInstance.isActive());
assertNotNull(caseInstance.findCaseExecution("A"));
}
use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException 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.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testCompleteActiveCaseInstanceWithActiveTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testCompleteActiveCaseInstanceWithActiveTask() {
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");
// task A is active
assertTrue(taskA.isActive());
try {
// when
caseInstance.complete();
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());
}
}
Aggregations