use of org.camunda.bpm.model.cmmn.instance.ConditionExpression in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method testSentryWithIfPartWithMultipleCondition.
@Test
public void testSentryWithIfPartWithMultipleCondition() {
// given
IfPart ifPart = createElement(sentry, "abc", IfPart.class);
ConditionExpression firstConditionExpression = createElement(ifPart, "con_1", ConditionExpression.class);
Body firstBody = createElement(firstConditionExpression, null, Body.class);
String firstExpression = "${firstExpression}";
firstBody.setTextContent(firstExpression);
ConditionExpression secondConditionExpression = createElement(ifPart, "con_2", ConditionExpression.class);
Body secondBody = createElement(secondConditionExpression, null, Body.class);
String secondExpression = "${secondExpression}";
secondBody.setTextContent(secondExpression);
// when
CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
// then
assertNotNull(sentryDeclaration);
CmmnIfPartDeclaration ifPartDeclaration = sentryDeclaration.getIfPart();
assertNotNull(ifPartDeclaration);
Expression condition = ifPartDeclaration.getCondition();
assertNotNull(condition);
assertEquals(firstExpression, condition.getExpressionText());
// the second condition will be ignored!
assertTrue(sentryDeclaration.getOnParts().isEmpty());
}
use of org.camunda.bpm.model.cmmn.instance.ConditionExpression in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testRepetitionRule.
@Test
public void testRepetitionRule() {
// given
ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
expression.setText("${true}");
Cmmn.validateModel(modelInstance);
// when
CmmnActivity newActivity = handler.handleElement(planItem, context);
// then
Object rule = newActivity.getProperty(PROPERTY_REPETITION_RULE);
assertNotNull(rule);
assertTrue(rule instanceof CaseControlRule);
}
use of org.camunda.bpm.model.cmmn.instance.ConditionExpression in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest 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 entryCriteria
EntryCriterion criterion1 = createElement(planItem, EntryCriterion.class);
criterion1.setSentry(sentry);
// set exitCriterion
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.ConditionExpression in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testRequiredRuleByDefaultPlanItemControl.
@Test
public void testRequiredRuleByDefaultPlanItemControl() {
// given
PlanItemControl defaultControl = createElement(humanTask, "ItemControl_1", DefaultControl.class);
RequiredRule requiredRule = createElement(defaultControl, "RequiredRule_1", RequiredRule.class);
ConditionExpression expression = createElement(requiredRule, "Expression_1", ConditionExpression.class);
expression.setText("${true}");
Cmmn.validateModel(modelInstance);
// when
CmmnActivity newActivity = handler.handleElement(planItem, context);
// then
Object rule = newActivity.getProperty(PROPERTY_REQUIRED_RULE);
assertNotNull(rule);
assertTrue(rule instanceof CaseControlRule);
}
use of org.camunda.bpm.model.cmmn.instance.ConditionExpression in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testManualActivationRule.
@Test
public void testManualActivationRule() {
// given
ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
ManualActivationRule manualActivationRule = createElement(itemControl, "ManualActivationRule_1", ManualActivationRule.class);
ConditionExpression expression = createElement(manualActivationRule, "Expression_1", ConditionExpression.class);
expression.setText("${true}");
Cmmn.validateModel(modelInstance);
// when
CmmnActivity newActivity = handler.handleElement(planItem, context);
// then
Object rule = newActivity.getProperty(PROPERTY_MANUAL_ACTIVATION_RULE);
assertNotNull(rule);
assertTrue(rule instanceof CaseControlRule);
}
Aggregations