use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-bpm-platform by camunda.
the class CmmnTransformerTest method testActivityTreeWithOneHumanTask.
/**
* +-----------------+ +-----------------+
* | Case1 \ | aCaseDefinition |
* +-------------------+---+ +-----------------+
* | | |
* | +-------+ | ==> +-----------------+
* | | A | | | aCasePlanModel |
* | +-------+ | +-----------------+
* | | |
* +-----------------------+ +-----------------+
* | A |
* +-----------------+
*/
@Test
public void testActivityTreeWithOneHumanTask() {
// given
HumanTask humanTask = createElement(casePlanModel, "A", HumanTask.class);
PlanItem planItem = createElement(casePlanModel, "PI_A", PlanItem.class);
planItem.setDefinition(humanTask);
// when
List<CaseDefinitionEntity> caseDefinitions = transform();
// then
assertEquals(1, caseDefinitions.size());
CaseDefinitionEntity caseDefinition = caseDefinitions.get(0);
List<CmmnActivity> activities = caseDefinition.getActivities();
CmmnActivity casePlanModelActivity = activities.get(0);
List<CmmnActivity> planItemActivities = casePlanModelActivity.getActivities();
assertEquals(1, planItemActivities.size());
CmmnActivity child = planItemActivities.get(0);
assertEquals(planItem.getId(), child.getId());
assertTrue(child.getActivities().isEmpty());
}
use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-bpm-platform by camunda.
the class ItemHandler method getName.
protected String getName(CmmnElement element) {
String name = null;
if (isPlanItem(element)) {
PlanItem planItem = (PlanItem) element;
name = planItem.getName();
}
if (name == null || name.isEmpty()) {
PlanItemDefinition definition = getDefinition(element);
if (definition != null) {
name = definition.getName();
}
}
return name;
}
use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-bpm-platform by camunda.
the class CmmnTransformerTest method testNestedStages.
/**
* +-----------------+ +-----------------+
* | Case1 \ | aCaseDefinition |
* +-------------------+-------------------+ +-----------------+
* | | |
* | +-------+ | +-----------------+
* | | A1 | | +---------------| aCasePlanModel |---------------+
* | +-------+ | | +-----------------+ |
* | | | | |
* | +------------------------+ | +-----------------+ +-----------------+ +-----------------+
* | / X1 \ | | A1 | | X1 | | Y |-----------+
* | + +-------+ +-------+ + | +-----------------+ +-----------------+ +-----------------+ |
* | | | A2 | | B | | | / \ / \
* | + +-------+ +-------+ + | / \ / \
* | \ / | +---------------+ +---------------+ +-----------------+ +-----------------+
* | +------------------------+ | | A2 | | B | | C | | X2 |
* | | +---------------+ +---------------+ +-----------------+ +-----------------+
* | +-----------------------------+ | ==> / \
* | / Y \ | +---------------+ +---------------+
* | + +-------+ + | | A1 | | B |
* | | | C | | | +---------------+ +---------------+
* | | +-------+ | |
* | | | |
* | | +------------------------+ | |
* | | / X2 \ | |
* | | + +-------+ +-------+ + | |
* | | | | A1 | | B | | | |
* | | + +-------+ +-------+ + | |
* | | \ / | |
* | + +------------------------+ + |
* | \ / |
* | +-----------------------------+ |
* | |
* +---------------------------------------+
*/
@Test
public void testNestedStages() {
// given
Stage stageX = createElement(casePlanModel, "X", Stage.class);
Stage stageY = createElement(casePlanModel, "Y", Stage.class);
HumanTask humanTaskA = createElement(casePlanModel, "A", HumanTask.class);
HumanTask humanTaskB = createElement(casePlanModel, "B", HumanTask.class);
HumanTask humanTaskC = createElement(casePlanModel, "C", HumanTask.class);
PlanItem planItemA1 = createElement(casePlanModel, "PI_A1", PlanItem.class);
planItemA1.setDefinition(humanTaskA);
PlanItem planItemX1 = createElement(casePlanModel, "PI_X1", PlanItem.class);
planItemX1.setDefinition(stageX);
PlanItem planItemA2 = createElement(stageX, "PI_A2", PlanItem.class);
planItemA2.setDefinition(humanTaskA);
PlanItem planItemB = createElement(stageX, "PI_B", PlanItem.class);
planItemB.setDefinition(humanTaskB);
PlanItem planItemY = createElement(casePlanModel, "PI_Y", PlanItem.class);
planItemY.setDefinition(stageY);
PlanItem planItemC = createElement(stageY, "PI_C", PlanItem.class);
planItemC.setDefinition(humanTaskC);
PlanItem planItemX2 = createElement(stageY, "PI_X2", PlanItem.class);
planItemX2.setDefinition(stageX);
// when
List<CaseDefinitionEntity> caseDefinitions = transform();
// then
assertEquals(1, caseDefinitions.size());
CaseDefinitionEntity caseDefinition = caseDefinitions.get(0);
List<CmmnActivity> activities = caseDefinition.getActivities();
CmmnActivity casePlanModelActivity = activities.get(0);
List<CmmnActivity> children = casePlanModelActivity.getActivities();
assertEquals(3, children.size());
CmmnActivity childPlanItem = children.get(0);
assertEquals(planItemA1.getId(), childPlanItem.getId());
assertTrue(childPlanItem.getActivities().isEmpty());
childPlanItem = children.get(1);
assertEquals(planItemX1.getId(), childPlanItem.getId());
List<CmmnActivity> childrenOfX1 = childPlanItem.getActivities();
assertFalse(childrenOfX1.isEmpty());
assertEquals(2, childrenOfX1.size());
childPlanItem = childrenOfX1.get(0);
assertEquals(planItemA2.getId(), childPlanItem.getId());
assertTrue(childPlanItem.getActivities().isEmpty());
childPlanItem = childrenOfX1.get(1);
assertEquals(planItemB.getId(), childPlanItem.getId());
assertTrue(childPlanItem.getActivities().isEmpty());
childPlanItem = children.get(2);
assertEquals(planItemY.getId(), childPlanItem.getId());
List<CmmnActivity> childrenOfY = childPlanItem.getActivities();
assertFalse(childrenOfY.isEmpty());
assertEquals(2, childrenOfY.size());
childPlanItem = childrenOfY.get(0);
assertEquals(planItemC.getId(), childPlanItem.getId());
assertTrue(childPlanItem.getActivities().isEmpty());
childPlanItem = childrenOfY.get(1);
assertEquals(planItemX2.getId(), childPlanItem.getId());
List<CmmnActivity> childrenOfX2 = childPlanItem.getActivities();
assertFalse(childrenOfX2.isEmpty());
assertEquals(2, childrenOfX2.size());
childPlanItem = childrenOfX2.get(0);
assertEquals(planItemA2.getId(), childPlanItem.getId());
assertTrue(childPlanItem.getActivities().isEmpty());
childPlanItem = childrenOfX2.get(1);
assertEquals(planItemB.getId(), childPlanItem.getId());
assertTrue(childPlanItem.getActivities().isEmpty());
}
use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-cmmn-model by camunda.
the class CreateModelTest method createCaseWithOneStageAndNestedHumanTask.
@Test
public void createCaseWithOneStageAndNestedHumanTask() {
// create process
Case caseInstance = createElement(definitions, "case-with-one-human-task", Case.class);
// create case plan model
CasePlanModel casePlanModel = createElement(caseInstance, "casePlanModel_1", CasePlanModel.class);
// create a stage
Stage stage = createElement(casePlanModel, "Stage_1", Stage.class);
// create elements
HumanTask humanTask = createElement(stage, "HumanTask_1", HumanTask.class);
// create a plan item
PlanItem planItem = createElement(stage, "PlanItem_1", PlanItem.class);
// set definition to human task
planItem.setDefinition(humanTask);
}
use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-cmmn-model by camunda.
the class Cmmn10Test method shouldGetPlanItemExitCriterion.
@Test
public void shouldGetPlanItemExitCriterion() {
CmmnModelInstance modelInstance = getCmmnModelInstance();
PlanItem planItem = modelInstance.getModelElementsByType(PlanItem.class).iterator().next();
Collection<Sentry> exitCriterias = planItem.getExitCriterias();
assertThat(exitCriterias).hasSize(1);
Collection<Sentry> exitCriteria = planItem.getExitCriteria();
assertThat(exitCriteria).hasSize(1);
Collection<ExitCriterion> exitCriterions = planItem.getExitCriterions();
assertThat(exitCriterions).isEmpty();
}
Aggregations