Search in sources :

Example 1 with HumanTaskActivityBehavior

use of org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior 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());
}
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)

Example 2 with HumanTaskActivityBehavior

use of org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior 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 3 with HumanTaskActivityBehavior

use of org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior 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 4 with HumanTaskActivityBehavior

use of org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior 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)

Example 5 with HumanTaskActivityBehavior

use of org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testTaskDefinitionCandidateUsers.

@Test
public void testTaskDefinitionCandidateUsers() {
    // given
    String aCandidateUsers = "mary,john,peter";
    humanTask.setCamundaCandidateUsers(aCandidateUsers);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    TaskDefinition taskDefinition = behavior.getTaskDefinition();
    Set<Expression> candidateUserExpressions = taskDefinition.getCandidateUserIdExpressions();
    assertEquals(3, candidateUserExpressions.size());
    for (Expression candidateUserExpression : candidateUserExpressions) {
        String candidateUser = candidateUserExpression.getExpressionText();
        if ("mary".equals(candidateUser)) {
            assertEquals("mary", candidateUser);
        } else if ("john".equals(candidateUser)) {
            assertEquals("john", candidateUser);
        } else if ("peter".equals(candidateUser)) {
            assertEquals("peter", candidateUser);
        } else {
            fail("Unexpected candidate user: " + candidateUser);
        }
    }
}
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)

Aggregations

HumanTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)30 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)29 Test (org.junit.Test)29 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)24 Expression (org.camunda.bpm.engine.delegate.Expression)12 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)12 ClassDelegateTaskListener (org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener)12 DelegateExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener)12 ExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener)12 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)12 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)12 CamundaTaskListener (org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener)12 CmmnActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior)2 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)2 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)1 TaskDecorator (org.camunda.bpm.engine.impl.task.TaskDecorator)1 CaseRole (org.camunda.bpm.model.cmmn.instance.CaseRole)1