use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method testRemoveExcludedOwners.
@Test
public void testRemoveExcludedOwners() {
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.release(task.getId(), "salaboy");
userTaskAdminService.addExcludedOwners(task.getId(), false, factory.newUser("salaboy"));
List<TaskEvent> events = runtimeDataService.getTaskEvents(task.getId(), new QueryFilter());
Assertions.assertThat(events).hasSize(3);
TaskEvent updatedEvent = events.get(2);
Assertions.assertThat(updatedEvent.getMessage()).isEqualTo("Excluded owners [salaboy] have been added");
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
Assertions.assertThat(tasks).hasSize(0);
userTaskAdminService.removeExcludedOwners(task.getId(), factory.newUser("salaboy"));
events = runtimeDataService.getTaskEvents(task.getId(), new QueryFilter());
Assertions.assertThat(events).hasSize(4);
updatedEvent = events.get(3);
Assertions.assertThat(updatedEvent.getMessage()).isEqualTo("Excluded owners [salaboy] have been removed");
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
Assertions.assertThat(tasks).hasSize(1);
}
use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.
the class RuntimeDataServiceImpl method getTaskEvents.
public List<TaskEvent> getTaskEvents(long taskId, QueryFilter filter) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("taskId", taskId);
applyQueryContext(params, filter);
applyQueryFilter(params, filter);
List<TaskEvent> taskEvents = commandService.execute(new QueryNameCommand<List<TaskEvent>>("getAllTasksEvents", params));
if (taskEvents == null || taskEvents.isEmpty()) {
UserTaskInstanceDesc task = getTaskById(taskId);
if (task == null) {
throw new TaskNotFoundException(MessageFormat.format(TASK_NOT_FOUND, taskId));
}
}
return taskEvents;
}
use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.
the class RuntimeDataServiceEJBIntegrationTest method testGetTaskEvents.
@Test
public void testGetTaskEvents() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance instance = processService.getProcessInstance(processInstanceId);
assertNotNull(instance);
Collection<NodeInstance> activeNodes = ((WorkflowProcessInstanceImpl) instance).getNodeInstances();
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
NodeInstance node = activeNodes.iterator().next();
assertNotNull(node);
assertTrue(node instanceof WorkItemNodeInstance);
Long workItemId = ((WorkItemNodeInstance) node).getWorkItemId();
assertNotNull(workItemId);
UserTaskInstanceDesc userTask = runtimeDataService.getTaskByWorkItemId(workItemId);
assertNotNull(userTask);
List<TaskEvent> auditTasks = runtimeDataService.getTaskEvents(userTask.getTaskId(), new QueryFilter());
assertNotNull(auditTasks);
assertEquals(1, auditTasks.size());
assertEquals(TaskEvent.TaskEventType.ADDED, auditTasks.get(0).getType());
userTaskService.start(userTask.getTaskId(), "salaboy");
auditTasks = runtimeDataService.getTaskEvents(userTask.getTaskId(), new QueryFilter());
assertNotNull(auditTasks);
assertEquals(2, auditTasks.size());
assertEquals(TaskEvent.TaskEventType.ADDED, auditTasks.get(0).getType());
assertEquals(TaskEvent.TaskEventType.STARTED, auditTasks.get(1).getType());
}
Aggregations