Search in sources :

Example 6 with QueryFilter

use of org.kie.internal.query.QueryFilter 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());
}
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 7 with QueryFilter

use of org.kie.internal.query.QueryFilter 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 8 with QueryFilter

use of org.kie.internal.query.QueryFilter 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 9 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class TaskAuditBaseTest method testUpdateTaskContentEvents.

@Test
public void testUpdateTaskContentEvents() {
    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();
    assertAuditTaskInfoGroup("Knights Templer", "Ready", taskId);
    taskService.claim(taskId, "Darth Vader");
    assertAuditTaskInfo("Darth Vader", "Reserved", taskId);
    // Go straight from Ready to Inprogress
    taskService.start(taskId, "Darth Vader");
    assertAuditTaskInfo("Darth Vader", "InProgress", taskId);
    Map<String, Object> params = new HashMap<>();
    params.put("test", "value");
    taskService.addOutputContentFromUser(taskId, "Darth Vader", params);
    // Check is Complete
    params.clear();
    params.put("test", "updated");
    taskService.complete(taskId, "Darth Vader", params);
    assertAuditTaskInfo("Darth Vader", "Completed", taskId);
    List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
    Assertions.assertThat(taskEvents).hasSize(6);
    Assertions.assertThat(taskEvents.get(0).getType()).isEqualTo(TaskEventType.ADDED);
    Assertions.assertThat(taskEvents.get(0).getUserId()).isNull();
    Assertions.assertThat(taskEvents.get(1).getType()).isEqualTo(TaskEventType.CLAIMED);
    Assertions.assertThat(taskEvents.get(1).getUserId()).isEqualTo("Darth Vader");
    Assertions.assertThat(taskEvents.get(2).getType()).isEqualTo(TaskEventType.STARTED);
    Assertions.assertThat(taskEvents.get(2).getUserId()).isEqualTo("Darth Vader");
    // first update of data explicitly
    Assertions.assertThat(taskEvents.get(3).getType()).isEqualTo(TaskEventType.UPDATED);
    Assertions.assertThat(taskEvents.get(3).getUserId()).isEqualTo("Darth Vader");
    // next update of data through complete
    Assertions.assertThat(taskEvents.get(4).getType()).isEqualTo(TaskEventType.UPDATED);
    Assertions.assertThat(taskEvents.get(4).getUserId()).isEqualTo("Darth Vader");
    Assertions.assertThat(taskEvents.get(5).getType()).isEqualTo(TaskEventType.COMPLETED);
    Assertions.assertThat(taskEvents.get(5).getUserId()).isEqualTo("Darth Vader");
}
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) HashMap(java.util.HashMap) TaskEvent(org.kie.internal.task.api.model.TaskEvent) HumanTaskServicesBaseTest(org.jbpm.services.task.HumanTaskServicesBaseTest) Test(org.junit.Test)

Example 10 with QueryFilter

use of org.kie.internal.query.QueryFilter 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)

Aggregations

QueryFilter (org.kie.internal.query.QueryFilter)149 Test (org.junit.Test)127 TaskSummary (org.kie.api.task.model.TaskSummary)122 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)52 HashMap (java.util.HashMap)47 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)31 KModuleDeploymentServiceTest (org.jbpm.kie.services.test.KModuleDeploymentServiceTest)26 AuditTask (org.kie.internal.task.api.AuditTask)25 ArrayList (java.util.ArrayList)24 QueryContext (org.kie.api.runtime.query.QueryContext)24 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)23 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)21 Task (org.kie.api.task.model.Task)19 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)18 TaskFluent (org.jbpm.services.task.utils.TaskFluent)17 TaskEvent (org.kie.internal.task.api.model.TaskEvent)17 HumanTaskServicesBaseTest (org.jbpm.services.task.HumanTaskServicesBaseTest)14 Status (org.kie.api.task.model.Status)13 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)11 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)10