use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest 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());
QueryFilter filter = new QueryFilter();
filter.setFilterParams("t.type = :type ");
filter.setParams(Collections.singletonMap("type", TaskEvent.TaskEventType.COMPLETED));
auditTasks = runtimeDataService.getTaskEvents(userTask.getTaskId(), filter);
assertNotNull(auditTasks);
assertEquals(0, auditTasks.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.
the class UserTaskServiceImplTest method testTaskOperationWithUserOrWithIdentityProvider.
@Test
public void testTaskOperationWithUserOrWithIdentityProvider() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance instance = processService.getProcessInstance(processInstanceId);
assertNotNull(instance);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(taskIds);
assertEquals(1, taskIds.size());
Long taskId = taskIds.get(0);
userTaskService.start(taskId, "salaboy");
List<TaskEvent> auditTasks = runtimeDataService.getTaskEvents(taskId, new QueryFilter());
assertNotNull(auditTasks);
assertEquals(2, auditTasks.size());
assertEquals(TaskEvent.TaskEventType.ADDED, auditTasks.get(0).getType());
assertEquals("org.jbpm.writedocument", auditTasks.get(0).getUserId());
assertEquals(TaskEvent.TaskEventType.STARTED, auditTasks.get(1).getType());
assertEquals("salaboy", auditTasks.get(1).getUserId());
identityProvider.setName("salaboy");
userTaskService.stop(taskId, null);
auditTasks = runtimeDataService.getTaskEvents(taskId, new QueryFilter());
assertNotNull(auditTasks);
assertEquals(3, auditTasks.size());
assertEquals(TaskEvent.TaskEventType.ADDED, auditTasks.get(0).getType());
assertEquals("org.jbpm.writedocument", auditTasks.get(0).getUserId());
assertEquals(TaskEvent.TaskEventType.STARTED, auditTasks.get(1).getType());
assertEquals("salaboy", auditTasks.get(1).getUserId());
assertEquals(TaskEvent.TaskEventType.STOPPED, auditTasks.get(2).getType());
assertEquals("salaboy", auditTasks.get(2).getUserId());
Map<String, Object> params = new HashMap<>();
params.put("test", "value");
userTaskService.saveContent(taskId, params);
auditTasks = runtimeDataService.getTaskEvents(taskId, new QueryFilter());
assertNotNull(auditTasks);
assertEquals(4, auditTasks.size());
assertEquals(TaskEvent.TaskEventType.ADDED, auditTasks.get(0).getType());
assertEquals("org.jbpm.writedocument", auditTasks.get(0).getUserId());
assertEquals(TaskEvent.TaskEventType.STARTED, auditTasks.get(1).getType());
assertEquals("salaboy", auditTasks.get(1).getUserId());
assertEquals(TaskEvent.TaskEventType.STOPPED, auditTasks.get(2).getType());
assertEquals("salaboy", auditTasks.get(2).getUserId());
assertEquals(TaskEvent.TaskEventType.UPDATED, auditTasks.get(3).getType());
assertEquals("salaboy", auditTasks.get(3).getUserId());
identityProvider.setName("testUser");
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method testAddBusinessAdmins.
@Test
public void testAddBusinessAdmins() {
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");
tasks = runtimeDataService.getTasksAssignedAsBusinessAdministrator("salaboy", new QueryFilter());
Assertions.assertThat(tasks).hasSize(0);
userTaskAdminService.addBusinessAdmins(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("Business administrators [salaboy] have been added");
tasks = runtimeDataService.getTasksAssignedAsBusinessAdministrator("salaboy", new QueryFilter());
Assertions.assertThat(tasks).hasSize(1);
tasks = runtimeDataService.getTasksAssignedAsBusinessAdministrator("Administrator", new QueryFilter());
Assertions.assertThat(tasks).hasSize(1);
userTaskAdminService.addBusinessAdmins(task.getId(), true, factory.newUser("salaboy"));
tasks = runtimeDataService.getTasksAssignedAsBusinessAdministrator("salaboy", new QueryFilter());
Assertions.assertThat(tasks).hasSize(1);
tasks = runtimeDataService.getTasksAssignedAsBusinessAdministrator("Administrator", new QueryFilter());
Assertions.assertThat(tasks).hasSize(0);
}
use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method testAddExcludedOwners.
@Test
public void testAddExcludedOwners() {
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);
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
Assertions.assertThat(tasks).hasSize(0);
userTaskAdminService.addExcludedOwners(task.getId(), true, factory.newUser("john"));
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
Assertions.assertThat(tasks).hasSize(1);
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
Assertions.assertThat(tasks).hasSize(0);
}
use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method testAddPotentialOwners.
@Test
public void testAddPotentialOwners() {
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.addPotentialOwners(task.getId(), false, factory.newUser("john"));
List<TaskEvent> events = runtimeDataService.getTaskEvents(task.getId(), new QueryFilter());
Assertions.assertThat(events).hasSize(3);
TaskEvent updatedEvent = events.get(2);
Assertions.assertThat(updatedEvent.getMessage()).isEqualTo("Potential owners [john] have been added");
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
Assertions.assertThat(tasks).hasSize(1);
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
Assertions.assertThat(tasks).hasSize(1);
userTaskAdminService.addPotentialOwners(task.getId(), true, factory.newUser("john"));
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
Assertions.assertThat(tasks).hasSize(0);
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
Assertions.assertThat(tasks).hasSize(1);
}
Aggregations