use of org.camunda.bpm.engine.task.IdentityLink 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.task.IdentityLink 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.task.IdentityLink 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.task.IdentityLink in project camunda-bpm-platform by camunda.
the class TaskDecoratorTest method testDecorateCandidateGroups.
public void testDecorateCandidateGroups() {
// given
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.task.IdentityLink in project camunda-bpm-platform by camunda.
the class InvoiceTestCase method testApproveInvoiceAssignment.
@Deployment(resources = { "invoice.v2.bpmn", "invoiceBusinessDecisions.dmn" })
public void testApproveInvoiceAssignment() {
InputStream invoiceInputStream = InvoiceProcessApplication.class.getClassLoader().getResourceAsStream("invoice.pdf");
VariableMap variables = Variables.createVariables().putValue("creditor", "Great Pizza for Everyone Inc.").putValue("amount", 300.0d).putValue("invoiceCategory", "Travel Expenses").putValue("invoiceNumber", "GPFE-23232323").putValue("invoiceDocument", fileValue("invoice.pdf").file(invoiceInputStream).mimeType("application/pdf").create()).putValue("approverGroups", Arrays.asList("sales", "accounting"));
ProcessInstance pi = runtimeService.createProcessInstanceByKey("invoice").setVariables(variables).startBeforeActivity("approveInvoice").execute();
// givent that the process instance is waiting at task "approveInvoice"
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("approveInvoice", task.getTaskDefinitionKey());
// and task has candidate groups
List<IdentityLink> links = taskService.getIdentityLinksForTask(task.getId());
Set<String> approverGroups = new HashSet<String>();
for (IdentityLink link : links) {
approverGroups.add(link.getGroupId());
}
assertEquals(2, approverGroups.size());
assertTrue(approverGroups.contains("accounting"));
assertTrue(approverGroups.contains("sales"));
// and variable approver is null
assertNull(taskService.getVariable(task.getId(), "approver"));
// if mary claims the task
taskService.claim(task.getId(), "mary");
// then the variable "approver" exists and is set to mary
assertEquals("mary", taskService.getVariable(task.getId(), "approver"));
}
Aggregations