Search in sources :

Example 6 with AuditTask

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");
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) TaskFluent(org.jbpm.services.task.utils.TaskFluent) AuditTask(org.kie.internal.task.api.AuditTask) HumanTaskServicesBaseTest(org.jbpm.services.task.HumanTaskServicesBaseTest) Test(org.junit.Test)

Example 7 with AuditTask

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");
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) TaskFluent(org.jbpm.services.task.utils.TaskFluent) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) AuditTask(org.kie.internal.task.api.AuditTask) HumanTaskServicesBaseTest(org.jbpm.services.task.HumanTaskServicesBaseTest) Test(org.junit.Test)

Example 8 with AuditTask

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);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) AuditTask(org.kie.internal.task.api.AuditTask)

Example 9 with AuditTask

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());
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) TaskFluent(org.jbpm.services.task.utils.TaskFluent) TaskSummary(org.kie.api.task.model.TaskSummary) AuditTask(org.kie.internal.task.api.AuditTask) HumanTaskServicesBaseTest(org.jbpm.services.task.HumanTaskServicesBaseTest) Test(org.junit.Test)

Example 10 with AuditTask

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);
    }
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) TaskFluent(org.jbpm.services.task.utils.TaskFluent) TaskEvent(org.kie.internal.task.api.model.TaskEvent) AuditTask(org.kie.internal.task.api.AuditTask)

Aggregations

AuditTask (org.kie.internal.task.api.AuditTask)28 QueryFilter (org.kie.internal.query.QueryFilter)23 Test (org.junit.Test)19 Task (org.kie.api.task.model.Task)16 TaskFluent (org.jbpm.services.task.utils.TaskFluent)15 HumanTaskServicesBaseTest (org.jbpm.services.task.HumanTaskServicesBaseTest)12 TaskSummary (org.kie.api.task.model.TaskSummary)7 TaskEvent (org.kie.internal.task.api.model.TaskEvent)6 ArrayList (java.util.ArrayList)5 List (java.util.List)4 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)4 HashMap (java.util.HashMap)3 WorkflowProcessInstanceImpl (org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl)3 WorkItemNodeInstance (org.jbpm.workflow.instance.node.WorkItemNodeInstance)3 NodeInstance (org.kie.api.runtime.process.NodeInstance)3 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)3 TaskContext (org.kie.internal.task.api.TaskContext)3 TaskPersistenceContext (org.kie.internal.task.api.TaskPersistenceContext)3 Date (java.util.Date)2 I18NTextImpl (org.jbpm.services.task.impl.model.I18NTextImpl)2