Search in sources :

Example 16 with TaskEvent

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

the class UserTaskAdminServiceImplTest method testRemoveExcludedOwners.

@Test
public void testRemoveExcludedOwners() {
    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.addExcludedOwners(task.getId(), false, 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("Excluded owners [salaboy] have been added");
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(0);
    userTaskAdminService.removeExcludedOwners(task.getId(), factory.newUser("salaboy"));
    events = runtimeDataService.getTaskEvents(task.getId(), new QueryFilter());
    Assertions.assertThat(events).hasSize(4);
    updatedEvent = events.get(3);
    Assertions.assertThat(updatedEvent.getMessage()).isEqualTo("Excluded owners [salaboy] have been removed");
    tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
    Assertions.assertThat(tasks).hasSize(1);
}
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 17 with TaskEvent

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

the class RuntimeDataServiceImpl method getTaskEvents.

public List<TaskEvent> getTaskEvents(long taskId, QueryFilter filter) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("taskId", taskId);
    applyQueryContext(params, filter);
    applyQueryFilter(params, filter);
    List<TaskEvent> taskEvents = commandService.execute(new QueryNameCommand<List<TaskEvent>>("getAllTasksEvents", params));
    if (taskEvents == null || taskEvents.isEmpty()) {
        UserTaskInstanceDesc task = getTaskById(taskId);
        if (task == null) {
            throw new TaskNotFoundException(MessageFormat.format(TASK_NOT_FOUND, taskId));
        }
    }
    return taskEvents;
}
Also used : TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) HashMap(java.util.HashMap) TaskEvent(org.kie.internal.task.api.model.TaskEvent) List(java.util.List) ArrayList(java.util.ArrayList) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 18 with TaskEvent

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

the class RuntimeDataServiceEJBIntegrationTest method testGetTaskEvents.

@Test
public void testGetTaskEvents() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance instance = processService.getProcessInstance(processInstanceId);
    assertNotNull(instance);
    Collection<NodeInstance> activeNodes = ((WorkflowProcessInstanceImpl) instance).getNodeInstances();
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    NodeInstance node = activeNodes.iterator().next();
    assertNotNull(node);
    assertTrue(node instanceof WorkItemNodeInstance);
    Long workItemId = ((WorkItemNodeInstance) node).getWorkItemId();
    assertNotNull(workItemId);
    UserTaskInstanceDesc userTask = runtimeDataService.getTaskByWorkItemId(workItemId);
    assertNotNull(userTask);
    List<TaskEvent> auditTasks = runtimeDataService.getTaskEvents(userTask.getTaskId(), new QueryFilter());
    assertNotNull(auditTasks);
    assertEquals(1, auditTasks.size());
    assertEquals(TaskEvent.TaskEventType.ADDED, auditTasks.get(0).getType());
    userTaskService.start(userTask.getTaskId(), "salaboy");
    auditTasks = runtimeDataService.getTaskEvents(userTask.getTaskId(), new QueryFilter());
    assertNotNull(auditTasks);
    assertEquals(2, auditTasks.size());
    assertEquals(TaskEvent.TaskEventType.ADDED, auditTasks.get(0).getType());
    assertEquals(TaskEvent.TaskEventType.STARTED, auditTasks.get(1).getType());
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) TaskEvent(org.kie.internal.task.api.model.TaskEvent) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) NodeInstance(org.kie.api.runtime.process.NodeInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) Test(org.junit.Test)

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