use of org.kie.internal.task.api.AuditTask in project jbpm by kiegroup.
the class LocalWithCustomCallbackTaskAuditTest method testGroupTasks.
@Test
public void testGroupTasks() {
Task task = new TaskFluent().setName("This is my task name").addPotentialUser("salaboy").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
List<TaskSummary> allGroupTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(1, allGroupTasks.size());
assertTrue(allGroupTasks.get(0).getStatusId().equals("Ready"));
List<AuditTask> allGroupAuditTasksByUser = taskAuditService.getAllGroupAuditTasksByUser("salaboy", new QueryFilter(0, 0));
assertEquals(1, allGroupAuditTasksByUser.size());
assertTrue(allGroupAuditTasksByUser.get(0).getStatus().equals("Ready"));
}
use of org.kie.internal.task.api.AuditTask in project jbpm by kiegroup.
the class TaskAuditBaseTest method testExitBeforeClaim.
@Test
public void testExitBeforeClaim() {
Task task = new TaskFluent().setName("This is my task name 2").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<TaskSummary> allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Ready"));
taskService.exit(taskId, "Administrator");
List<AuditTask> allHistoryAuditTasks = taskAuditService.getAllAuditTasks(new QueryFilter(0, 0));
assertEquals(1, allHistoryAuditTasks.size());
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(0, allGroupAuditTasks.size());
}
use of org.kie.internal.task.api.AuditTask in project jbpm by kiegroup.
the class TaskAuditBaseTest method testComplete.
@Test
public void testComplete() {
long initTimeMs = new Date().getTime();
Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<TaskSummary> allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Ready"));
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(0, allGroupAuditTasks.size());
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", null, null, null);
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Reserved"));
taskService.release(taskId, "Darth Vader");
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Ready"));
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(0, allGroupAuditTasks.size());
allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", null, null, null);
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Reserved"));
// Go straight from Ready to Inprogress
taskService.start(taskId, "Darth Vader");
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.InProgress, task1.getTaskData().getStatus());
assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId());
// Check is Complete
taskService.complete(taskId, "Darth Vader", null);
Task task2 = taskService.getTaskById(taskId);
assertEquals(Status.Completed, task2.getTaskData().getStatus());
assertEquals("Darth Vader", task2.getTaskData().getActualOwner().getId());
List<TaskEvent> allTaskEvents = taskService.execute(new GetAuditEventsCommand(taskId, new QueryFilter(0, 0)));
assertEquals(6, allTaskEvents.size());
// test DeleteAuditEventsCommand
int numFirstTaskEvents = allTaskEvents.size();
task = new TaskFluent().setName("This is my task name 2").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long secondTaskId = task.getId();
taskService.claim(secondTaskId, "Darth Vader");
taskService.start(secondTaskId, "Darth Vader");
taskService.complete(secondTaskId, "Darth Vader", null);
allTaskEvents = taskService.execute(new GetAuditEventsCommand());
int numTaskEvents = allTaskEvents.size();
assertTrue("Expected more than " + numFirstTaskEvents + " events: " + numTaskEvents, numTaskEvents > numFirstTaskEvents);
taskService.execute(new DeleteAuditEventsCommand(taskId));
allTaskEvents = taskService.execute(new GetAuditEventsCommand());
assertEquals(numTaskEvents - numFirstTaskEvents, allTaskEvents.size());
taskService.execute(new DeleteAuditEventsCommand());
allTaskEvents = taskService.execute(new GetAuditEventsCommand());
assertEquals(0, allTaskEvents.size());
// test get/delete BAM Task summaries commands
List<BAMTaskSummaryImpl> bamTaskList = taskService.execute(new GetBAMTaskSummariesCommand());
assertEquals("BAM Task Summary list size: ", 2, bamTaskList.size());
taskService.execute(new DeleteBAMTaskSummariesCommand(taskId));
bamTaskList = taskService.execute(new GetBAMTaskSummariesCommand());
assertEquals("BAM Task Summary list size after delete (task id: " + taskId + ") : ", 1, bamTaskList.size());
bamTaskList = taskService.execute(new GetBAMTaskSummariesCommand(secondTaskId));
assertEquals("BAM Task Summary list size after delete (task id: " + taskId + ") : ", 1, bamTaskList.size());
taskService.execute(new DeleteBAMTaskSummariesCommand());
bamTaskList = taskService.execute(new GetBAMTaskSummariesCommand());
assertEquals("BAM Task Summary list size after delete (task id: " + taskId + ") : ", 0, bamTaskList.size());
List<AuditTask> allHistoryAuditTasks = taskAuditService.getAllAuditTasks(new QueryFilter(0, 0));
assertEquals(2, allHistoryAuditTasks.size());
// test last modification date was generated
long currentTimeMs = new Date().getTime();
for (AuditTask at : allHistoryAuditTasks) {
Date modDate = ((AuditTaskImpl) at).getLastModificationDate();
assertNotNull(modDate);
long modDateMs = modDate.getTime();
assertTrue("Task " + at.getTaskId() + " modification date is not too much in the past", modDateMs >= initTimeMs);
assertTrue("Task " + at.getTaskId() + " modification date is not in the future", modDateMs <= currentTimeMs);
}
}
use of org.kie.internal.task.api.AuditTask in project jbpm by kiegroup.
the class TaskAuditBaseTest method testOnlyActiveTasks.
@Test
public void testOnlyActiveTasks() {
Task task = new TaskFluent().setName("This is my task name").addPotentialUser("salaboy").setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
List<TaskSummary> allActiveTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
assertEquals(1, allActiveTasks.size());
assertTrue(allActiveTasks.get(0).getStatusId().equals("Reserved"));
QueryFilter queryFilter = new QueryFilter(0, 0);
Map<String, Object> params = new HashMap<String, Object>();
List<String> statuses = new ArrayList<String>();
statuses.add(Status.Reserved.toString());
params.put("statuses", statuses);
queryFilter.setParams(params);
List<AuditTask> allActiveAuditTasksByUser = taskAuditService.getAllAuditTasksByStatus("salaboy", queryFilter);
assertEquals(1, allActiveAuditTasksByUser.size());
assertTrue(allActiveAuditTasksByUser.get(0).getStatus().equals("Reserved"));
statuses = new ArrayList<String>();
statuses.add(Status.Completed.toString());
params.put("statuses", statuses);
queryFilter.setParams(params);
allActiveAuditTasksByUser = taskAuditService.getAllAuditTasksByStatus("salaboy", queryFilter);
assertEquals(0, allActiveAuditTasksByUser.size());
}
use of org.kie.internal.task.api.AuditTask in project jbpm by kiegroup.
the class TaskAuditBaseTest method testAdminTasks.
@Test
public void testAdminTasks() {
Task task = new TaskFluent().setName("This is my task name").setAdminUser("salaboy").getTask();
taskService.addTask(task, new HashMap<String, Object>());
List<TaskSummary> allAdminTasks = taskService.getTasksAssignedAsBusinessAdministrator("salaboy", null);
assertEquals(1, allAdminTasks.size());
List<AuditTask> allAdminAuditTasksByUser = taskAuditService.getAllAdminAuditTasksByUser("salaboy", new QueryFilter(0, 0));
assertEquals(1, allAdminAuditTasksByUser.size());
}
Aggregations