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);
}
}
}
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);
}
}
}
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());
}
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());
}
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());
}
Aggregations