use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition 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.model.CmmnCaseDefinition 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());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.
the class CaseExecutionResumeTest method testResumeTask.
@Test
public void testResumeTask() {
// 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()).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).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");
taskA.suspend();
// a case execution associated with Task B
CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
// when
taskA.resume();
// then
assertTrue(caseInstance.isActive());
assertTrue(stageX.isActive());
assertTrue(taskA.isActive());
assertTrue(taskB.isEnabled());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition 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.impl.cmmn.model.CmmnCaseDefinition 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"));
}
Aggregations