use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskIdentityLinksTest method testCustomTypeUserLink.
@Deployment(resources = "org/activiti/engine/test/api/task/IdentityLinksProcess.bpmn20.xml")
public void testCustomTypeUserLink() {
runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.addUserIdentityLink(taskId, "kermit", "interestee");
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
IdentityLink identityLink = identityLinks.get(0);
assertNull(identityLink.getGroupId());
assertEquals("kermit", identityLink.getUserId());
assertEquals("interestee", identityLink.getType());
assertEquals(taskId, identityLink.getTaskId());
assertEquals(1, identityLinks.size());
taskService.deleteUserIdentityLink(taskId, "kermit", "interestee");
assertEquals(0, taskService.getIdentityLinksForTask(taskId).size());
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskIdentityLinksTest method testCustomIdentityLink.
// Test custom identity links
@Deployment
public void testCustomIdentityLink() {
runtimeService.startProcessInstanceByKey("customIdentityLink");
List<Task> tasks = taskService.createTaskQuery().taskInvolvedUser("kermit").list();
assertEquals(1, tasks.size());
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(tasks.get(0).getId());
assertEquals(2, identityLinks.size());
for (IdentityLink idLink : identityLinks) {
assertEquals("businessAdministrator", idLink.getType());
String userId = idLink.getUserId();
if (userId == null) {
assertEquals("management", idLink.getGroupId());
} else {
assertEquals("kermit", userId);
}
}
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskServiceTest method testGetIdentityLinksWithAssignee.
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.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class RestResponseFactory method createRestIdentityLinks.
public List<RestIdentityLink> createRestIdentityLinks(List<IdentityLink> links) {
RestUrlBuilder urlBuilder = createUrlBuilder();
List<RestIdentityLink> responseList = new ArrayList<RestIdentityLink>();
for (IdentityLink instance : links) {
responseList.add(createRestIdentityLink(instance, urlBuilder));
}
return responseList;
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class IdentityLinkEventsTest method testTaskIdentityLinks.
/**
* Check identity links on process instances.
*/
@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskIdentityLinks() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
// Add identity link
taskService.addCandidateUser(task.getId(), "kermit");
taskService.addCandidateGroup(task.getId(), "sales");
// Three events are received, since the user link on the task also creates an involvment in the process
assertEquals(6, listener.getEventsReceived().size());
ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
assertTrue(event.getEntity() instanceof IdentityLink);
IdentityLink link = (IdentityLink) event.getEntity();
assertEquals("kermit", link.getUserId());
assertEquals("candidate", link.getType());
assertEquals(task.getId(), link.getTaskId());
assertEquals(task.getExecutionId(), event.getExecutionId());
assertEquals(task.getProcessDefinitionId(), event.getProcessDefinitionId());
assertEquals(task.getProcessInstanceId(), event.getProcessInstanceId());
event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
assertEquals("kermit", link.getUserId());
assertEquals("candidate", link.getType());
event = (ActivitiEntityEvent) listener.getEventsReceived().get(4);
assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
assertTrue(event.getEntity() instanceof IdentityLink);
link = (IdentityLink) event.getEntity();
assertEquals("sales", link.getGroupId());
assertEquals("candidate", link.getType());
assertEquals(task.getId(), link.getTaskId());
assertEquals(task.getExecutionId(), event.getExecutionId());
assertEquals(task.getProcessDefinitionId(), event.getProcessDefinitionId());
assertEquals(task.getProcessInstanceId(), event.getProcessInstanceId());
event = (ActivitiEntityEvent) listener.getEventsReceived().get(5);
assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
assertEquals("sales", link.getGroupId());
assertEquals("candidate", link.getType());
listener.clearEventsReceived();
// Deleting process should delete identity link
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
assertEquals(3, listener.getEventsReceived().size());
event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
event = (ActivitiEntityEvent) listener.getEventsReceived().get(2);
assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
}
Aggregations