use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.
the class HumanTaskDicretionaryItemHandlerTest method testManualActivationRule.
@Test
public void testManualActivationRule() {
// given
ItemControl itemControl = createElement(discretionaryItem, "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(discretionaryItem, context);
// then
Object rule = newActivity.getProperty(PROPERTY_MANUAL_ACTIVATION_RULE);
assertNotNull(rule);
assertTrue(rule instanceof CaseControlRule);
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.
the class HumanTaskDicretionaryItemHandlerTest 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(discretionaryItem, context);
// then
Object rule = newActivity.getProperty(PROPERTY_REQUIRED_RULE);
assertNotNull(rule);
assertTrue(rule instanceof CaseControlRule);
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.
the class HumanTaskDicretionaryItemHandlerTest method testManualActivationRuleByDefaultPlanItemControl.
@Test
public void testManualActivationRuleByDefaultPlanItemControl() {
// given
PlanItemControl defaultControl = createElement(humanTask, "ItemControl_1", DefaultControl.class);
ManualActivationRule manualActivationRule = createElement(defaultControl, "ManualActivationRule_1", ManualActivationRule.class);
ConditionExpression expression = createElement(manualActivationRule, "Expression_1", ConditionExpression.class);
expression.setText("${true}");
Cmmn.validateModel(modelInstance);
// when
CmmnActivity newActivity = handler.handleElement(discretionaryItem, context);
// then
Object rule = newActivity.getProperty(PROPERTY_MANUAL_ACTIVATION_RULE);
assertNotNull(rule);
assertTrue(rule instanceof CaseControlRule);
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testDeleteTaskListenerByExpression.
@Test
public void testDeleteTaskListenerByExpression() {
// given:
ExtensionElements extensionElements = addExtensionElements(humanTask);
CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);
String expression = "${myExpression}";
String event = TaskListener.EVENTNAME_DELETE;
taskListener.setCamundaEvent(event);
taskListener.setCamundaExpression(expression);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
assertEquals(0, activity.getListeners().size());
HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
TaskDefinition taskDefinition = behavior.getTaskDefinition();
assertNotNull(taskDefinition);
assertEquals(1, taskDefinition.getTaskListeners().size());
List<TaskListener> createListeners = taskDefinition.getTaskListeners(event);
assertEquals(1, createListeners.size());
TaskListener listener = createListeners.get(0);
assertTrue(listener instanceof ExpressionTaskListener);
ExpressionTaskListener expressionListener = (ExpressionTaskListener) listener;
assertEquals(expression, expressionListener.getExpressionText());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testMultipleExitCriteria.
@Test
public void testMultipleExitCriteria() {
// 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);
Body body1 = createElement(conditionExpression1, null, Body.class);
body1.setTextContent("${test}");
// set first exitCriteria
ExitCriterion criterion1 = createElement(planItem, ExitCriterion.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);
Body body2 = createElement(conditionExpression2, null, Body.class);
body2.setTextContent("${test}");
// set second exitCriteria
ExitCriterion criterion2 = createElement(planItem, ExitCriterion.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.getEntryCriteria().isEmpty());
assertFalse(newActivity.getExitCriteria().isEmpty());
assertEquals(2, newActivity.getExitCriteria().size());
assertTrue(newActivity.getExitCriteria().contains(firstSentryDeclaration));
assertTrue(newActivity.getExitCriteria().contains(secondSentryDeclaration));
}
Aggregations