use of org.kie.internal.task.api.AuditTask in project jbpm by kiegroup.
the class TaskAuditBaseTest method testLifeCycleWithBAMEndWithExited.
@Test
public void testLifeCycleWithBAMEndWithExited() {
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<AuditTask> allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
taskService.release(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
// Go straight from Ready to Inprogress
taskService.start(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("InProgress", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "InProgress");
taskService.exit(taskId, "Administrator");
allGroupAuditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Exited", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Exited");
}
use of org.kie.internal.task.api.AuditTask in project jbpm by kiegroup.
the class TaskAuditBaseTest method testLifeCycleWithBAMEndWithObsolete.
@Test
public void testLifeCycleWithBAMEndWithObsolete() {
Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
((InternalTaskData) task.getTaskData()).setSkipable(true);
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<AuditTask> allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
taskService.release(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
// Go straight from Ready to Inprogress
taskService.start(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("InProgress", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "InProgress");
taskService.skip(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Obsolete", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Obsolete");
}
use of org.kie.internal.task.api.AuditTask in project jbpm by kiegroup.
the class TaskAuditBaseTest method assertAuditTaskInfo.
protected void assertAuditTaskInfo(String user, String status, Long taskId) {
List<AuditTask> allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser(user, new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals(status));
assertBAMTask(taskId, status);
}
use of org.kie.internal.task.api.AuditTask in project jbpm by kiegroup.
the class TaskAuditBaseTest method testExitAfterClaim.
@Test
public void testExitAfterClaim() {
// One potential owner, should go straight to state Reserved
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.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.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 testDueDateUpdate.
private void testDueDateUpdate(Date oldDate, Date newDate, boolean changeExpected) {
Task task = new TaskFluent().setDueDate(oldDate).setAdminUser("Administrator").getTask();
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
taskService.setExpirationDate(taskId, newDate);
task = taskService.getTaskById(taskId);
Assertions.assertThat(task.getTaskData().getExpirationTime()).isEqualTo(newDate);
List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
Assertions.assertThat(auditTasks).hasSize(1);
Assertions.assertThat(auditTasks.get(0).getDueDate()).isEqualTo(newDate);
List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
if (changeExpected) {
Assertions.assertThat(taskEvents).hasSize(2);
Assertions.assertThat(taskEvents.get(1).getMessage()).contains(String.valueOf(oldDate), String.valueOf(newDate));
} else {
Assertions.assertThat(taskEvents).hasSize(1);
}
}
Aggregations