Search in sources :

Example 41 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testTaskDefinitionFormKey.

@Test
public void testTaskDefinitionFormKey() {
    // given
    String aFormKey = "aFormKey";
    humanTask.setCamundaFormKey(aFormKey);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    TaskDefinition taskDefinition = behavior.getTaskDefinition();
    Expression formKeyExpression = taskDefinition.getFormKey();
    assertNotNull(formKeyExpression);
    assertEquals(aFormKey, formKeyExpression.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 42 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testTaskDefinitionHumanTaskNameExpression.

@Test
public void testTaskDefinitionHumanTaskNameExpression() {
    // given
    String name = "A HumanTask";
    humanTask.setName(name);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    Expression nameExpression = behavior.getTaskDefinition().getNameExpression();
    assertNotNull(nameExpression);
    assertEquals("A HumanTask", nameExpression.getExpressionText());
}
Also used : 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 43 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testTaskDefinitionCandidateGroups.

@Test
public void testTaskDefinitionCandidateGroups() {
    // given
    String aCandidateGroups = "accounting,management,backoffice";
    humanTask.setCamundaCandidateGroups(aCandidateGroups);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    TaskDefinition taskDefinition = behavior.getTaskDefinition();
    Set<Expression> candidateGroupExpressions = taskDefinition.getCandidateGroupIdExpressions();
    assertEquals(3, candidateGroupExpressions.size());
    for (Expression candidateGroupExpression : candidateGroupExpressions) {
        String candidateGroup = candidateGroupExpression.getExpressionText();
        if ("accounting".equals(candidateGroup)) {
            assertEquals("accounting", candidateGroup);
        } else if ("management".equals(candidateGroup)) {
            assertEquals("management", candidateGroup);
        } else if ("backoffice".equals(candidateGroup)) {
            assertEquals("backoffice", candidateGroup);
        } else {
            fail("Unexpected candidate group: " + candidateGroup);
        }
    }
}
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 44 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testPlanItemDescription.

@Test
public void testPlanItemDescription() {
    // given
    String description = "A description";
    humanTask.setDescription(description);
    // the planItem has an own description
    String localDescription = "My Local Description";
    planItem.setDescription(localDescription);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    TaskDefinition taskDefinition = behavior.getTaskDefinition();
    Expression descriptionExpression = taskDefinition.getDescriptionExpression();
    assertNotNull(descriptionExpression);
    assertEquals(localDescription, 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 45 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class TaskDecoratorTest method testDecorateDueDateFromVariable.

public void testDecorateDueDateFromVariable() {
    // given
    String aDueDate = "2014-06-01";
    Date dueDate = DateTimeUtil.parseDate(aDueDate);
    taskService.setVariable(task.getId(), "dueDate", dueDate);
    Expression dueDateExpression = expressionManager.createExpression("${dueDate}");
    taskDefinition.setDueDateExpression(dueDateExpression);
    // when
    decorate(task, taskDecorator);
    // then
    assertEquals(dueDate, task.getDueDate());
}
Also used : Expression(org.camunda.bpm.engine.delegate.Expression) Date(java.util.Date)

Aggregations

Expression (org.camunda.bpm.engine.delegate.Expression)62 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)18 Test (org.junit.Test)15 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)14 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)14 HumanTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)12 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)12 HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)8 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 CmmnIfPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration)4 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)4 CamundaField (org.camunda.bpm.model.cmmn.instance.camunda.CamundaField)4 FieldDeclaration (org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration)3 CaseControlRuleImpl (org.camunda.bpm.engine.impl.cmmn.behavior.CaseControlRuleImpl)3 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)3 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)3 CamundaExpression (org.camunda.bpm.model.cmmn.instance.camunda.CamundaExpression)3 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)3 Collection (java.util.Collection)2