Search in sources :

Example 26 with Expression

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

the class TaskDecoratorTest method testDecorateCandidateGroupsFromVariable.

public void testDecorateCandidateGroupsFromVariable() {
    // given
    taskService.setVariable(task.getId(), "management", "management");
    taskService.setVariable(task.getId(), "accounting", "accounting");
    taskService.setVariable(task.getId(), "backoffice", "backoffice");
    List<String> aCandidateGroupList = new ArrayList<String>();
    aCandidateGroupList.add("${management}");
    aCandidateGroupList.add("${accounting}");
    aCandidateGroupList.add("${backoffice}");
    for (String candidateGroup : aCandidateGroupList) {
        Expression candidateGroupExpression = expressionManager.createExpression(candidateGroup);
        taskDefinition.addCandidateGroupIdExpression(candidateGroupExpression);
    }
    // when
    decorate(task, taskDecorator);
    // then
    Set<IdentityLink> candidates = task.getCandidates();
    assertEquals(3, candidates.size());
    for (IdentityLink identityLink : candidates) {
        String taskId = identityLink.getTaskId();
        assertEquals(task.getId(), taskId);
        assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
        String groupId = identityLink.getGroupId();
        if ("management".equals(groupId)) {
            assertEquals("management", groupId);
        } else if ("accounting".equals(groupId)) {
            assertEquals("accounting", groupId);
        } else if ("backoffice".equals(groupId)) {
            assertEquals("backoffice", groupId);
        } else {
            fail("Unexpected group: " + groupId);
        }
    }
}
Also used : Expression(org.camunda.bpm.engine.delegate.Expression) ArrayList(java.util.ArrayList) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 27 with Expression

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

the class TaskDecoratorTest method testDecorateCandidateUsersFromVariable.

public void testDecorateCandidateUsersFromVariable() {
    // given
    taskService.setVariable(task.getId(), "john", "john");
    taskService.setVariable(task.getId(), "peter", "peter");
    taskService.setVariable(task.getId(), "mary", "mary");
    List<String> aCandidateUserList = new ArrayList<String>();
    aCandidateUserList.add("${john}");
    aCandidateUserList.add("${peter}");
    aCandidateUserList.add("${mary}");
    for (String candidateUser : aCandidateUserList) {
        Expression candidateUserExpression = expressionManager.createExpression(candidateUser);
        taskDefinition.addCandidateUserIdExpression(candidateUserExpression);
    }
    // when
    decorate(task, taskDecorator);
    // then
    Set<IdentityLink> candidates = task.getCandidates();
    assertEquals(3, candidates.size());
    for (IdentityLink identityLink : candidates) {
        String taskId = identityLink.getTaskId();
        assertEquals(task.getId(), taskId);
        assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
        String userId = identityLink.getUserId();
        if ("john".equals(userId)) {
            assertEquals("john", userId);
        } else if ("peter".equals(userId)) {
            assertEquals("peter", userId);
        } else if ("mary".equals(userId)) {
            assertEquals("mary", userId);
        } else {
            fail("Unexpected user: " + userId);
        }
    }
}
Also used : Expression(org.camunda.bpm.engine.delegate.Expression) ArrayList(java.util.ArrayList) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 28 with Expression

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

the class TaskDecoratorTest method testDecorateFollowUpDateFromVariable.

public void testDecorateFollowUpDateFromVariable() {
    // given
    String aFollowUpDateDate = "2014-06-01";
    Date followUpDate = DateTimeUtil.parseDate(aFollowUpDateDate);
    taskService.setVariable(task.getId(), "followUpDate", followUpDate);
    Expression followUpDateExpression = expressionManager.createExpression("${followUpDate}");
    taskDefinition.setFollowUpDateExpression(followUpDateExpression);
    // when
    decorate(task, taskDecorator);
    // then
    assertEquals(followUpDate, task.getFollowUpDate());
}
Also used : Expression(org.camunda.bpm.engine.delegate.Expression) Date(java.util.Date)

Example 29 with Expression

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

the class TaskDecoratorTest method testDecorateNameFromVariable.

public void testDecorateNameFromVariable() {
    // given
    String aTaskName = "A Task Name";
    taskService.setVariable(task.getId(), "taskName", aTaskName);
    Expression nameExpression = expressionManager.createExpression("${taskName}");
    taskDefinition.setNameExpression(nameExpression);
    // when
    decorate(task, taskDecorator);
    // then
    assertEquals(aTaskName, task.getName());
}
Also used : Expression(org.camunda.bpm.engine.delegate.Expression)

Example 30 with Expression

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

the class TaskDecoratorTest method testDecorateFollowUpDate.

public void testDecorateFollowUpDate() {
    // given
    String aFollowUpDate = "2014-06-01";
    Date followUpDate = DateTimeUtil.parseDate(aFollowUpDate);
    Expression followUpDateExpression = expressionManager.createExpression(aFollowUpDate);
    taskDefinition.setFollowUpDateExpression(followUpDateExpression);
    // when
    decorate(task, taskDecorator);
    // then
    assertEquals(followUpDate, task.getFollowUpDate());
}
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