Search in sources :

Example 76 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class TaskIdentityLinksTest method testOwnerLink.

public void testOwnerLink() {
    Task task = taskService.newTask("task");
    task.setOwner("owner");
    taskService.saveTask(task);
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
    assertNotNull(identityLinks);
    assertEquals(1, identityLinks.size());
    IdentityLink identityLink = identityLinks.get(0);
    assertEquals(IdentityLinkType.OWNER, identityLink.getType());
    assertEquals("owner", identityLink.getUserId());
    assertEquals("task", identityLink.getTaskId());
    taskService.deleteTask(task.getId(), true);
}
Also used : Task(org.camunda.bpm.engine.task.Task) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 77 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class TaskIdentityLinksTest method testCustomTypeUserLink.

@Deployment(resources = "org/camunda/bpm/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());
}
Also used : IdentityLink(org.camunda.bpm.engine.task.IdentityLink) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 78 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class TaskIdentityLinksTest method testCustomLinkGroupLink.

@Deployment(resources = "org/camunda/bpm/engine/test/api/task/IdentityLinksProcess.bpmn20.xml")
public void testCustomLinkGroupLink() {
    runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.addGroupIdentityLink(taskId, "muppets", "playing");
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
    IdentityLink identityLink = identityLinks.get(0);
    assertEquals("muppets", identityLink.getGroupId());
    assertNull("kermit", identityLink.getUserId());
    assertEquals("playing", identityLink.getType());
    assertEquals(taskId, identityLink.getTaskId());
    assertEquals(1, identityLinks.size());
    taskService.deleteGroupIdentityLink(taskId, "muppets", "playing");
    assertEquals(0, taskService.getIdentityLinksForTask(taskId).size());
}
Also used : IdentityLink(org.camunda.bpm.engine.task.IdentityLink) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 79 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class TaskAuthorizationTest method testProcessTaskAddCandidateGroupWithUpdatePersmissionOnTask.

public void testProcessTaskAddCandidateGroupWithUpdatePersmissionOnTask() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    String taskId = selectSingleTask().getId();
    createGrantAuthorization(TASK, taskId, userId, UPDATE);
    // when
    taskService.addCandidateGroup(taskId, "accounting");
    // then
    disableAuthorization();
    List<IdentityLink> linksForTask = taskService.getIdentityLinksForTask(taskId);
    enableAuthorization();
    assertNotNull(linksForTask);
    assertEquals(1, linksForTask.size());
    IdentityLink identityLink = linksForTask.get(0);
    assertNotNull(identityLink);
    assertEquals("accounting", identityLink.getGroupId());
    assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
}
Also used : IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 80 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class HistoricIdentityLinkLogTestByXml method testShouldAddProcessCandidateStarterGroupforAddIdentityLinkUsingXml.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/OneTaskProcessWithCandidateStarterGroups.bpmn20.xml" })
public void testShouldAddProcessCandidateStarterGroupforAddIdentityLinkUsingXml() {
    // Pre test - Historical identity link is added as part of deployment
    List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 1);
    // given
    ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY_CANDIDATE_STARTER_GROUP).singleResult();
    assertNotNull(latestProcessDef);
    List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
    assertEquals(1, links.size());
    historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 1);
    // query Test
    HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.groupId(XML_GROUP).count(), 1);
}
Also used : HistoricIdentityLinkLog(org.camunda.bpm.engine.history.HistoricIdentityLinkLog) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) HistoricIdentityLinkLogQuery(org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

IdentityLink (org.camunda.bpm.engine.task.IdentityLink)81 Task (org.camunda.bpm.engine.task.Task)13 Deployment (org.camunda.bpm.engine.test.Deployment)13 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 InputStream (java.io.InputStream)4 HashSet (java.util.HashSet)4 Expression (org.camunda.bpm.engine.delegate.Expression)4 HistoricIdentityLinkLog (org.camunda.bpm.engine.history.HistoricIdentityLinkLog)4 DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)4 VariableMap (org.camunda.bpm.engine.variable.VariableMap)4 TaskService (org.camunda.bpm.engine.TaskService)3 HistoricIdentityLinkLogQuery (org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery)3 List (java.util.List)2 HalResource (org.camunda.bpm.engine.rest.hal.HalResource)2 Job (org.camunda.bpm.engine.runtime.Job)2 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 Matchers.anyString (org.mockito.Matchers.anyString)2