use of org.jbpm.services.api.admin.TaskReassignment in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method testReassignNotStartedAndCancel.
@Test(timeout = 10000)
public void testReassignNotStartedAndCancel() 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<TaskReassignment> reassignments = userTaskAdminService.getTaskReassignments(task.getId(), false);
Assertions.assertThat(reassignments).isNotNull();
Assertions.assertThat(reassignments).hasSize(0);
Long reassignmentId = userTaskAdminService.reassignWhenNotStarted(task.getId(), "2s", factory.newUser("john"));
reassignments = userTaskAdminService.getTaskReassignments(task.getId(), true);
Assertions.assertThat(reassignments).isNotNull();
Assertions.assertThat(reassignments).hasSize(1);
userTaskAdminService.cancelReassignment(task.getId(), reassignmentId);
reassignments = userTaskAdminService.getTaskReassignments(task.getId(), true);
Assertions.assertThat(reassignments).isNotNull();
Assertions.assertThat(reassignments).hasSize(0);
}
use of org.jbpm.services.api.admin.TaskReassignment in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method testReassignNotCompleted.
@Test(timeout = 10000)
public void testReassignNotCompleted() 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);
userTaskService.start(task.getId(), "salaboy");
Collection<TaskReassignment> reassignments = userTaskAdminService.getTaskReassignments(task.getId(), false);
Assertions.assertThat(reassignments).isNotNull();
Assertions.assertThat(reassignments).hasSize(0);
userTaskAdminService.reassignWhenNotCompleted(task.getId(), "2s", factory.newUser("john"));
reassignments = userTaskAdminService.getTaskReassignments(task.getId(), true);
Assertions.assertThat(reassignments).isNotNull();
Assertions.assertThat(reassignments).hasSize(1);
CountDownListenerFactory.getExistingTask("userTaskAdminService").waitTillCompleted();
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
Assertions.assertThat(tasks).hasSize(0);
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
Assertions.assertThat(tasks).hasSize(1);
reassignments = userTaskAdminService.getTaskReassignments(task.getId(), true);
Assertions.assertThat(reassignments).isNotNull();
Assertions.assertThat(reassignments).hasSize(0);
reassignments = userTaskAdminService.getTaskReassignments(task.getId(), false);
Assertions.assertThat(reassignments).isNotNull();
Assertions.assertThat(reassignments).hasSize(1);
}
use of org.jbpm.services.api.admin.TaskReassignment in project jbpm by kiegroup.
the class ListTaskReassignmentsCommand method execute.
@Override
public List<TaskReassignment> execute(Context cntxt) {
TaskContext context = (TaskContext) cntxt;
Task task = context.getTaskQueryService().getTaskInstanceById(taskId);
if (!isBusinessAdmin(userId, task.getPeopleAssignments().getBusinessAdministrators(), context)) {
throw new PermissionDeniedException("User " + userId + " is not business admin of task " + taskId);
}
Deadlines deadlines = ((InternalTask) task).getDeadlines();
List<TaskReassignment> reassignmantsNotStarted = deadlines.getStartDeadlines().stream().filter(d -> !d.getEscalations().isEmpty() && !d.getEscalations().get(0).getReassignments().isEmpty()).map(d -> {
Reassignment r = d.getEscalations().get(0).getReassignments().get(0);
return new TaskReassignmentImpl(d.getId(), get(r.getDocumentation()), d.getDate(), r.getPotentialOwners(), !d.isEscalated());
}).collect(Collectors.toList());
List<TaskReassignment> reassignmantsNotCompleted = deadlines.getEndDeadlines().stream().filter(d -> !d.getEscalations().isEmpty() && !d.getEscalations().get(0).getReassignments().isEmpty()).map(d -> {
Reassignment r = d.getEscalations().get(0).getReassignments().get(0);
return new TaskReassignmentImpl(d.getId(), get(r.getDocumentation()), d.getDate(), r.getPotentialOwners(), !d.isEscalated());
}).collect(Collectors.toList());
List<TaskReassignment> result = new ArrayList<>();
result.addAll(reassignmantsNotStarted);
result.addAll(reassignmantsNotCompleted);
if (activeOnly) {
logger.debug("Removing already completed deadlines from the result");
result = result.stream().filter(t -> t.isActive()).collect(Collectors.toList());
}
return result;
}
use of org.jbpm.services.api.admin.TaskReassignment in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method testReassignNotCompletedInvalidOrgEntities.
@Test(timeout = 10000)
public void testReassignNotCompletedInvalidOrgEntities() 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);
userTaskService.start(task.getId(), "salaboy");
Collection<TaskReassignment> reassignments = userTaskAdminService.getTaskReassignments(task.getId(), false);
Assertions.assertThat(reassignments).isNotNull();
Assertions.assertThat(reassignments).hasSize(0);
Assertions.assertThatThrownBy(() -> {
userTaskAdminService.reassignWhenNotCompleted(task.getId(), "2s", null);
}).hasMessage("Invalid org entity");
}
use of org.jbpm.services.api.admin.TaskReassignment in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method testReassignNotCompletedInvalidTimeExpression.
@Test(timeout = 10000)
public void testReassignNotCompletedInvalidTimeExpression() 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);
userTaskService.start(task.getId(), "salaboy");
Collection<TaskReassignment> reassignments = userTaskAdminService.getTaskReassignments(task.getId(), false);
Assertions.assertThat(reassignments).isNotNull();
Assertions.assertThat(reassignments).hasSize(0);
Assertions.assertThatThrownBy(() -> {
userTaskAdminService.reassignWhenNotCompleted(task.getId(), "2ssssssss", factory.newUser("john"));
}).hasMessage("Error parsing time string: [ 2ssssssss ]");
Assertions.assertThatThrownBy(() -> {
userTaskAdminService.reassignWhenNotCompleted(task.getId(), null, factory.newUser("john"));
}).hasMessage("Invalid time expression");
Assertions.assertThatThrownBy(() -> {
userTaskAdminService.reassignWhenNotCompleted(task.getId(), "", factory.newUser("john"));
}).hasMessage("Invalid time expression");
}
Aggregations