PeopleAssignmentHelper { protected void processPeopleAssignments(String peopleAssignmentIds, List<OrganizationalEntity> organizationalEntities, boolean user) { if (peopleAssignmentIds != null && peopleAssignmentIds.trim().length() > 0) { String[] ids = peopleAssignmentIds.split(separator); for (String id : ids) { id = id.trim(); if(id.length()==0) continue; boolean exists = false; for (OrganizationalEntity orgEntity : organizationalEntities) { if (orgEntity.getId().equals(id)) { exists = true; } } if (!exists) { OrganizationalEntity organizationalEntity = null; if (user) { organizationalEntity = TaskModelProvider.getFactory().newUser(); ((InternalOrganizationalEntity) organizationalEntity).setId(id); } else { organizationalEntity = TaskModelProvider.getFactory().newGroup(); ((InternalOrganizationalEntity) organizationalEntity).setId(id); } organizationalEntities.add(organizationalEntity); } } } } PeopleAssignmentHelper();  PeopleAssignmentHelper(String separator);  PeopleAssignmentHelper(String adminUser, String adminGroup);  PeopleAssignmentHelper(CaseData caseFile); void handlePeopleAssignments(WorkItem workItem, InternalTask task, InternalTaskData taskData); static final String ACTOR_ID; static final String GROUP_ID; static final String BUSINESSADMINISTRATOR_ID; static final String BUSINESSADMINISTRATOR_GROUP_ID; static final String TASKSTAKEHOLDER_ID; static final String EXCLUDED_OWNER_ID; static final String RECIPIENT_ID; static final String DEFAULT_ADMIN_USER; static final String DEFAULT_ADMIN_GROUP; }
@Test public void testProcessPeopleAssignments() { List<OrganizationalEntity> organizationalEntities = new ArrayList<OrganizationalEntity>(); String ids = "espiegelberg, drbug "; assertTrue(organizationalEntities.isEmpty()); peopleAssignmentHelper.processPeopleAssignments(ids, organizationalEntities, true); assertTrue(organizationalEntities.size() == 2); assertTrue(organizationalEntities.contains(createUser("drbug"))); assertTrue(organizationalEntities.contains(createUser("espiegelberg"))); ids = null; organizationalEntities = new ArrayList<OrganizationalEntity>(); assertTrue(organizationalEntities.isEmpty()); peopleAssignmentHelper.processPeopleAssignments(ids, organizationalEntities, true); assertTrue(organizationalEntities.isEmpty()); ids = " "; organizationalEntities = new ArrayList<OrganizationalEntity>(); assertTrue(organizationalEntities.isEmpty()); peopleAssignmentHelper.processPeopleAssignments(ids, organizationalEntities, true); assertTrue(organizationalEntities.isEmpty()); ids = "Software Developer"; organizationalEntities = new ArrayList<OrganizationalEntity>(); assertTrue(organizationalEntities.isEmpty()); peopleAssignmentHelper.processPeopleAssignments(ids, organizationalEntities, false); assertTrue(organizationalEntities.size() == 1); assertTrue(organizationalEntities.contains(createGroup("Software Developer"))); ids = "Software Developer,Project Manager"; peopleAssignmentHelper.processPeopleAssignments(ids, organizationalEntities, false); assertTrue(organizationalEntities.size() == 2); assertTrue(organizationalEntities.contains(createGroup("Software Developer"))); assertTrue(organizationalEntities.contains(createGroup("Project Manager"))); }
@Test public void testProcessPeopleAssignmentsWithEmptyStrings() { List<OrganizationalEntity> organizationalEntities = new ArrayList<OrganizationalEntity>(); String ids = "bpmsAdmin,"; assertTrue(organizationalEntities.isEmpty()); peopleAssignmentHelper.processPeopleAssignments(ids, organizationalEntities, true); assertTrue(organizationalEntities.size() == 1); assertTrue(organizationalEntities.contains(createUser("bpmsAdmin"))); ids = ",bpmsAdmin"; organizationalEntities = new ArrayList<OrganizationalEntity>(); assertTrue(organizationalEntities.isEmpty()); peopleAssignmentHelper.processPeopleAssignments(ids, organizationalEntities, true); assertTrue(organizationalEntities.size() == 1); assertTrue(organizationalEntities.contains(createUser("bpmsAdmin"))); }