use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class CaseVariableListenerHandlerTest method testClassDelegateHandling.
@Test
public void testClassDelegateHandling() {
ExtensionElements extensionElements = SpecUtil.createElement(modelInstance, caseTask, null, ExtensionElements.class);
CamundaVariableListener variableListener = SpecUtil.createElement(modelInstance, extensionElements, null, CamundaVariableListener.class);
CamundaField field = SpecUtil.createElement(modelInstance, variableListener, null, CamundaField.class);
field.setCamundaName("fieldName");
field.setCamundaStringValue("a string value");
variableListener.setCamundaClass("a.class.Name");
// when
CmmnActivity activity = handler.handleElement(planItem, context);
List<VariableListener<?>> listeners = activity.getVariableListenersLocal(CaseVariableListener.CREATE);
Assert.assertEquals(1, listeners.size());
ClassDelegateCaseVariableListener listener = (ClassDelegateCaseVariableListener) listeners.get(0);
Assert.assertEquals("a.class.Name", listener.getClassName());
Assert.assertEquals(1, listener.getFieldDeclarations().size());
Assert.assertEquals("fieldName", listener.getFieldDeclarations().get(0).getName());
Object fieldValue = listener.getFieldDeclarations().get(0).getValue();
assertTrue(fieldValue instanceof Expression);
Expression expressionValue = (Expression) fieldValue;
assertEquals("a string value", expressionValue.getExpressionText());
Assert.assertEquals(listener, activity.getVariableListenersLocal(CaseVariableListener.UPDATE).get(0));
Assert.assertEquals(listener, activity.getVariableListenersLocal(CaseVariableListener.DELETE).get(0));
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class TaskDecoratorTest method testDecoratePriority.
public void testDecoratePriority() {
// given
String aPriority = "10";
Expression priorityExpression = expressionManager.createExpression(aPriority);
taskDefinition.setPriorityExpression(priorityExpression);
// when
decorate(task, taskDecorator);
// then
assertEquals(Integer.parseInt(aPriority), task.getPriority());
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class TaskDecoratorTest method testDecorateCandidateUsers.
public void testDecorateCandidateUsers() {
// given
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 testDecorateAssigneeFromVariable.
public void testDecorateAssigneeFromVariable() {
// given
String aAssignee = "john";
taskService.setVariable(task.getId(), "assignee", aAssignee);
Expression assigneeExpression = expressionManager.createExpression("${assignee}");
taskDefinition.setAssigneeExpression(assigneeExpression);
// when
decorate(task, taskDecorator);
// then
assertEquals(aAssignee, task.getAssignee());
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class TaskDecoratorTest method testDecorateDescription.
public void testDecorateDescription() {
// given
String aDescription = "This is a Task";
Expression descriptionExpression = expressionManager.createExpression(aDescription);
taskDefinition.setDescriptionExpression(descriptionExpression);
// when
decorate(task, taskDecorator);
// then
assertEquals(aDescription, task.getDescription());
}
Aggregations