-
Notifications
You must be signed in to change notification settings - Fork 101
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
Closes #2364 - Add Rerouting of Tasks in JAVA-API #2373
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a newline after @TaskanaInject attributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok is added
Task task2; | ||
Task task3; | ||
Task task4; | ||
private SimpleHistoryServiceImpl historyService = new SimpleHistoryServiceImpl(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this private? Why do you initialize it here instead of the setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I have made it not private
|
||
@WithAccessId(user = "admin") | ||
@BeforeAll | ||
void setUp() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use lowercase "setup" in all other tests. So please change it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I have changed it
@WithAccessId(user = "admin") | ||
@BeforeAll | ||
void setUp() throws Exception { | ||
taskanaHistoryEngine = TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngine); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you create it here instead of using @TaskanaInject ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this assert? You already deleted all task4 related history events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this assert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you suggest I rewrite it?
} | ||
} | ||
|
||
TaskHistoryQueryMapper getHistoryQueryMapper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made it private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also test rerouteTasks(...) for its history events?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second test should_CreateRerouteHistoryEvent_When_MultipleTasksAreRerouted() tests the history events for rerouteTasks()
@@ -776,6 +778,78 @@ public void setCustomInt8(Integer customInt8) { | |||
this.customInt8 = customInt8; | |||
} | |||
|
|||
@Override | |||
public Task asTask() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: