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);
}
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);
}
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);
}
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();
}
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());
}
}
}
Aggregations