-
Notifications
You must be signed in to change notification settings - Fork 104
Closes #2378 - Add DeleteHistoryEvent for Task #2380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
...rovider/src/test/java/acceptance/events/task/CreateHistoryEventOnTaskDeletionAccTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| package acceptance.events.task; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import java.util.List; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.extension.ExtendWith; | ||
| import pro.taskana.classification.api.ClassificationService; | ||
| import pro.taskana.classification.api.models.ClassificationSummary; | ||
| import pro.taskana.common.api.TaskanaEngine; | ||
| import pro.taskana.common.test.security.JaasExtension; | ||
| import pro.taskana.common.test.security.WithAccessId; | ||
| import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl; | ||
| import pro.taskana.spi.history.api.TaskanaHistory; | ||
| import pro.taskana.spi.history.api.events.task.TaskHistoryEvent; | ||
| import pro.taskana.spi.history.api.events.task.TaskHistoryEventType; | ||
| import pro.taskana.task.api.TaskService; | ||
| import pro.taskana.task.api.TaskState; | ||
| import pro.taskana.task.api.models.Task; | ||
| import pro.taskana.testapi.DefaultTestEntities; | ||
| import pro.taskana.testapi.TaskanaInject; | ||
| import pro.taskana.testapi.TaskanaIntegrationTest; | ||
| import pro.taskana.testapi.WithServiceProvider; | ||
| import pro.taskana.testapi.builder.TaskBuilder; | ||
| import pro.taskana.workbasket.api.WorkbasketService; | ||
| import pro.taskana.workbasket.api.models.WorkbasketSummary; | ||
|
|
||
| @WithServiceProvider( | ||
| serviceProviderInterface = TaskanaHistory.class, | ||
| serviceProviders = SimpleHistoryServiceImpl.class) | ||
| @TaskanaIntegrationTest | ||
| @ExtendWith(JaasExtension.class) | ||
| class CreateHistoryEventOnTaskDeletionAccTest { | ||
| @TaskanaInject TaskanaEngine taskanaEngine; | ||
| @TaskanaInject TaskService taskService; | ||
| @TaskanaInject WorkbasketService workbasketService; | ||
| @TaskanaInject ClassificationService classificationService; | ||
| ClassificationSummary defaultClassificationSummary; | ||
| WorkbasketSummary defaultWorkbasketSummary; | ||
| Task task1; | ||
| Task task2; | ||
| Task task3; | ||
| Task task4; | ||
| SimpleHistoryServiceImpl historyService; | ||
|
|
||
| @WithAccessId(user = "admin") | ||
| @BeforeAll | ||
| void setUp() throws Exception { | ||
| historyService = new SimpleHistoryServiceImpl(); | ||
| historyService.initialize(taskanaEngine); | ||
|
|
||
| defaultClassificationSummary = | ||
| DefaultTestEntities.defaultTestClassification() | ||
| .buildAndStoreAsSummary(classificationService); | ||
| defaultWorkbasketSummary = | ||
| DefaultTestEntities.defaultTestWorkbasket().buildAndStoreAsSummary(workbasketService); | ||
|
|
||
| task1 = createTask().buildAndStore(taskService); | ||
| task2 = createTask().state(TaskState.COMPLETED).buildAndStore(taskService); | ||
| task3 = createTask().state(TaskState.COMPLETED).buildAndStore(taskService); | ||
| task4 = createTask().state(TaskState.COMPLETED).buildAndStore(taskService); | ||
| } | ||
|
|
||
| @WithAccessId(user = "admin") | ||
| @Test | ||
| void should_CreateDeleteHistoryEvent_When_TaskIsDeleted() throws Exception { | ||
ryzheboka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| historyService.deleteHistoryEventsByTaskIds(List.of(task4.getId())); | ||
|
|
||
| taskService.deleteTask(task4.getId()); | ||
|
|
||
| List<TaskHistoryEvent> events = | ||
ryzheboka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| historyService.createTaskHistoryQuery().taskIdIn(task4.getId()).list(); | ||
| assertThat(events).hasSize(1); | ||
| assertDeleteHistoryEvent(events.get(0).getId(), "admin", task4.getId()); | ||
| } | ||
|
|
||
| @WithAccessId(user = "admin") | ||
| @Test | ||
| void should_CreateDeleteHistoryEvent_When_TaskIsForceDeleted() throws Exception { | ||
| historyService.deleteHistoryEventsByTaskIds(List.of(task1.getId())); | ||
|
|
||
| taskService.forceDeleteTask(task1.getId()); | ||
|
|
||
| List<TaskHistoryEvent> events = | ||
| historyService.createTaskHistoryQuery().taskIdIn(task1.getId()).list(); | ||
| assertThat(events).hasSize(1); | ||
| assertDeleteHistoryEvent(events.get(0).getId(), "admin", task1.getId()); | ||
| } | ||
|
|
||
| @WithAccessId(user = "admin") | ||
| @Test | ||
| void should_CreateDeleteHistoryEvents_When_MultipleTasksAreDeleted() throws Exception { | ||
| List<String> taskIds = List.of(task2.getId(), task3.getId()); | ||
| historyService.deleteHistoryEventsByTaskIds(taskIds); | ||
|
|
||
| taskService.deleteTasks(taskIds); | ||
|
|
||
| TaskHistoryEvent eventTask2 = | ||
| historyService.createTaskHistoryQuery().taskIdIn(task2.getId()).single(); | ||
| TaskHistoryEvent eventTask3 = | ||
| historyService.createTaskHistoryQuery().taskIdIn(task3.getId()).single(); | ||
| assertDeleteHistoryEvent(eventTask2.getId(), "admin", task2.getId()); | ||
| assertDeleteHistoryEvent(eventTask3.getId(), "admin", task3.getId()); | ||
| } | ||
|
|
||
| private void assertDeleteHistoryEvent(String eventId, String expectedUser, String taskId) | ||
| throws Exception { | ||
| TaskHistoryEvent event = historyService.getTaskHistoryEvent(eventId); | ||
| assertThat(event.getUserId()).isEqualTo(expectedUser); | ||
| assertThat(event.getEventType()).isEqualTo(TaskHistoryEventType.DELETED.getName()); | ||
| assertThat(event.getTaskId()).isEqualTo(taskId); | ||
| } | ||
|
|
||
| private TaskBuilder createTask() { | ||
| return TaskBuilder.newTask() | ||
| .classificationSummary(defaultClassificationSummary) | ||
| .workbasketSummary(defaultWorkbasketSummary) | ||
| .primaryObjRef(DefaultTestEntities.defaultTestObjectReference().build()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/TaskDeletedEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package pro.taskana.spi.history.api.events.task; | ||
|
|
||
| import java.time.Instant; | ||
| import pro.taskana.task.api.models.TaskSummary; | ||
|
|
||
| public class TaskDeletedEvent extends TaskHistoryEvent { | ||
|
|
||
| public TaskDeletedEvent( | ||
| String id, | ||
| TaskSummary taskSummary, | ||
| String taskId, | ||
| String userId) { | ||
| super(id, taskSummary, userId, null); | ||
| eventType = TaskHistoryEventType.DELETED.getName(); | ||
| created = Instant.now(); | ||
| super.taskId = taskId; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.