Search in sources :

Example 26 with CmmnCaseDefinition

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.

the class CaseTaskPlanItemHandlerTest method testWithParent.

@Test
public void testWithParent() {
    // given:
    // a new activity as parent
    CmmnCaseDefinition parent = new CmmnCaseDefinition("aParentActivity");
    context.setParent(parent);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    assertEquals(parent, activity.getParent());
    assertTrue(parent.getActivities().contains(activity));
}
Also used : CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 27 with CmmnCaseDefinition

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.

the class DecisionTaskPlanItemHandlerTest method testWithParent.

@Test
public void testWithParent() {
    // given
    CmmnCaseDefinition parent = new CmmnCaseDefinition("aParentActivity");
    context.setParent(parent);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    assertEquals(parent, activity.getParent());
    assertTrue(parent.getActivities().contains(activity));
}
Also used : CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 28 with CmmnCaseDefinition

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.

the class CmmnTransformerTest method testCasePlanModel.

/**
 *   +-----------------+                    +-----------------+
 *   | Case1            \                   | aCaseDefinition |
 *   +-------------------+---+              +-----------------+
 *   |                       |                      |
 *   |                       |   ==>        +-----------------+
 *   |                       |              |  aCasePlanModel |
 *   |                       |              +-----------------+
 *   |                       |
 *   +-----------------------+
 */
@Test
public void testCasePlanModel() {
    // given
    // when
    List<CaseDefinitionEntity> caseDefinitions = transform();
    // then
    assertEquals(1, caseDefinitions.size());
    CmmnCaseDefinition caseModel = caseDefinitions.get(0);
    List<CmmnActivity> activities = caseModel.getActivities();
    assertEquals(1, activities.size());
    CmmnActivity casePlanModelActivity = activities.get(0);
    assertEquals(casePlanModel.getId(), casePlanModelActivity.getId());
    assertTrue(casePlanModelActivity.getActivities().isEmpty());
}
Also used : CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 29 with CmmnCaseDefinition

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.

the class CaseExecutionReactivateTest method testReactivateCaseInstance.

@Test
public void testReactivateCaseInstance() {
    // given ///////////////////////////////////////////////////////////////
    // a case definition
    CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").createActivity("X").behavior(new StageActivityBehavior()).createActivity("A").behavior(new TaskWaitState()).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).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");
    // a case execution associated with Task B
    CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
    caseInstance.suspend();
    // when
    caseInstance.reactivate();
    // then
    assertTrue(caseInstance.isActive());
    assertTrue(stageX.isActive());
    assertTrue(taskA.isEnabled());
    assertTrue(taskB.isEnabled());
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) StageActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder) Test(org.junit.Test)

Example 30 with CmmnCaseDefinition

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.

the class CaseExecutionTerminationTest method testTerminateTask.

@Test
public void testTerminateTask() {
    // 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");
    // a case execution associated with Task B
    CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
    // when
    taskA.terminate();
    // then
    assertTrue(caseInstance.isActive());
    assertTrue(stageX.isActive());
    assertTrue(taskA.isTerminated());
    assertTrue(taskB.isEnabled());
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) StageActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder) Test(org.junit.Test)

Aggregations

CmmnCaseDefinition (org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition)64 CmmnCaseInstance (org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance)48 CaseDefinitionBuilder (org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)46 CmmnActivityExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution)38 Test (org.junit.Test)32 StageActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior)22 ArrayList (java.util.ArrayList)18 CaseExecutionImpl (org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl)17 CaseIllegalStateTransitionException (org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException)14 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)14 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)2 CmmnExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution)2 CmmnActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior)1 MilestoneActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.MilestoneActivityBehavior)1 CmmnOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration)1 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 Case (org.camunda.bpm.model.cmmn.instance.Case)1 Definitions (org.camunda.bpm.model.cmmn.instance.Definitions)1 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)1