use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testGetIdentityLinksWithAssignee.
@Test
public void testGetIdentityLinksWithAssignee() {
Task task = taskService.newTask();
taskService.saveTask(task);
String taskId = task.getId();
identityService.saveUser(identityService.newUser("kermit"));
taskService.claim(taskId, "kermit");
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
assertEquals(1, identityLinks.size());
assertEquals("kermit", identityLinks.get(0).getUserId());
assertNull(identityLinks.get(0).getGroupId());
assertEquals(IdentityLinkType.ASSIGNEE, identityLinks.get(0).getType());
// cleanup
taskService.deleteTask(taskId, true);
identityService.deleteUser("kermit");
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class TaskIdentityLinksTest method testAssigneeLink.
public void testAssigneeLink() {
Task task = taskService.newTask("task");
task.setAssignee("assignee");
taskService.saveTask(task);
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
assertNotNull(identityLinks);
assertEquals(1, identityLinks.size());
IdentityLink identityLink = identityLinks.get(0);
assertEquals(IdentityLinkType.ASSIGNEE, identityLink.getType());
assertEquals("assignee", identityLink.getUserId());
assertEquals("task", identityLink.getTaskId());
taskService.deleteTask(task.getId(), true);
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class TaskIdentityLinksTest method testCandidateUserLink.
@Deployment(resources = "org/camunda/bpm/engine/test/api/task/IdentityLinksProcess.bpmn20.xml")
public void testCandidateUserLink() {
runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.addCandidateUser(taskId, "kermit");
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
IdentityLink identityLink = identityLinks.get(0);
assertNull(identityLink.getGroupId());
assertEquals("kermit", identityLink.getUserId());
assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
assertEquals(taskId, identityLink.getTaskId());
assertEquals(1, identityLinks.size());
taskService.deleteCandidateUser(taskId, "kermit");
assertEquals(0, taskService.getIdentityLinksForTask(taskId).size());
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class TaskIdentityLinksTest method testCandidateGroupLink.
@Deployment(resources = "org/camunda/bpm/engine/test/api/task/IdentityLinksProcess.bpmn20.xml")
public void testCandidateGroupLink() {
try {
identityService.setAuthenticatedUserId("demo");
runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.addCandidateGroup(taskId, "muppets");
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
IdentityLink identityLink = identityLinks.get(0);
assertEquals("muppets", identityLink.getGroupId());
assertNull("kermit", identityLink.getUserId());
assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
assertEquals(taskId, identityLink.getTaskId());
assertEquals(1, identityLinks.size());
if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_FULL) {
List<Event> taskEvents = taskService.getTaskEvents(taskId);
assertEquals(1, taskEvents.size());
Event taskEvent = taskEvents.get(0);
assertEquals(Event.ACTION_ADD_GROUP_LINK, taskEvent.getAction());
List<String> taskEventMessageParts = taskEvent.getMessageParts();
assertEquals("muppets", taskEventMessageParts.get(0));
assertEquals(IdentityLinkType.CANDIDATE, taskEventMessageParts.get(1));
assertEquals(2, taskEventMessageParts.size());
}
taskService.deleteCandidateGroup(taskId, "muppets");
if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_FULL) {
List<Event> taskEvents = taskService.getTaskEvents(taskId);
Event taskEvent = findTaskEvent(taskEvents, Event.ACTION_DELETE_GROUP_LINK);
assertEquals(Event.ACTION_DELETE_GROUP_LINK, taskEvent.getAction());
List<String> taskEventMessageParts = taskEvent.getMessageParts();
assertEquals("muppets", taskEventMessageParts.get(0));
assertEquals(IdentityLinkType.CANDIDATE, taskEventMessageParts.get(1));
assertEquals(2, taskEventMessageParts.size());
assertEquals(2, taskEvents.size());
}
assertEquals(0, taskService.getIdentityLinksForTask(taskId).size());
} finally {
identityService.clearAuthentication();
}
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class DelegateTaskTestTaskListener method notify.
public void notify(DelegateTask delegateTask) {
Set<IdentityLink> candidates = delegateTask.getCandidates();
Set<String> candidateUsers = new HashSet<String>();
Set<String> candidateGroups = new HashSet<String>();
for (IdentityLink candidate : candidates) {
if (candidate.getUserId() != null) {
candidateUsers.add(candidate.getUserId());
} else if (candidate.getGroupId() != null) {
candidateGroups.add(candidate.getGroupId());
}
}
delegateTask.setVariable(VARNAME_CANDIDATE_USERS, candidateUsers);
delegateTask.setVariable(VARNAME_CANDIDATE_GROUPS, candidateGroups);
}
Aggregations