use of org.camunda.bpm.model.cmmn.instance.EntryCriterion in project camunda-bpm-platform by camunda.
the class StagePlanItemHandlerTest method testEntryCriteriaAndExitCriteria.
@Test
public void testEntryCriteriaAndExitCriteria() {
// given
// create sentry containing ifPart
Sentry sentry = createElement(casePlanModel, "Sentry_1", Sentry.class);
IfPart ifPart = createElement(sentry, "abc", IfPart.class);
ConditionExpression conditionExpression = createElement(ifPart, "def", ConditionExpression.class);
Body body = createElement(conditionExpression, null, Body.class);
body.setTextContent("${test}");
// set entry-/exitCriteria
EntryCriterion criterion1 = createElement(planItem, EntryCriterion.class);
criterion1.setSentry(sentry);
ExitCriterion criterion2 = createElement(planItem, ExitCriterion.class);
criterion2.setSentry(sentry);
// transform casePlanModel as parent
CmmnActivity parent = new CasePlanModelHandler().handleElement(casePlanModel, context);
context.setParent(parent);
// transform Sentry
CmmnSentryDeclaration sentryDeclaration = new SentryHandler().handleElement(sentry, context);
// when
CmmnActivity newActivity = handler.handleElement(planItem, context);
// then
assertFalse(newActivity.getExitCriteria().isEmpty());
assertEquals(1, newActivity.getExitCriteria().size());
assertEquals(sentryDeclaration, newActivity.getExitCriteria().get(0));
assertFalse(newActivity.getEntryCriteria().isEmpty());
assertEquals(1, newActivity.getEntryCriteria().size());
assertEquals(sentryDeclaration, newActivity.getEntryCriteria().get(0));
}
use of org.camunda.bpm.model.cmmn.instance.EntryCriterion in project camunda-bpm-platform by camunda.
the class TaskPlanItemHandlerTest method testMultipleEntryCriteria.
@Test
public void testMultipleEntryCriteria() {
// given
// create first sentry containing ifPart
Sentry sentry1 = createElement(casePlanModel, "Sentry_1", Sentry.class);
IfPart ifPart1 = createElement(sentry1, "abc", IfPart.class);
ConditionExpression conditionExpression1 = createElement(ifPart1, "def", ConditionExpression.class);
conditionExpression1.setText("${test}");
// set first entryCriteria
EntryCriterion criterion1 = createElement(planItem, EntryCriterion.class);
criterion1.setSentry(sentry1);
// create first sentry containing ifPart
Sentry sentry2 = createElement(casePlanModel, "Sentry_2", Sentry.class);
IfPart ifPart2 = createElement(sentry2, "ghi", IfPart.class);
ConditionExpression conditionExpression2 = createElement(ifPart2, "jkl", ConditionExpression.class);
conditionExpression2.setText("${test}");
// set second entryCriteria
EntryCriterion criterion2 = createElement(planItem, EntryCriterion.class);
criterion2.setSentry(sentry2);
// transform casePlanModel as parent
CmmnActivity parent = new CasePlanModelHandler().handleElement(casePlanModel, context);
context.setParent(parent);
// transform Sentry
CmmnSentryDeclaration firstSentryDeclaration = new SentryHandler().handleElement(sentry1, context);
CmmnSentryDeclaration secondSentryDeclaration = new SentryHandler().handleElement(sentry2, context);
// when
CmmnActivity newActivity = handler.handleElement(planItem, context);
// then
assertTrue(newActivity.getExitCriteria().isEmpty());
assertFalse(newActivity.getEntryCriteria().isEmpty());
assertEquals(2, newActivity.getEntryCriteria().size());
assertTrue(newActivity.getEntryCriteria().contains(firstSentryDeclaration));
assertTrue(newActivity.getEntryCriteria().contains(secondSentryDeclaration));
}
use of org.camunda.bpm.model.cmmn.instance.EntryCriterion in project camunda-cmmn-model by camunda.
the class EntryCriterionImpl method registerType.
public static void registerType(ModelBuilder modelBuilder) {
ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(EntryCriterion.class, CMMN_ELEMENT_ENTRY_CRITERION).extendsType(Criterion.class).namespaceUri(CMMN11_NS).instanceProvider(new ModelTypeInstanceProvider<EntryCriterion>() {
public EntryCriterion newInstance(ModelTypeInstanceContext instanceContext) {
return new EntryCriterionImpl(instanceContext);
}
});
typeBuilder.build();
}
use of org.camunda.bpm.model.cmmn.instance.EntryCriterion in project camunda-cmmn-model by camunda.
the class Cmmn10Test method shouldGetPlanItemEntryCriterion.
@Test
public void shouldGetPlanItemEntryCriterion() {
CmmnModelInstance modelInstance = getCmmnModelInstance();
PlanItem planItem = modelInstance.getModelElementsByType(PlanItem.class).iterator().next();
Collection<Sentry> entryCriterias = planItem.getEntryCriterias();
assertThat(entryCriterias).hasSize(1);
Collection<Sentry> entryCriteria = planItem.getEntryCriteria();
assertThat(entryCriteria).hasSize(1);
Collection<EntryCriterion> entryCriterions = planItem.getEntryCriterions();
assertThat(entryCriterions).isEmpty();
}
Aggregations