Search in sources :

Example 1 with CaseIllegalStateTransitionException

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());
    }
}
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 2 with CaseIllegalStateTransitionException

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());
    }
}
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 3 with CaseIllegalStateTransitionException

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());
    }
}
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 4 with CaseIllegalStateTransitionException

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());
    }
}
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 5 with CaseIllegalStateTransitionException

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));
    }
}
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