Search in sources :

Example 11 with CaseIllegalStateTransitionException

use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.

the class CaseExecutionCompletionTest method testManualCompleteEnabledTask.

/**
 *   +-----------------+
 *   | Case1            \
 *   +-------------------+---+
 *   |                       |
 *   |     +-------+         |
 *   |     |   A   |         |
 *   |     +-------+         |
 *   |                       |
 *   +-----------------------+
 */
public void testManualCompleteEnabledTask() {
    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.manualComplete();
        fail("It should not be possible to complete an enabled task.");
    } catch (CaseIllegalStateTransitionException e) {
        // then
        // task A is still enabled
        assertTrue(taskA.isEnabled());
    }
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CaseIllegalStateTransitionException(org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)

Example 12 with CaseIllegalStateTransitionException

use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.

the class CaseExecutionCompletionTest method testCompleteAlreadyCompletedCaseInstance.

/**
 *   +-----------------+
 *   | Case1            \
 *   +-------------------+---+
 *   |                       |
 *   |     +-------+         |
 *   |     |   A   |         |
 *   |     +-------+         |
 *   |                       |
 *   +-----------------------+
 */
public void testCompleteAlreadyCompletedCaseInstance() {
    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.complete();
        fail("It should not be possible to complete an already completed case instance.");
    } catch (CaseIllegalStateTransitionException e) {
        // then
        // the case instance is still completed
        assertTrue(caseInstance.isCompleted());
    }
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CaseIllegalStateTransitionException(org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)

Example 13 with CaseIllegalStateTransitionException

use of org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException in project camunda-bpm-platform by camunda.

the class CaseExecutionCompletionTest method testManualCompleteActiveCaseInstanceWithActiveTask.

/**
 *   +-----------------+
 *   | Case1            \
 *   +-------------------+---+
 *   |                       |
 *   |     +-------+         |
 *   |     |   A   |         |
 *   |     +-------+         |
 *   |                       |
 *   +-----------------------+
 */
public void testManualCompleteActiveCaseInstanceWithActiveTask() {
    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");
    try {
        // when
        caseInstance.manualComplete();
        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());
    }
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CaseIllegalStateTransitionException(org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)

Aggregations

CaseIllegalStateTransitionException (org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException)13 CmmnCaseInstance (org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance)13 CaseDefinitionBuilder (org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)13 CmmnCaseDefinition (org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition)13 CmmnActivityExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution)12 Test (org.junit.Test)3 StageActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior)1