Search in sources :

Example 1 with PeopleAssignments

use of org.kie.api.task.model.PeopleAssignments in project jbpm by kiegroup.

the class PeopleAssignmentHelperTest method testAssignActorsWithCustomSeparator.

@Test
public void testAssignActorsWithCustomSeparator() {
    peopleAssignmentHelper = new PeopleAssignmentHelper(":");
    String actorId = "user1:user2";
    Task task = TaskModelProvider.getFactory().newTask();
    InternalTaskData taskData = (InternalTaskData) TaskModelProvider.getFactory().newTaskData();
    PeopleAssignments peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, actorId);
    peopleAssignmentHelper.assignActors(workItem, peopleAssignments, taskData);
    OrganizationalEntity organizationalEntity1 = peopleAssignments.getPotentialOwners().get(0);
    assertTrue(organizationalEntity1 instanceof User);
    assertEquals("user1", organizationalEntity1.getId());
    assertEquals("user1", taskData.getCreatedBy().getId());
    OrganizationalEntity organizationalEntity2 = peopleAssignments.getPotentialOwners().get(1);
    assertTrue(organizationalEntity2 instanceof User);
    assertEquals("user2", organizationalEntity2.getId());
    workItem = new WorkItemImpl();
    peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, actorId + ": drbug  ");
    peopleAssignmentHelper.assignActors(workItem, peopleAssignments, taskData);
    assertEquals(3, peopleAssignments.getPotentialOwners().size());
    organizationalEntity1 = peopleAssignments.getPotentialOwners().get(0);
    assertEquals("user1", organizationalEntity1.getId());
    assertEquals("user1", taskData.getCreatedBy().getId());
    organizationalEntity2 = peopleAssignments.getPotentialOwners().get(1);
    assertTrue(organizationalEntity2 instanceof User);
    assertEquals("user2", organizationalEntity2.getId());
    OrganizationalEntity organizationalEntity3 = peopleAssignments.getPotentialOwners().get(2);
    assertEquals("drbug", organizationalEntity3.getId());
    workItem = new WorkItemImpl();
    peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, "");
    peopleAssignmentHelper.assignActors(workItem, peopleAssignments, taskData);
    assertEquals(0, peopleAssignments.getPotentialOwners().size());
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) PeopleAssignments(org.kie.api.task.model.PeopleAssignments) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 2 with PeopleAssignments

use of org.kie.api.task.model.PeopleAssignments in project jbpm by kiegroup.

the class PeopleAssignmentHelperTest method testAssignBusinessAdministrators.

@Test
public void testAssignBusinessAdministrators() {
    String businessAdministratorId = "espiegelberg";
    Task task = TaskModelProvider.getFactory().newTask();
    PeopleAssignments peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter(PeopleAssignmentHelper.BUSINESSADMINISTRATOR_ID, businessAdministratorId);
    peopleAssignmentHelper.assignBusinessAdministrators(workItem, peopleAssignments);
    assertEquals(3, peopleAssignments.getBusinessAdministrators().size());
    OrganizationalEntity organizationalEntity1 = peopleAssignments.getBusinessAdministrators().get(0);
    assertTrue(organizationalEntity1 instanceof User);
    assertEquals("Administrator", organizationalEntity1.getId());
    OrganizationalEntity organizationalEntity2 = peopleAssignments.getBusinessAdministrators().get(1);
    assertTrue(organizationalEntity2 instanceof Group);
    assertEquals("Administrators", organizationalEntity2.getId());
    OrganizationalEntity organizationalEntity3 = peopleAssignments.getBusinessAdministrators().get(2);
    assertTrue(organizationalEntity3 instanceof User);
    assertEquals(businessAdministratorId, organizationalEntity3.getId());
}
Also used : Group(org.kie.api.task.model.Group) Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) PeopleAssignments(org.kie.api.task.model.PeopleAssignments) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 3 with PeopleAssignments

use of org.kie.api.task.model.PeopleAssignments in project jbpm by kiegroup.

the class PeopleAssignmentHelperTest method testAssignGroups.

@Test
public void testAssignGroups() {
    String groupId = "Software Developers, Project Managers";
    Task task = TaskModelProvider.getFactory().newTask();
    PeopleAssignments peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter(PeopleAssignmentHelper.GROUP_ID, groupId);
    peopleAssignmentHelper.assignGroups(workItem, peopleAssignments);
    OrganizationalEntity organizationalEntity1 = peopleAssignments.getPotentialOwners().get(0);
    assertTrue(organizationalEntity1 instanceof Group);
    assertEquals("Software Developers", organizationalEntity1.getId());
    OrganizationalEntity organizationalEntity2 = peopleAssignments.getPotentialOwners().get(1);
    assertTrue(organizationalEntity2 instanceof Group);
    assertEquals("Project Managers", organizationalEntity2.getId());
}
Also used : Group(org.kie.api.task.model.Group) Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) PeopleAssignments(org.kie.api.task.model.PeopleAssignments) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 4 with PeopleAssignments

use of org.kie.api.task.model.PeopleAssignments in project jbpm by kiegroup.

the class PeopleAssignmentHelperTest method testAssignActorsWithCustomSeparatorViaSysProp.

@Test
public void testAssignActorsWithCustomSeparatorViaSysProp() {
    System.setProperty("org.jbpm.ht.user.separator", ";");
    peopleAssignmentHelper = new PeopleAssignmentHelper();
    String actorId = "user1;user2";
    Task task = TaskModelProvider.getFactory().newTask();
    InternalTaskData taskData = (InternalTaskData) TaskModelProvider.getFactory().newTaskData();
    PeopleAssignments peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, actorId);
    peopleAssignmentHelper.assignActors(workItem, peopleAssignments, taskData);
    OrganizationalEntity organizationalEntity1 = peopleAssignments.getPotentialOwners().get(0);
    assertTrue(organizationalEntity1 instanceof User);
    assertEquals("user1", organizationalEntity1.getId());
    assertEquals("user1", taskData.getCreatedBy().getId());
    OrganizationalEntity organizationalEntity2 = peopleAssignments.getPotentialOwners().get(1);
    assertTrue(organizationalEntity2 instanceof User);
    assertEquals("user2", organizationalEntity2.getId());
    workItem = new WorkItemImpl();
    peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, actorId + "; drbug  ");
    peopleAssignmentHelper.assignActors(workItem, peopleAssignments, taskData);
    assertEquals(3, peopleAssignments.getPotentialOwners().size());
    organizationalEntity1 = peopleAssignments.getPotentialOwners().get(0);
    assertEquals("user1", organizationalEntity1.getId());
    assertEquals("user1", taskData.getCreatedBy().getId());
    organizationalEntity2 = peopleAssignments.getPotentialOwners().get(1);
    assertTrue(organizationalEntity2 instanceof User);
    assertEquals("user2", organizationalEntity2.getId());
    OrganizationalEntity organizationalEntity3 = peopleAssignments.getPotentialOwners().get(2);
    assertEquals("drbug", organizationalEntity3.getId());
    workItem = new WorkItemImpl();
    peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, "");
    peopleAssignmentHelper.assignActors(workItem, peopleAssignments, taskData);
    assertEquals(0, peopleAssignments.getPotentialOwners().size());
    System.clearProperty("org.jbpm.ht.user.separator");
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) PeopleAssignments(org.kie.api.task.model.PeopleAssignments) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 5 with PeopleAssignments

use of org.kie.api.task.model.PeopleAssignments in project jbpm by kiegroup.

the class PeopleAssignmentHelperTest method testAssignBusinessAdministratorGroups.

@Test
public void testAssignBusinessAdministratorGroups() {
    String businessAdministratorGroupId = "Super users";
    Task task = TaskModelProvider.getFactory().newTask();
    PeopleAssignments peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter(PeopleAssignmentHelper.BUSINESSADMINISTRATOR_GROUP_ID, businessAdministratorGroupId);
    peopleAssignmentHelper.assignBusinessAdministrators(workItem, peopleAssignments);
    assertEquals(3, peopleAssignments.getBusinessAdministrators().size());
    OrganizationalEntity organizationalEntity1 = peopleAssignments.getBusinessAdministrators().get(0);
    assertTrue(organizationalEntity1 instanceof User);
    assertEquals("Administrator", organizationalEntity1.getId());
    OrganizationalEntity organizationalEntity2 = peopleAssignments.getBusinessAdministrators().get(1);
    assertTrue(organizationalEntity2 instanceof Group);
    assertEquals("Administrators", organizationalEntity2.getId());
    OrganizationalEntity organizationalEntity3 = peopleAssignments.getBusinessAdministrators().get(2);
    assertTrue(organizationalEntity3 instanceof Group);
    assertEquals(businessAdministratorGroupId, organizationalEntity3.getId());
}
Also used : Group(org.kie.api.task.model.Group) Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) PeopleAssignments(org.kie.api.task.model.PeopleAssignments) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Aggregations

OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)9 PeopleAssignments (org.kie.api.task.model.PeopleAssignments)9 WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)8 User (org.kie.api.task.model.User)8 InternalPeopleAssignments (org.kie.internal.task.api.model.InternalPeopleAssignments)8 InternalTask (org.kie.internal.task.api.model.InternalTask)8 WorkItem (org.drools.core.process.instance.WorkItem)7 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)7 Test (org.junit.Test)7 Task (org.kie.api.task.model.Task)7 InternalTaskData (org.kie.internal.task.api.model.InternalTaskData)5 Group (org.kie.api.task.model.Group)4 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 ClassObjectFilter (org.drools.core.ClassObjectFilter)1 PeopleAssignmentHelper (org.jbpm.services.task.wih.util.PeopleAssignmentHelper)1 KieSession (org.kie.api.runtime.KieSession)1 CaseData (org.kie.api.runtime.process.CaseData)1