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);
}
}
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);
}
}
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);
}
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);
}
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;
}
Aggregations