Search in sources :

Example 21 with AuditTask

use of org.kie.internal.task.api.AuditTask 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 22 with AuditTask

use of org.kie.internal.task.api.AuditTask 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)

Example 23 with AuditTask

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

the class TaskAuditBaseTest method assertAuditTaskInfoGroup.

protected void assertAuditTaskInfoGroup(String group, String status, Long taskId) {
    List<AuditTask> allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser(group, 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 24 with AuditTask

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

the class AuditTaskDeleteTest method testDeleteAuditTaskInfoLogByTimestamp.

@Test
public void testDeleteAuditTaskInfoLogByTimestamp() {
    List<AuditTask> tasks = this.auditTaskQuery().taskId(taskTestData[4].getId()).build().getResultList();
    assertEquals(1, tasks.size());
    AuditTaskDeleteBuilder updateBuilder = this.auditTaskDelete().date(tasks.get(0).getCreatedOn());
    int result = updateBuilder.build().execute();
    assertEquals(1, result);
}
Also used : AuditTaskDeleteBuilder(org.kie.internal.task.query.AuditTaskDeleteBuilder) AuditTask(org.kie.internal.task.api.AuditTask) Test(org.junit.Test)

Example 25 with AuditTask

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

the class GetAllAdminAuditTasksByUserCommand method execute.

@Override
public List<AuditTask> execute(Context context) {
    TaskPersistenceContext persistenceContext = ((TaskContext) context).getPersistenceContext();
    boolean userExists = doCallbackUserOperation(userId, (TaskContext) context);
    List<String> groupIds = doUserGroupCallbackOperation(userId, null, (TaskContext) context);
    // Adding the user to check for groups and user as Business Administrators
    groupIds.add(userId);
    List<AuditTask> groupTasks = persistenceContext.queryWithParametersInTransaction("getAllAdminAuditTasksByUser", persistenceContext.addParametersToMap("businessAdmins", groupIds, "firstResult", filter.getOffset(), "maxResults", filter.getCount()), ClassUtil.<List<AuditTask>>castClass(List.class));
    return groupTasks;
}
Also used : TaskContext(org.kie.internal.task.api.TaskContext) List(java.util.List) TaskPersistenceContext(org.kie.internal.task.api.TaskPersistenceContext) 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