Search in sources :

Example 31 with CmmnActivity

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testRepetitionRuleStandardEvents.

@Test
public void testRepetitionRuleStandardEvents() {
    // 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
    List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
    assertNotNull(events);
    assertEquals(2, events.size());
    assertTrue(events.contains(CaseExecutionListener.COMPLETE));
    assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
Also used : RepetitionRule(org.camunda.bpm.model.cmmn.instance.RepetitionRule) PlanItemControl(org.camunda.bpm.model.cmmn.instance.PlanItemControl) ItemControl(org.camunda.bpm.model.cmmn.instance.ItemControl) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 32 with CmmnActivity

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testHumanTaskDescription.

@Test
public void testHumanTaskDescription() {
    // given
    String description = "A description";
    humanTask.setDescription(description);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    TaskDefinition taskDefinition = behavior.getTaskDefinition();
    Expression descriptionExpression = taskDefinition.getDescriptionExpression();
    assertNotNull(descriptionExpression);
    assertEquals(description, descriptionExpression.getExpressionText());
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) Expression(org.camunda.bpm.engine.delegate.Expression) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 33 with CmmnActivity

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testAssignmentTaskListenerByClass.

@Test
public void testAssignmentTaskListenerByClass() {
    // given:
    ExtensionElements extensionElements = addExtensionElements(humanTask);
    CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);
    String className = "org.camunda.bpm.test.tasklistener.ABC";
    String event = TaskListener.EVENTNAME_ASSIGNMENT;
    taskListener.setCamundaEvent(event);
    taskListener.setCamundaClass(className);
    // 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 ClassDelegateTaskListener);
    ClassDelegateTaskListener classDelegateListener = (ClassDelegateTaskListener) listener;
    assertEquals(className, classDelegateListener.getClassName());
    assertTrue(classDelegateListener.getFieldDeclarations().isEmpty());
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) Test(org.junit.Test)

Example 34 with CmmnActivity

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testHumanTaskActivityType.

@Test
public void testHumanTaskActivityType() {
    // given
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    String activityType = (String) activity.getProperty(PROPERTY_ACTIVITY_TYPE);
    assertEquals("humanTask", activityType);
}
Also used : CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 35 with CmmnActivity

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testAssignmentTaskListenerByExpression.

@Test
public void testAssignmentTaskListenerByExpression() {
    // given:
    ExtensionElements extensionElements = addExtensionElements(humanTask);
    CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);
    String expression = "${myExpression}";
    String event = TaskListener.EVENTNAME_ASSIGNMENT;
    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());
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Aggregations

CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)325 Test (org.junit.Test)298 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)112 PlanItemControl (org.camunda.bpm.model.cmmn.instance.PlanItemControl)64 CaseControlRule (org.camunda.bpm.engine.impl.cmmn.CaseControlRule)47 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)47 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)39 Sentry (org.camunda.bpm.model.cmmn.instance.Sentry)39 IfPart (org.camunda.bpm.model.cmmn.instance.IfPart)37 CasePlanModelHandler (org.camunda.bpm.engine.impl.cmmn.handler.CasePlanModelHandler)36 SentryHandler (org.camunda.bpm.engine.impl.cmmn.handler.SentryHandler)35 CallableElement (org.camunda.bpm.engine.impl.core.model.CallableElement)34 ItemControl (org.camunda.bpm.model.cmmn.instance.ItemControl)32 HumanTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)29 RepetitionRule (org.camunda.bpm.model.cmmn.instance.RepetitionRule)28 ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)26 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)23 Body (org.camunda.bpm.model.cmmn.instance.Body)23 EntryCriterion (org.camunda.bpm.model.cmmn.instance.EntryCriterion)21 ExitCriterion (org.camunda.bpm.model.cmmn.instance.ExitCriterion)21