org.activiti.engine.task.IdentityLinkType Java Examples

The following examples show how to use org.activiti.engine.task.IdentityLinkType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivitiTaskActionService.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void involveUser(String taskId, ObjectNode requestNode) {
  Task task = taskService.createTaskQuery().taskId(taskId).singleResult();

  if (task == null) {
    throw new NotFoundException("Task with id: " + taskId + " does not exist");
  }

  User currentUser = SecurityUtils.getCurrentUserObject();
  permissionService.validateReadPermissionOnTask(currentUser, task.getId());

  if (requestNode.get("userId") != null) {
    String userId = requestNode.get("userId").asText();
    CachedUser user = userCache.getUser(userId);
    if (user == null) {
      throw new BadRequestException("Invalid user id");
    }
    taskService.addUserIdentityLink(taskId, userId.toString(), IdentityLinkType.PARTICIPANT);

  } else {
    throw new BadRequestException("User id is required");
  }

}
 
Example #2
Source File: TaskCreateListener.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void notify(DelegateTask task)
{
    // Set all default properties, based on the type-definition
    propertyConverter.setDefaultTaskProperties(task);

    String taskFormKey = getFormKey(task);
    
    // Fetch definition and extract name again. Possible that the default is used if the provided is missing
    TypeDefinition typeDefinition = propertyConverter.getWorkflowObjectFactory().getTaskTypeDefinition(taskFormKey, false);
    taskFormKey = typeDefinition.getName().toPrefixString();
    
    // The taskDefinition key is set as a variable in order to be available
    // in the history
    task.setVariableLocal(ActivitiConstants.PROP_TASK_FORM_KEY, taskFormKey);
    
    // Add process initiator as involved person
    ActivitiScriptNode initiatorNode = (ActivitiScriptNode) task.getExecution().getVariable(WorkflowConstants.PROP_INITIATOR);
    if(initiatorNode != null) {
        task.addUserIdentityLink((String) initiatorNode.getProperties().get(ContentModel.PROP_USERNAME.toPrefixString()), IdentityLinkType.STARTER);
    }
}
 
Example #3
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testGetIdentityLinksWithCandidateUser() {
  Task task = taskService.newTask();
  taskService.saveTask(task);
  String taskId = task.getId();
  
  identityService.saveUser(identityService.newUser("kermit"));
  
  taskService.addCandidateUser(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.CANDIDATE, identityLinks.get(0).getType());
  
  //cleanup
  taskService.deleteTask(taskId, true);
  identityService.deleteUser("kermit");
}
 
Example #4
Source File: ActivitiTaskActionService.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void assignTask(User currentUser, Task task, String assigneeIdString) {
  try {
    String oldAssignee = task.getAssignee();
    taskService.setAssignee(task.getId(), assigneeIdString);

    // If the old assignee user wasn't part of the involved users yet, make it so
    addIdentiyLinkForUser(task, oldAssignee, IdentityLinkType.PARTICIPANT);

    // If the current user wasn't part of the involved users yet, make it so
    String currentUserIdString = String.valueOf(currentUser.getId());
    addIdentiyLinkForUser(task, currentUserIdString, IdentityLinkType.PARTICIPANT);

  } catch (ActivitiException e) {
    throw new BadRequestException("Task " + task.getId() + " can't be assigned", e);
  }
}
 
Example #5
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testGetIdentityLinksWithCandidateGroup() {
  Task task = taskService.newTask();
  taskService.saveTask(task);
  String taskId = task.getId();
  
  identityService.saveGroup(identityService.newGroup("muppets"));
  
  taskService.addCandidateGroup(taskId, "muppets");
  List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
  assertEquals(1, identityLinks.size());
  assertEquals("muppets", identityLinks.get(0).getGroupId());
  assertNull(identityLinks.get(0).getUserId());
  assertEquals(IdentityLinkType.CANDIDATE, identityLinks.get(0).getType());
  
  //cleanup
  taskService.deleteTask(taskId, true);
  identityService.deleteGroup("muppets");
}
 
Example #6
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
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");
}
 
Example #7
Source File: TaskIdentityLinksTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = "org/activiti5/engine/test/api/task/IdentityLinksProcess.bpmn20.xml")
public void testEmptyCandidateUserLink() {
  runtimeService.startProcessInstanceByKey("IdentityLinksProcess");

  String taskId = taskService
      .createTaskQuery()
      .singleResult()
      .getId();

  taskService.addCandidateGroup(taskId, "muppets");
  taskService.deleteCandidateUser(taskId, "kermit");

  List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
  assertNotNull(identityLinks);
  assertEquals( 1, identityLinks.size());

  IdentityLink identityLink = identityLinks.get(0);
  assertEquals("muppets", identityLink.getGroupId());
  assertEquals(null, identityLink.getUserId());
  assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
  assertEquals(taskId, identityLink.getTaskId());

  taskService.deleteCandidateGroup(taskId, "muppets");

  assertEquals(0, taskService.getIdentityLinksForTask(taskId).size());
}
 
Example #8
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testGetIdentityLinksWithNonExistingOwner() {
  Task task = taskService.newTask();
  taskService.saveTask(task);
  String taskId = task.getId();
  
  taskService.claim(taskId, "nonExistingOwner");
  taskService.delegateTask(taskId, "nonExistingAssignee");
  List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
  assertEquals(2, identityLinks.size());

  IdentityLink assignee = identityLinks.get(0);
  assertEquals("nonExistingAssignee", assignee.getUserId());
  assertNull(assignee.getGroupId());
  assertEquals(IdentityLinkType.ASSIGNEE, assignee.getType());
  
  IdentityLink owner = identityLinks.get(1);
  assertEquals("nonExistingOwner", owner.getUserId());
  assertNull(owner.getGroupId());
  assertEquals(IdentityLinkType.OWNER, owner.getType());

  //cleanup
  taskService.deleteTask(taskId, true);
}
 
Example #9
Source File: TaskIdentityLinksTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources="org/activiti5/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());
}
 
Example #10
Source File: ActivitiPropertyConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<NodeRef> getPooledActorsReference(Collection<IdentityLink> links) 
{
     List<NodeRef> pooledActorRefs = new ArrayList<NodeRef>();
     if(links != null)
     {
         for(IdentityLink link : links)
         {
             if(IdentityLinkType.CANDIDATE.equals(link.getType()))
             {
                 String id = link.getGroupId();
                 if(id == null)
                 {
                     id = link.getUserId();
                 }
                 NodeRef pooledNodeRef = authorityManager.mapNameToAuthority(id);
                 if (pooledNodeRef != null)
                 {
                     pooledActorRefs.add(pooledNodeRef);
                 }
             }
         }
     }
     return pooledActorRefs;
}
 
Example #11
Source File: ProcessInstanceIdentityLinksTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources="org/activiti5/engine/test/api/runtime/IdentityLinksProcess.bpmn20.xml")
public void testParticipantUserLink() {
  Authentication.setAuthenticatedUserId(null);
  runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
  
  String processInstanceId = runtimeService
    .createProcessInstanceQuery()
    .singleResult()
    .getId();
  
  runtimeService.addParticipantUser(processInstanceId, "kermit");
  
  List<IdentityLink> identityLinks = runtimeService.getIdentityLinksForProcessInstance(processInstanceId);
  IdentityLink identityLink = identityLinks.get(0);
  
  assertNull(identityLink.getGroupId());
  assertEquals("kermit", identityLink.getUserId());
  assertEquals(IdentityLinkType.PARTICIPANT, identityLink.getType());
  assertEquals(processInstanceId, identityLink.getProcessInstanceId());
  
  assertEquals(1, identityLinks.size());

  runtimeService.deleteParticipantUser(processInstanceId, "kermit");
  
  assertEquals(0, runtimeService.getIdentityLinksForProcessInstance(processInstanceId).size());
}
 
Example #12
Source File: ProcessDefinitionIdentityLinkResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected IdentityLink getIdentityLink(String family, String identityId, String processDefinitionId) {
  boolean isUser = family.equals(RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS);

  // Perhaps it would be better to offer getting a single identitylink
  // from
  // the API
  List<IdentityLink> allLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinitionId);
  for (IdentityLink link : allLinks) {
    boolean rightIdentity = false;
    if (isUser) {
      rightIdentity = identityId.equals(link.getUserId());
    } else {
      rightIdentity = identityId.equals(link.getGroupId());
    }

    if (rightIdentity && link.getType().equals(IdentityLinkType.CANDIDATE)) {
      return link;
    }
  }
  throw new ActivitiObjectNotFoundException("Could not find the requested identity link.", IdentityLink.class);
}
 
Example #13
Source File: AddIdentityLinkCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void validateParams(String taskId, String identityId, int identityIdType, String identityType) {
  if (taskId == null) {
    throw new ActivitiIllegalArgumentException("taskId is null");
  }

  if (identityType == null) {
    throw new ActivitiIllegalArgumentException("type is required when adding a new task identity link");
  }

  if (identityId == null && (identityIdType == IDENTITY_GROUP || 
      (IdentityLinkType.ASSIGNEE.equals(identityType) == false && IdentityLinkType.OWNER.equals(identityType) == false))) {
    
    throw new ActivitiIllegalArgumentException("identityId is null");
  }
  
  if (identityIdType != IDENTITY_USER && identityIdType != IDENTITY_GROUP) {
    throw new ActivitiIllegalArgumentException("identityIdType allowed values are 1 and 2");
  }
}
 
Example #14
Source File: TasksImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public CollectionWithPagingInfo<TaskCandidate> getTaskCandidates(String taskId, Paging paging) 
{
    // Fetch task to check if user is authorized to perform the delete
    getValidTask(taskId);
    
    List<IdentityLink> links = activitiProcessEngine.getTaskService().getIdentityLinksForTask(taskId);
    List<TaskCandidate> page = new ArrayList<TaskCandidate>();
    if (links != null) 
    {
        for (IdentityLink identityLink : links)
        {
            if (IdentityLinkType.CANDIDATE.equals(identityLink.getType())) 
            {
                page.add(new TaskCandidate(identityLink));
            }
        }
    }
    
    return CollectionWithPagingInfo.asPaged(paging, page, false, page.size());
}
 
Example #15
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testGetIdentityLinksWithCandidateUser() {
  Task task = taskService.newTask();
  taskService.saveTask(task);
  String taskId = task.getId();

  identityService.saveUser(identityService.newUser("kermit"));

  taskService.addCandidateUser(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.CANDIDATE, identityLinks.get(0).getType());

  // cleanup
  taskService.deleteTask(taskId, true);
  identityService.deleteUser("kermit");
}
 
Example #16
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testGetIdentityLinksWithCandidateGroup() {
  Task task = taskService.newTask();
  taskService.saveTask(task);
  String taskId = task.getId();

  identityService.saveGroup(identityService.newGroup("muppets"));

  taskService.addCandidateGroup(taskId, "muppets");
  List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
  assertEquals(1, identityLinks.size());
  assertEquals("muppets", identityLinks.get(0).getGroupId());
  assertNull(identityLinks.get(0).getUserId());
  assertEquals(IdentityLinkType.CANDIDATE, identityLinks.get(0).getType());

  // cleanup
  taskService.deleteTask(taskId, true);
  identityService.deleteGroup("muppets");
}
 
Example #17
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
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");
}
 
Example #18
Source File: BpmnDeploymentHelper.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void addAuthorizationsFromIterator(CommandContext commandContext, List<String> expressions, 
    ProcessDefinitionEntity processDefinition, ExpressionType expressionType) {
  
  if (expressions != null) {
    Iterator<String> iterator = expressions.iterator();
    while (iterator.hasNext()) {
      @SuppressWarnings("cast")
      String expression = iterator.next();
      IdentityLinkEntity identityLink = commandContext.getIdentityLinkEntityManager().create();
      identityLink.setProcessDef(processDefinition);
      if (expressionType.equals(ExpressionType.USER)) {
        identityLink.setUserId(expression);
      } else if (expressionType.equals(ExpressionType.GROUP)) {
        identityLink.setGroupId(expression);
      }
      identityLink.setType(IdentityLinkType.CANDIDATE);
      commandContext.getIdentityLinkEntityManager().insert(identityLink);
    }
  }
  
}
 
Example #19
Source File: DeleteIdentityLinkCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected Void execute(CommandContext commandContext, TaskEntity task) {
  if (task.getProcessDefinitionId() != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) {
    Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); 
    activiti5CompatibilityHandler.deleteIdentityLink(taskId, userId, groupId, type);
    return null;
  }

  if (IdentityLinkType.ASSIGNEE.equals(type)) {
    commandContext.getTaskEntityManager().changeTaskAssignee(task, null);
  } else if (IdentityLinkType.OWNER.equals(type)) {
    commandContext.getTaskEntityManager().changeTaskOwner(task, null);
  } else {
    commandContext.getIdentityLinkEntityManager().deleteIdentityLink(task, userId, groupId, type);
  }

  commandContext.getHistoryManager().createIdentityLinkComment(taskId, userId, groupId, type, false);

  return null;
}
 
Example #20
Source File: DeleteIdentityLinkCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void validateParams(String userId, String groupId, String type, String taskId) {
  if (taskId == null) {
    throw new ActivitiIllegalArgumentException("taskId is null");
  }

  if (type == null) {
    throw new ActivitiIllegalArgumentException("type is required when adding a new task identity link");
  }

  // Special treatment for assignee and owner: group cannot be used and
  // userId may be null
  if (IdentityLinkType.ASSIGNEE.equals(type) || IdentityLinkType.OWNER.equals(type)) {
    if (groupId != null) {
      throw new ActivitiIllegalArgumentException("Incompatible usage: cannot use type '" + type + "' together with a groupId");
    }
  } else {
    if (userId == null && groupId == null) {
      throw new ActivitiIllegalArgumentException("userId and groupId cannot both be null");
    }
  }
}
 
Example #21
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testGetIdentityLinksWithNonExistingOwner() {
  Task task = taskService.newTask();
  taskService.saveTask(task);
  String taskId = task.getId();

  taskService.claim(taskId, "nonExistingOwner");
  taskService.delegateTask(taskId, "nonExistingAssignee");
  List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
  assertEquals(2, identityLinks.size());

  IdentityLink assignee = identityLinks.get(0);
  assertEquals("nonExistingAssignee", assignee.getUserId());
  assertNull(assignee.getGroupId());
  assertEquals(IdentityLinkType.ASSIGNEE, assignee.getType());

  IdentityLink owner = identityLinks.get(1);
  assertEquals("nonExistingOwner", owner.getUserId());
  assertNull(owner.getGroupId());
  assertEquals(IdentityLinkType.OWNER, owner.getType());

  // cleanup
  taskService.deleteTask(taskId, true);
}
 
Example #22
Source File: TaskQueryTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testQueryByInvolvedGroup() {
  try {
    Task adhocTask = taskService.newTask();
    adhocTask.setAssignee("kermit");
    adhocTask.setOwner("fozzie");
    taskService.saveTask(adhocTask);
    taskService.addGroupIdentityLink(adhocTask.getId(), "group1", IdentityLinkType.PARTICIPANT);

    List<String> groups = new ArrayList<String>();
    groups.add("group1");

    assertEquals(3, taskService.getIdentityLinksForTask(adhocTask.getId()).size());
    assertEquals(1, taskService.createTaskQuery()
        .taskId(adhocTask.getId()).taskInvolvedGroupsIn(groups).count());
  } finally {
    List<Task> allTasks = taskService.createTaskQuery().list();
    for (Task task : allTasks) {
      if (task.getExecutionId() == null) {
        taskService.deleteTask(task.getId());
        if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
          historyService.deleteHistoricTaskInstance(task.getId());
        }
      }
    }
  }
}
 
Example #23
Source File: TaskIdentityLinksTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = "org/activiti/engine/test/api/task/IdentityLinksProcess.bpmn20.xml")
public void testEmptyCandidateUserLink() {
  runtimeService.startProcessInstanceByKey("IdentityLinksProcess");

  String taskId = taskService.createTaskQuery().singleResult().getId();

  taskService.addCandidateGroup(taskId, "muppets");
  taskService.deleteCandidateUser(taskId, "kermit");

  List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
  assertNotNull(identityLinks);
  assertEquals(1, identityLinks.size());

  IdentityLink identityLink = identityLinks.get(0);
  assertEquals("muppets", identityLink.getGroupId());
  assertEquals(null, identityLink.getUserId());
  assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
  assertEquals(taskId, identityLink.getTaskId());

  taskService.deleteCandidateGroup(taskId, "muppets");

  assertEquals(0, taskService.getIdentityLinksForTask(taskId).size());
}
 
Example #24
Source File: TaskIdentityLinksTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testDeleteOwner() {
  Task task = taskService.newTask();
  task.setOwner("nonExistingUser");
  taskService.saveTask(task);

  taskService.deleteUserIdentityLink(task.getId(), "nonExistingUser", IdentityLinkType.OWNER);

  task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
  assertNull(task.getOwner());
  assertEquals(0, taskService.getIdentityLinksForTask(task.getId()).size());
  
  // cleanup
  taskService.deleteTask(task.getId(), true);
}
 
Example #25
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testAddGroupIdentityLinkNullUserId() {
  try {
    taskService.addGroupIdentityLink("taskId", null, IdentityLinkType.CANDIDATE);
    fail("ActivitiException expected");
  } catch (ActivitiIllegalArgumentException ae) {
    assertTextPresent("identityId is null", ae.getMessage());
  }
}
 
Example #26
Source File: TaskIdentityLinksTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testDeleteAssignee() {
  Task task = taskService.newTask();
  task.setAssignee("nonExistingUser");
  taskService.saveTask(task);

  taskService.deleteUserIdentityLink(task.getId(), "nonExistingUser", IdentityLinkType.ASSIGNEE);

  task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
  assertNull(task.getAssignee());
  assertEquals(0, taskService.getIdentityLinksForTask(task.getId()).size());
  
  // cleanup
  taskService.deleteTask(task.getId(), true);
}
 
Example #27
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testGetIdentityLinksWithNonExistingAssignee() {
  Task task = taskService.newTask();
  taskService.saveTask(task);
  String taskId = task.getId();

  taskService.claim(taskId, "nonExistingAssignee");
  List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
  assertEquals(1, identityLinks.size());
  assertEquals("nonExistingAssignee", identityLinks.get(0).getUserId());
  assertNull(identityLinks.get(0).getGroupId());
  assertEquals(IdentityLinkType.ASSIGNEE, identityLinks.get(0).getType());

  // cleanup
  taskService.deleteTask(taskId, true);
}
 
Example #28
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testAddUserIdentityLinkUnexistingTask() {
  User user = identityService.newUser("user");
  identityService.saveUser(user);

  try {
    taskService.addUserIdentityLink("unexistingTaskId", user.getId(), IdentityLinkType.CANDIDATE);
    fail("ActivitiException expected");
  } catch (ActivitiObjectNotFoundException ae) {
    assertTextPresent("Cannot find task with id unexistingTaskId", ae.getMessage());
    assertEquals(Task.class, ae.getObjectClass());
  }

  identityService.deleteUser(user.getId());
}
 
Example #29
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testAddUserIdentityLinkNullTaskId() {
  try {
    taskService.addUserIdentityLink(null, "userId", IdentityLinkType.CANDIDATE);
    fail("ActivitiException expected");
  } catch (ActivitiIllegalArgumentException ae) {
    assertTextPresent("taskId is null", ae.getMessage());
  }
}
 
Example #30
Source File: TaskServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testAddUserIdentityLinkNullUserId() {
  try {
    taskService.addUserIdentityLink("taskId", null, IdentityLinkType.CANDIDATE);
    fail("ActivitiException expected");
  } catch (ActivitiIllegalArgumentException ae) {
    assertTextPresent("identityId is null", ae.getMessage());
  }
}