@Test public void testDeleteTaskEventByDate() { kieSession = createKSession(HUMAN_TASK_MULTIACTORS); Date startDate = new Date(); processInstanceList = startProcess(kieSession, HUMAN_TASK_MULTIACTORS_ID, 1); // Get the task TaskService taskService = getRuntimeEngine().getTaskService(); Task task = taskService.getTaskById( taskService.getTasksByProcessInstanceId(processInstanceList.get(0).getId()).get(0)); Assertions.assertThat(task).isNotNull(); Assertions.assertThat(task.getTaskData().getStatus()).isEqualTo(Status.Ready); // Perform 2 operation on the task taskService.claim(task.getId(), "krisv"); taskService.start(task.getId(), "krisv"); taskService.complete(task.getId(), "krisv", null); // Remove the instance from the running list as it has ended already. processInstanceList.clear(); // Delete all task operation between dates int resultCount = taskAuditService .taskEventInstanceLogDelete() .dateRangeStart(startDate) .dateRangeEnd(new Date()) .build() .execute(); // Changes are as follows (see // https://docs.jboss.org/jbpm/v6.1/userguide/jBPMTaskService.html#jBPMTaskLifecycle): // 1) Created -> Ready (automatic change because there are multiple actors) // 2) Ready -> Reserved (by claim) // 3) Reserved -> In Progress (by start) // 4) In Progress -> Completed (by complete) Assertions.assertThat(resultCount).isEqualTo(4); }