Search in sources :

Example 51 with IdentityLink

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

the class MultiTenancyTaskServiceTest method testGetIdentityLinkWithTenantIdForCandidateUsers.

public void testGetIdentityLinkWithTenantIdForCandidateUsers() {
    // given
    BpmnModelInstance oneTaskProcess = Bpmn.createExecutableProcess("testProcess").startEvent().userTask("task").camundaCandidateUsers("aUserId").endEvent().done();
    deploymentForTenant("tenant", oneTaskProcess);
    ProcessInstance tenantProcessInstance = runtimeService.createProcessInstanceByKey("testProcess").processDefinitionTenantId("tenant").execute();
    Task tenantTask = taskService.createTaskQuery().processInstanceId(tenantProcessInstance.getId()).singleResult();
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(tenantTask.getId());
    assertEquals(identityLinks.size(), 1);
    assertEquals(identityLinks.get(0).getTenantId(), "tenant");
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 52 with IdentityLink

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

the class MultiTenancyTaskServiceTest method testGetIdentityLinkWithTenantIdForCandidateGroup.

public void testGetIdentityLinkWithTenantIdForCandidateGroup() {
    // given
    BpmnModelInstance oneTaskProcess = Bpmn.createExecutableProcess("testProcess").startEvent().userTask("task").camundaCandidateGroups("aGroupId").endEvent().done();
    deploymentForTenant("tenant", oneTaskProcess);
    ProcessInstance tenantProcessInstance = runtimeService.createProcessInstanceByKey("testProcess").processDefinitionTenantId("tenant").execute();
    Task tenantTask = taskService.createTaskQuery().processInstanceId(tenantProcessInstance.getId()).singleResult();
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(tenantTask.getId());
    assertEquals(identityLinks.size(), 1);
    assertEquals(identityLinks.get(0).getTenantId(), "tenant");
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 53 with IdentityLink

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

the class TaskAuthorizationTest method testProcessTaskAddCandidateGroupWithTaskAssignPersmissionOnProcessDefinition.

public void testProcessTaskAddCandidateGroupWithTaskAssignPersmissionOnProcessDefinition() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    String taskId = selectSingleTask().getId();
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, TASK_ASSIGN);
    // 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 54 with IdentityLink

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

the class TaskAuthorizationTest method testProcessTaskAddGroupIdentityLink.

public void testProcessTaskAddGroupIdentityLink() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    String taskId = selectSingleTask().getId();
    createGrantAuthorization(TASK, taskId, userId, UPDATE);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_TASK);
    // when
    taskService.addGroupIdentityLink(taskId, "accounting", IdentityLinkType.CANDIDATE);
    // 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 55 with IdentityLink

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

the class TaskAuthorizationTest method testProcessTaskAddUserIdentityLinkWithUpdatePersmissionOnAnyTask.

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

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