diff --git a/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/jobs/HistoryCleanupJob.java b/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/jobs/HistoryCleanupJob.java index 4c58490f14..75e9ec7d74 100644 --- a/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/jobs/HistoryCleanupJob.java +++ b/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/jobs/HistoryCleanupJob.java @@ -72,7 +72,8 @@ public void execute() { .eventTypeIn( TaskHistoryEventType.COMPLETED.getName(), TaskHistoryEventType.CANCELLED.getName(), - TaskHistoryEventType.TERMINATED.getName()) + TaskHistoryEventType.TERMINATED.getName(), + TaskHistoryEventType.DELETED.getName()) .list(); Set taskIdsToDeleteHistoryEventsFor; diff --git a/lib/taskana-core-test/src/test/java/acceptance/jobs/HistoryCleanupJobAccTest.java b/lib/taskana-core-test/src/test/java/acceptance/jobs/HistoryCleanupJobAccTest.java index 0031e78b82..15b76e9430 100644 --- a/lib/taskana-core-test/src/test/java/acceptance/jobs/HistoryCleanupJobAccTest.java +++ b/lib/taskana-core-test/src/test/java/acceptance/jobs/HistoryCleanupJobAccTest.java @@ -65,23 +65,18 @@ void after() throws Exception { void should_NotCleanHistoryEventsUntilDate_When_MinimumAgeNotReached() throws Exception { TaskHistoryEvent eventToBeCleaned = createTaskHistoryEvent( - "wbKey1", "taskId1", TaskHistoryEventType.CREATED.getName(), - "wbKey2", "someUserId", - "someDetails", Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned); TaskHistoryEvent eventToBeCleaned2 = createTaskHistoryEvent( - "wbKey1", "taskId1", TaskHistoryEventType.COMPLETED.getName(), - "wbKey2", "someUserId", - "someDetails", + Instant.now().minus(5, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned2); @@ -93,22 +88,16 @@ void should_NotCleanHistoryEventsUntilDate_When_MinimumAgeNotReached() throws Ex } private TaskHistoryEvent createTaskHistoryEvent( - String workbasketKey, String taskId, String type, - String previousWorkbasketId, String userid, - String details, Instant created, String parentBusinessProcessId) { TaskHistoryEvent historyEvent = new TaskHistoryEvent(); historyEvent.setId(IdGenerator.generateWithPrefix(IdGenerator.ID_PREFIX_TASK_HISTORY_EVENT)); historyEvent.setUserId(userid); - historyEvent.setDetails(details); - historyEvent.setWorkbasketKey(workbasketKey); historyEvent.setTaskId(taskId); historyEvent.setEventType(type); - historyEvent.setOldValue(previousWorkbasketId); historyEvent.setCreated(created); historyEvent.setParentBusinessProcessId(parentBusinessProcessId); return historyEvent; @@ -140,49 +129,69 @@ void should_CleanHistoryEventsUntilDate_When_SameParentBusinessTrueAndEventsQual TaskHistoryEvent eventToBeCleaned = createTaskHistoryEvent( - "wbKey1", "taskId1", TaskHistoryEventType.CREATED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned); TaskHistoryEvent eventToBeCleaned2 = createTaskHistoryEvent( - "wbKey1", + "taskId1", TaskHistoryEventType.COMPLETED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned2); TaskHistoryEvent eventToBeCleaned3 = createTaskHistoryEvent( - "wbKey1", + "taskId2", TaskHistoryEventType.CREATED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned3); TaskHistoryEvent eventToBeCleaned4 = createTaskHistoryEvent( - "wbKey1", + "taskId2", TaskHistoryEventType.CANCELLED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned4); - + TaskHistoryEvent eventToBeCleaned5 = + createTaskHistoryEvent( + + "taskId3", + TaskHistoryEventType.CREATED.getName(), + + "someUserId", + + Instant.now().minus(20, ChronoUnit.DAYS), + "sameParentId"); + historyService.create(eventToBeCleaned5); + TaskHistoryEvent eventToBeCleaned6 = + createTaskHistoryEvent( + + "taskId3", + TaskHistoryEventType.DELETED.getName(), + + "someUserId", + + Instant.now().minus(20, ChronoUnit.DAYS), + "sameParentId"); + historyService.create(eventToBeCleaned6); HistoryCleanupJob job = new HistoryCleanupJob(taskanaEngine, null, null); job.run(); @@ -196,34 +205,34 @@ void should_NotCleanHistoryEvents_When_SameParentBusinessTrueAndActiveTaskInPare TaskHistoryEvent eventToBeCleaned = createTaskHistoryEvent( - "wbKey1", + "taskId1", TaskHistoryEventType.CREATED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned); TaskHistoryEvent eventToBeCleaned2 = createTaskHistoryEvent( - "wbKey1", + "taskId1", TaskHistoryEventType.COMPLETED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned2); TaskHistoryEvent eventToBeCleaned3 = createTaskHistoryEvent( - "wbKey1", + "taskId2", TaskHistoryEventType.CREATED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(1, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned3); @@ -241,45 +250,45 @@ void should_NotCleanHistoryEvents_When_SameParentBusinessTrueAndActiveTaskInPare throws Exception { TaskHistoryEvent eventToBeCleaned = createTaskHistoryEvent( - "wbKey1", + "taskId1", TaskHistoryEventType.CREATED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned); TaskHistoryEvent eventToBeCleaned2 = createTaskHistoryEvent( - "wbKey1", + "taskId1", TaskHistoryEventType.COMPLETED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned2); TaskHistoryEvent eventToBeCleaned3 = createTaskHistoryEvent( - "wbKey1", + "taskId2", TaskHistoryEventType.CREATED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(3, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned3); TaskHistoryEvent eventToBeCleaned4 = createTaskHistoryEvent( - "wbKey1", + "taskId2", TaskHistoryEventType.CANCELLED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(5, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned4); @@ -296,34 +305,34 @@ void should_NotCleanEvents_When_NoCreatedEventsForParentBusinessProcessIdExist() throws Exception { TaskHistoryEvent toBeIgnored1 = createTaskHistoryEvent( - "wbKey1", + "taskId1", TaskHistoryEventType.CANCELLED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "toBeIgnored1"); historyService.create(toBeIgnored1); TaskHistoryEvent toBeIgnored2 = createTaskHistoryEvent( - "wbKey1", + "taskId2", TaskHistoryEventType.COMPLETED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "toBeIgnored2"); historyService.create(toBeIgnored2); TaskHistoryEvent toBeIgnored3 = createTaskHistoryEvent( - "wbKey1", + "taskId3", TaskHistoryEventType.TERMINATED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "toBeIgnored3"); historyService.create(toBeIgnored3); @@ -355,12 +364,12 @@ void should_NotCleanEvents_When_NoCreatedEventsForParentBusinessProcessIdExist() .map( pair -> createTaskHistoryEvent( - "wbKey1", + pair.getLeft(), pair.getRight().getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), parentBusinessId)) .toList(); @@ -406,45 +415,45 @@ void setup() throws Exception { void should_CleanHistoryEventsUntilDate_When_SameParentBusinessFalse() throws Exception { TaskHistoryEvent eventToBeCleaned = createTaskHistoryEvent( - "wbKey1", + "taskId1", TaskHistoryEventType.CREATED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned); TaskHistoryEvent eventToBeCleaned2 = createTaskHistoryEvent( - "wbKey1", + "taskId1", TaskHistoryEventType.COMPLETED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned2); TaskHistoryEvent eventToBeCleaned3 = createTaskHistoryEvent( - "wbKey1", + "taskId2", TaskHistoryEventType.CREATED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(20, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned3); TaskHistoryEvent eventToBeCleaned4 = createTaskHistoryEvent( - "wbKey1", + "taskId2", TaskHistoryEventType.TERMINATED.getName(), - "wbKey2", + "someUserId", - "someDetails", + Instant.now().minus(5, ChronoUnit.DAYS), "sameParentId"); historyService.create(eventToBeCleaned4);