Search in sources :

Example 56 with OrganizationalEntity

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

the class UserTaskAdminServiceImplTest method testNotifyNotCompleted.

@Test(timeout = 10000)
public void testNotifyNotCompleted() throws Exception {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    Assertions.assertThat(processInstanceId).isNotNull();
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    TaskSummary task = tasks.get(0);
    Collection<TaskNotification> notifications = userTaskAdminService.getTaskNotifications(task.getId(), false);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(0);
    userTaskService.start(task.getId(), "salaboy");
    List<OrganizationalEntity> recipients = new ArrayList<>();
    recipients.add(factory.newUser("john"));
    EmailNotification emailNotification = userTaskAdminService.buildEmailNotification("test", recipients, "Simple body", "Administrator", "");
    userTaskAdminService.notifyWhenNotCompleted(task.getId(), "2s", emailNotification);
    notifications = userTaskAdminService.getTaskNotifications(task.getId(), false);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(1);
    CountDownListenerFactory.getExistingTask("userTaskAdminService").waitTillCompleted();
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    notifications = userTaskAdminService.getTaskNotifications(task.getId(), true);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(0);
    notifications = userTaskAdminService.getTaskNotifications(task.getId(), false);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(1);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) TaskSummary(org.kie.api.task.model.TaskSummary) ArrayList(java.util.ArrayList) TaskNotification(org.jbpm.services.api.admin.TaskNotification) EmailNotification(org.kie.internal.task.api.model.EmailNotification) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 57 with OrganizationalEntity

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

the class UserTaskAdminServiceImplTest method testNotifyNotStartedAndCancel.

@Test(timeout = 10000)
public void testNotifyNotStartedAndCancel() throws Exception {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    Assertions.assertThat(processInstanceId).isNotNull();
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    TaskSummary task = tasks.get(0);
    Collection<TaskNotification> notifications = userTaskAdminService.getTaskNotifications(task.getId(), false);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(0);
    List<OrganizationalEntity> recipients = new ArrayList<>();
    recipients.add(factory.newUser("john"));
    EmailNotification emailNotification = userTaskAdminService.buildEmailNotification("test", recipients, "Simple body", "Administrator", "");
    long notificationId = userTaskAdminService.notifyWhenNotStarted(task.getId(), "2s", emailNotification);
    notifications = userTaskAdminService.getTaskNotifications(task.getId(), true);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(1);
    userTaskAdminService.cancelNotification(task.getId(), notificationId);
    notifications = userTaskAdminService.getTaskNotifications(task.getId(), true);
    Assertions.assertThat(notifications).isNotNull();
    Assertions.assertThat(notifications).hasSize(0);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) TaskSummary(org.kie.api.task.model.TaskSummary) ArrayList(java.util.ArrayList) TaskNotification(org.jbpm.services.api.admin.TaskNotification) EmailNotification(org.kie.internal.task.api.model.EmailNotification) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 58 with OrganizationalEntity

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

the class UserTaskAdminServiceImplTest method testNotifyNotStarted.

@Test(timeout = 10000)
public void testNotifyNotStarted() throws Exception {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    Assertions.assertThat(processInstanceId).isNotNull();
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
    TaskSummary task = tasks.get(0);
    List<OrganizationalEntity> recipients = new ArrayList<>();
    recipients.add(factory.newUser("john"));
    EmailNotification emailNotification = userTaskAdminService.buildEmailNotification("test", recipients, "Simple body", "Administrator", "");
    userTaskAdminService.notifyWhenNotStarted(task.getId(), "2s", emailNotification);
    CountDownListenerFactory.getExistingTask("userTaskAdminService").waitTillCompleted();
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) TaskSummary(org.kie.api.task.model.TaskSummary) ArrayList(java.util.ArrayList) EmailNotification(org.kie.internal.task.api.model.EmailNotification) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 59 with OrganizationalEntity

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

the class HumanTaskReassignmentTest method getTaskPotentialOwner.

private String getTaskPotentialOwner(long taskId) {
    Task task = taskService.getTaskById(taskId);
    assertNotNull(task);
    List<OrganizationalEntity> potentialOwners = task.getPeopleAssignments().getPotentialOwners();
    assertFalse(potentialOwners.isEmpty());
    return potentialOwners.get(0).getId();
}
Also used : Task(org.kie.api.task.model.Task) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity)

Example 60 with OrganizationalEntity

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

the class NonManagedLocalHTWorkItemHandler method abortWorkItem.

@Override
public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
    Task task = taskService.getTaskByWorkItemId(workItem.getId());
    if (task != null) {
        try {
            String adminUser = ADMIN_USER;
            List<OrganizationalEntity> businessAdmins = task.getPeopleAssignments().getBusinessAdministrators();
            for (OrganizationalEntity admin : businessAdmins) {
                if (admin instanceof Group) {
                    continue;
                }
                if (!admin.getId().equals(ADMIN_USER)) {
                    adminUser = admin.getId();
                    break;
                }
            }
            logger.debug("Task {} is going to be exited by {} who is business admin", task.getId(), adminUser);
            taskService.exit(task.getId(), adminUser);
        } catch (PermissionDeniedException e) {
            logger.info(e.getMessage());
        }
    }
}
Also used : Group(org.kie.api.task.model.Group) Task(org.kie.api.task.model.Task) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException)

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