Search in sources :

Example 6 with TaskEvent

use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.

the class UserTaskAdminServiceImplTest method testRemovePotentialOwners.

@Test
public void testRemovePotentialOwners() {
    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.removePotentialOwners(task.getId(), 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("Potential owners [salaboy] have been removed");
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(0);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) TaskEvent(org.kie.internal.task.api.model.TaskEvent) KModuleDeploymentServiceTest(org.jbpm.kie.services.test.KModuleDeploymentServiceTest) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 7 with TaskEvent

use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.

the class TaskAuditBaseTest method testLifeCycleWithBAM.

@Test
public void testLifeCycleWithBAM() {
    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.stop(taskId, "Darth Vader");
    allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
    ;
    assertEquals(1, allGroupAuditTasks.size());
    assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
    assertBAMTask(taskId, "Reserved");
    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");
    // Check is Complete
    taskService.complete(taskId, "Darth Vader", null);
    allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
    ;
    assertEquals(1, allGroupAuditTasks.size());
    assertEquals("Completed", allGroupAuditTasks.get(0).getStatus());
    assertBAMTask(taskId, "Completed");
    List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
    Assertions.assertThat(taskEvents).hasSize(8);
    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.RELEASED);
    Assertions.assertThat(taskEvents.get(2).getUserId()).isEqualTo("Darth Vader");
    Assertions.assertThat(taskEvents.get(3).getType()).isEqualTo(TaskEventType.CLAIMED);
    Assertions.assertThat(taskEvents.get(3).getUserId()).isEqualTo("Darth Vader");
    Assertions.assertThat(taskEvents.get(4).getType()).isEqualTo(TaskEventType.STARTED);
    Assertions.assertThat(taskEvents.get(4).getUserId()).isEqualTo("Darth Vader");
    Assertions.assertThat(taskEvents.get(5).getType()).isEqualTo(TaskEventType.STOPPED);
    Assertions.assertThat(taskEvents.get(5).getUserId()).isEqualTo("Darth Vader");
    Assertions.assertThat(taskEvents.get(6).getType()).isEqualTo(TaskEventType.STARTED);
    Assertions.assertThat(taskEvents.get(6).getUserId()).isEqualTo("Darth Vader");
    Assertions.assertThat(taskEvents.get(7).getType()).isEqualTo(TaskEventType.COMPLETED);
    Assertions.assertThat(taskEvents.get(7).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) TaskEvent(org.kie.internal.task.api.model.TaskEvent) AuditTask(org.kie.internal.task.api.AuditTask) HumanTaskServicesBaseTest(org.jbpm.services.task.HumanTaskServicesBaseTest) Test(org.junit.Test)

Example 8 with TaskEvent

use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.

the class TaskAuditBaseTest method testNameUpdate.

private void testNameUpdate(String oldName, String newName, boolean changeExpected) {
    Task task = new TaskFluent().setName(oldName).setAdminUser("Administrator").getTask();
    taskService.addTask(task, new HashMap<String, Object>());
    long taskId = task.getId();
    List<I18NText> taskNames = new ArrayList<I18NText>();
    taskNames.add(new I18NTextImpl("", newName));
    taskService.setTaskNames(taskId, taskNames);
    task = taskService.getTaskById(taskId);
    Assertions.assertThat(task.getName()).isEqualTo(newName);
    List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
    Assertions.assertThat(auditTasks).hasSize(1);
    Assertions.assertThat(auditTasks.get(0).getName()).isEqualTo(newName);
    List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
    if (changeExpected) {
        Assertions.assertThat(taskEvents).hasSize(2);
        Assertions.assertThat(taskEvents.get(1).getMessage()).contains(String.valueOf(oldName), String.valueOf(newName));
    } else {
        Assertions.assertThat(taskEvents).hasSize(1);
    }
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) I18NText(org.kie.api.task.model.I18NText) TaskFluent(org.jbpm.services.task.utils.TaskFluent) ArrayList(java.util.ArrayList) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) I18NTextImpl(org.jbpm.services.task.impl.model.I18NTextImpl) TaskEvent(org.kie.internal.task.api.model.TaskEvent)

Example 9 with TaskEvent

use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.

the class TaskAuditBaseTest method testDescriptionUpdate.

private void testDescriptionUpdate(String oldDescription, String newDescription, boolean changeExpected) {
    Task task = new TaskFluent().setDescription(oldDescription).setAdminUser("Administrator").getTask();
    taskService.addTask(task, new HashMap<String, Object>());
    long taskId = task.getId();
    List<I18NText> descriptions = new ArrayList<I18NText>();
    descriptions.add(new I18NTextImpl("", newDescription));
    taskService.setDescriptions(taskId, descriptions);
    task = taskService.getTaskById(taskId);
    Assertions.assertThat(task.getDescription()).isEqualTo(newDescription);
    List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
    Assertions.assertThat(auditTasks).hasSize(1);
    Assertions.assertThat(auditTasks.get(0).getDescription()).isEqualTo(newDescription);
    List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
    if (changeExpected) {
        Assertions.assertThat(taskEvents).hasSize(2);
        Assertions.assertThat(taskEvents.get(1).getMessage()).contains(String.valueOf(oldDescription), String.valueOf(newDescription));
    } else {
        Assertions.assertThat(taskEvents).hasSize(1);
    }
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) I18NText(org.kie.api.task.model.I18NText) TaskFluent(org.jbpm.services.task.utils.TaskFluent) ArrayList(java.util.ArrayList) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) I18NTextImpl(org.jbpm.services.task.impl.model.I18NTextImpl) TaskEvent(org.kie.internal.task.api.model.TaskEvent)

Example 10 with TaskEvent

use of org.kie.internal.task.api.model.TaskEvent in project jbpm by kiegroup.

the class TaskAuditBaseTest method testPriorityUpdate.

private void testPriorityUpdate(int oldPriority, int newPriority, boolean changeExpected) {
    Task task = new TaskFluent().setPriority(oldPriority).setAdminUser("Administrator").getTask();
    taskService.addTask(task, new HashMap<String, Object>());
    long taskId = task.getId();
    taskService.setPriority(taskId, newPriority);
    task = taskService.getTaskById(taskId);
    Assertions.assertThat(task.getPriority()).isEqualTo(newPriority);
    List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
    Assertions.assertThat(auditTasks).hasSize(1);
    Assertions.assertThat(auditTasks.get(0).getPriority()).isEqualTo(newPriority);
    List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
    if (changeExpected) {
        Assertions.assertThat(taskEvents).hasSize(2);
        Assertions.assertThat(taskEvents.get(1).getMessage()).contains(String.valueOf(oldPriority), String.valueOf(newPriority));
    } 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

TaskEvent (org.kie.internal.task.api.model.TaskEvent)18 QueryFilter (org.kie.internal.query.QueryFilter)17 Test (org.junit.Test)13 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)8 TaskFluent (org.jbpm.services.task.utils.TaskFluent)8 Task (org.kie.api.task.model.Task)8 AuditTask (org.kie.internal.task.api.AuditTask)8 TaskSummary (org.kie.api.task.model.TaskSummary)7 KModuleDeploymentServiceTest (org.jbpm.kie.services.test.KModuleDeploymentServiceTest)6 HumanTaskServicesBaseTest (org.jbpm.services.task.HumanTaskServicesBaseTest)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)3 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)3 I18NTextImpl (org.jbpm.services.task.impl.model.I18NTextImpl)2 WorkflowProcessInstanceImpl (org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl)2 WorkItemNodeInstance (org.jbpm.workflow.instance.node.WorkItemNodeInstance)2 NodeInstance (org.kie.api.runtime.process.NodeInstance)2 I18NText (org.kie.api.task.model.I18NText)2 Date (java.util.Date)1