Search in sources :

Example 66 with OrganizationalEntity

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

the class PeopleAssignmentHelperTest method testAssignRecipients.

@Test
public void testAssignRecipients() {
    String recipientId = "espiegelberg";
    Task task = TaskModelProvider.getFactory().newTask();
    InternalPeopleAssignments peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter(PeopleAssignmentHelper.RECIPIENT_ID, recipientId);
    peopleAssignmentHelper.assignRecipients(workItem, peopleAssignments);
    assertEquals(1, peopleAssignments.getRecipients().size());
    OrganizationalEntity organizationalEntity1 = peopleAssignments.getRecipients().get(0);
    assertTrue(organizationalEntity1 instanceof User);
    assertEquals(recipientId, organizationalEntity1.getId());
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) 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) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 67 with OrganizationalEntity

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

the class PeopleAssignmentHelperTest method testAssignExcludedOwners.

@Test
public void testAssignExcludedOwners() {
    String excludedOwnerId = "espiegelberg";
    Task task = TaskModelProvider.getFactory().newTask();
    InternalPeopleAssignments peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter(PeopleAssignmentHelper.EXCLUDED_OWNER_ID, excludedOwnerId);
    peopleAssignmentHelper.assignExcludedOwners(workItem, peopleAssignments);
    assertEquals(1, peopleAssignments.getExcludedOwners().size());
    OrganizationalEntity organizationalEntity1 = peopleAssignments.getExcludedOwners().get(0);
    assertTrue(organizationalEntity1 instanceof User);
    assertEquals(excludedOwnerId, organizationalEntity1.getId());
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) 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) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 68 with OrganizationalEntity

use of org.kie.api.task.model.OrganizationalEntity 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 69 with OrganizationalEntity

use of org.kie.api.task.model.OrganizationalEntity 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)

Example 70 with OrganizationalEntity

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

the class PeopleAssignmentHelperTest method testAssignTaskstakeholders.

@Test
public void testAssignTaskstakeholders() {
    String taskStakeholderId = "espiegelberg";
    Task task = TaskModelProvider.getFactory().newTask();
    InternalPeopleAssignments peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter(PeopleAssignmentHelper.TASKSTAKEHOLDER_ID, taskStakeholderId);
    peopleAssignmentHelper.assignTaskStakeholders(workItem, peopleAssignments);
    assertEquals(1, peopleAssignments.getTaskStakeholders().size());
    OrganizationalEntity organizationalEntity1 = peopleAssignments.getTaskStakeholders().get(0);
    assertTrue(organizationalEntity1 instanceof User);
    assertEquals(taskStakeholderId, organizationalEntity1.getId());
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) 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) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Aggregations

OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)147 Test (org.junit.Test)94 HashMap (java.util.HashMap)69 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)55 ArrayList (java.util.ArrayList)54 User (org.kie.api.task.model.User)52 UserImpl (org.jbpm.services.task.impl.model.UserImpl)51 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)48 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)41 InternalPeopleAssignments (org.kie.internal.task.api.model.InternalPeopleAssignments)36 InternalTask (org.kie.internal.task.api.model.InternalTask)35 InternalOrganizationalEntity (org.kie.internal.task.api.model.InternalOrganizationalEntity)34 Task (org.kie.api.task.model.Task)33 QueryContext (org.kie.api.runtime.query.QueryContext)32 Group (org.kie.api.task.model.Group)29 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)26 TaskSummary (org.kie.api.task.model.TaskSummary)25 AdHocFragmentNotFoundException (org.jbpm.casemgmt.api.AdHocFragmentNotFoundException)24 CaseActiveException (org.jbpm.casemgmt.api.CaseActiveException)24 CaseCommentNotFoundException (org.jbpm.casemgmt.api.CaseCommentNotFoundException)24