use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance in project camunda-bpm-platform by camunda.
the class CaseExecutionCompletionTest method testAutoCompletionCaseInstanceWithoutChildren.
/**
* +-----------------+
* | Case1 \
* +-------------------+---+
* | |
* | |
* | |
* | |
* | |
* +-----------------------+
*/
public void testAutoCompletionCaseInstanceWithoutChildren() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("complete", stateTransitionCollector).buildCaseDefinition();
// when
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
// then
assertTrue(caseInstance.isCompleted());
List<String> expectedStateTransitions = new ArrayList<String>();
// expected state transition:
// active --complete(Case1)--> completed
expectedStateTransitions.add("active --complete(Case1)--> completed");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance 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.impl.cmmn.execution.CmmnCaseInstance 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));
}
}
use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance 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.impl.cmmn.execution.CmmnCaseInstance in project camunda-bpm-platform by camunda.
the class CaseExecutionOccurTest method testOccurMilestone.
@Test
public void testOccurMilestone() {
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").createActivity("A").behavior(new MilestoneActivityBehavior()).endActivity().buildCaseDefinition();
CmmnActivity activity = caseDefinition.findActivity("A");
// a pseudo sentry
CmmnSentryDeclaration sentryDeclaration = new CmmnSentryDeclaration("X");
caseDefinition.findActivity("Case1").addSentry(sentryDeclaration);
activity.addEntryCriteria(sentryDeclaration);
CmmnOnPartDeclaration onPartDeclaration = new CmmnOnPartDeclaration();
onPartDeclaration.setSource(new CmmnActivity("B", caseDefinition));
onPartDeclaration.setStandardEvent("complete");
sentryDeclaration.addOnPart(onPartDeclaration);
// an active case instance
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
// task A as a child of the case instance
CmmnActivityExecution milestoneA = caseInstance.findCaseExecution("A");
// when
// completing
milestoneA.occur();
// then
// task A is completed ...
assertTrue(milestoneA.isCompleted());
// ... and the case instance is also completed
assertTrue(caseInstance.isCompleted());
// task A is not part of the case instance anymore
assertNull(caseInstance.findCaseExecution("A"));
// the case instance has no children
assertTrue(((CaseExecutionImpl) caseInstance).getCaseExecutions().isEmpty());
}
Aggregations