use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testDeleteTaskListenerByDelegateExpression.
@Test
public void testDeleteTaskListenerByDelegateExpression() {
// given:
ExtensionElements extensionElements = addExtensionElements(humanTask);
CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);
String delegateExpression = "${myDelegateExpression}";
String event = TaskListener.EVENTNAME_DELETE;
taskListener.setCamundaEvent(event);
taskListener.setCamundaDelegateExpression(delegateExpression);
// 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 DelegateExpressionTaskListener);
DelegateExpressionTaskListener delegateExpressionListener = (DelegateExpressionTaskListener) listener;
assertEquals(delegateExpression, delegateExpressionListener.getExpressionText());
assertTrue(delegateExpressionListener.getFieldDeclarations().isEmpty());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testTaskDecorator.
@Test
public void testTaskDecorator() {
// given: a plan item
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
// there exists a taskDecorator
HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
assertNotNull(behavior.getTaskDecorator());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testTaskDefinition.
@Test
public void testTaskDefinition() {
// given: a plan item
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
// there exists a taskDefinition
HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
assertNotNull(behavior.getTaskDefinition());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testEntryCriteria.
@Test
public void testEntryCriteria() {
// 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 entryCriterion
EntryCriterion criterion = createElement(planItem, EntryCriterion.class);
criterion.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
assertTrue(newActivity.getExitCriteria().isEmpty());
assertFalse(newActivity.getEntryCriteria().isEmpty());
assertEquals(1, newActivity.getEntryCriteria().size());
assertEquals(sentryDeclaration, newActivity.getEntryCriteria().get(0));
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testRepetitionRuleCustomStandardEvents.
@Test
public void testRepetitionRuleCustomStandardEvents() {
// 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}");
repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);
Cmmn.validateModel(modelInstance);
// when
CmmnActivity newActivity = handler.handleElement(planItem, context);
// then
List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
assertNotNull(events);
assertEquals(1, events.size());
assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
Aggregations