Closes #2364 - Add Rerouting of Tasks in JAVA-API#2373
Closes #2364 - Add Rerouting of Tasks in JAVA-API#2373jamesrdi wants to merge 1 commit intoTaskana:masterfrom
Conversation
5c22b0c to
f359273
Compare
a267bf8 to
cac955b
Compare
|
Hello @jamesrdi , please sync fork with current master and rebase this PR. |
1efe994 to
247e04f
Compare
I have just rebased it |
| class CreateHistoryEventOnTaskRerouteAccTest { | ||
| @TaskanaInject TaskanaEngine taskanaEngine; | ||
| @TaskanaInject TaskService taskService; | ||
| @TaskanaInject WorkbasketService workbasketService; |
There was a problem hiding this comment.
Please add a newline after @TaskanaInject attributes
| Task task2; | ||
| Task task3; | ||
| Task task4; | ||
| private SimpleHistoryServiceImpl historyService = new SimpleHistoryServiceImpl(); |
There was a problem hiding this comment.
Why is this private? Why do you initialize it here instead of the setup?
There was a problem hiding this comment.
I agree, I have made it not private
|
|
||
| @WithAccessId(user = "admin") | ||
| @BeforeAll | ||
| void setUp() throws Exception { |
There was a problem hiding this comment.
We use lowercase "setup" in all other tests. So please change it :)
There was a problem hiding this comment.
Ok I have changed it
| @WithAccessId(user = "admin") | ||
| @BeforeAll | ||
| void setUp() throws Exception { | ||
| taskanaHistoryEngine = TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngine); |
There was a problem hiding this comment.
Why do you create it here instead of using @TaskanaInject ?
There was a problem hiding this comment.
TaskanaHistoryEngineImpl is not injectible. Here is the error thrown when I try to inject it:
org.junit.platform.commons.JUnitException: Cannot inject field 'taskanaHistoryEngine'. Type 'class pro.taskana.simplehistory.impl.TaskanaHistoryEngineImpl' is not an injectable TASKANA type
| List<TaskHistoryEvent> events = | ||
| taskHistoryQueryMapper.queryHistoryEvents( | ||
| (TaskHistoryQueryImpl) historyService.createTaskHistoryQuery().taskIdIn(task4.getId())); | ||
| assertThat(events).isEmpty(); |
There was a problem hiding this comment.
Why do you need this assert? You already deleted all task4 related history events
There was a problem hiding this comment.
Ok I agree, I have deleted the assert
| taskHistoryQueryMapper.queryHistoryEvents( | ||
| (TaskHistoryQueryImpl) | ||
| historyService.createTaskHistoryQuery().taskIdIn(taskIds.toArray(new String[0]))); | ||
| assertThat(events).isEmpty(); |
There was a problem hiding this comment.
Why do you need this assert?
There was a problem hiding this comment.
I agree, I have deleted this assert
| (TaskHistoryQueryImpl) | ||
| historyService.createTaskHistoryQuery().taskIdIn(taskIds.toArray(new String[0]))); | ||
|
|
||
| assertThat(events) |
There was a problem hiding this comment.
Could you rewrite the assertion part? It would be more readable without the if/else if/else block?
There was a problem hiding this comment.
How do you suggest I rewrite it?
| } | ||
| } | ||
|
|
||
| TaskHistoryQueryMapper getHistoryQueryMapper() |
There was a problem hiding this comment.
I have made it private
There was a problem hiding this comment.
Could you also test rerouteTasks(...) for its history events?
There was a problem hiding this comment.
The second test should_CreateRerouteHistoryEvent_When_MultipleTasksAreRerouted() tests the history events for rerouteTasks()
| } | ||
|
|
||
| @Override | ||
| public Task asTask() { |
There was a problem hiding this comment.
It is used to convert tasksummaries obrained from the query to tasks, which will be passed to the function taskanaEngine.getTaskRoutingManager().determineWorkbasketId(task). determineWorkbasketId() only accept task as parameter, not tasksummary instances.
Casting cannot be used here, this is the error thrown when trying to cast:
Caused by: java.lang.ClassCastException: Cannot cast pro.taskana.task.internal.models.TaskSummaryImpl to pro.taskana.task.api.models.Task
f13a55d to
421a607
Compare
Added rerouting functionality, and fixed code smells in TaskServiceImpl and TaskQueryFilterParameter
https://sonarcloud.io/summary/new_code?id=jamesrdi_taskana&branch=TSK-2364
Release Notes:
For the submitter:
Verified by the reviewer: