use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testCompleteAlreadyCompletedTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testCompleteAlreadyCompletedTask() {
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");
taskA.complete();
// task A is completed
assertTrue(taskA.isCompleted());
try {
// when
// complete A
taskA.complete();
fail("It should not be possible to complete an already completed task.");
} catch (CaseIllegalStateTransitionException e) {
// then
// task A is still completed
assertTrue(taskA.isCompleted());
}
}
use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testCompleteTerminatedTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testCompleteTerminatedTask() {
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");
taskA.terminate();
// task A is completed
assertTrue(taskA.isTerminated());
try {
// when
// complete A
taskA.complete();
fail("It should not be possible to complete an already completed task.");
} catch (CaseIllegalStateTransitionException e) {
// then
// task A is still completed
assertTrue(taskA.isTerminated());
}
}
use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testManualCompleteAlreadyCompletedTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testManualCompleteAlreadyCompletedTask() {
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");
taskA.complete();
// task A is completed
assertTrue(taskA.isCompleted());
try {
// when
// complete A
taskA.manualComplete();
fail("It should not be possible to complete an already completed task.");
} catch (CaseIllegalStateTransitionException e) {
// then
// task A is still completed
assertTrue(taskA.isCompleted());
}
}
use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testManualCompleteTerminatedTask.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testManualCompleteTerminatedTask() {
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");
taskA.terminate();
// task A is completed
assertTrue(taskA.isTerminated());
try {
// when
// complete A
taskA.manualComplete();
fail("It should not be possible to complete an already completed task.");
} catch (CaseIllegalStateTransitionException e) {
// then
// task A is still completed
assertTrue(taskA.isTerminated());
}
}
use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testManualCompleteAlreadyCompletedCaseInstance.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | +-------+ |
* | | A | |
* | +-------+ |
* | |
* +-----------------------+
*/
public void testManualCompleteAlreadyCompletedCaseInstance() {
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.manualComplete();
fail("It should not be possible to complete an already completed case instance.");
} catch (CaseIllegalStateTransitionException e) {
// then
assertThat("the case instance is still completed", caseInstance.isCompleted(), is(true));
}
}
Aggregations