Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jamesrdi
Copy link
Contributor

@jamesrdi jamesrdi commented Sep 6, 2023

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:

@jamesrdi jamesrdi force-pushed the TSK-2364 branch 7 times, most recently from 5c22b0c to f359273 Compare September 7, 2023 07:28
@jamesrdi jamesrdi force-pushed the TSK-2364 branch 2 times, most recently from a267bf8 to cac955b Compare September 15, 2023 11:36
@arolfes
Copy link
Contributor

arolfes commented Nov 17, 2023

Hello @jamesrdi , please sync fork with current master and rebase this PR.

@jamesrdi jamesrdi force-pushed the TSK-2364 branch 2 times, most recently from 1efe994 to 247e04f Compare November 17, 2023 09:32
@jamesrdi
Copy link
Contributor Author

Hello @jamesrdi , please sync fork with current master and rebase this PR.

I have just rebased it

class CreateHistoryEventOnTaskRerouteAccTest {
@TaskanaInject TaskanaEngine taskanaEngine;
@TaskanaInject TaskService taskService;
@TaskanaInject WorkbasketService workbasketService;
Copy link
Contributor

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

Copy link
Contributor Author

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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 :)

Copy link
Contributor Author

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);
Copy link
Contributor

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 ?

Copy link
Contributor Author

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();
Copy link
Contributor

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

Copy link
Contributor Author

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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()
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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() {
Copy link
Contributor

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?

Copy link
Contributor Author

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

@jamesrdi jamesrdi force-pushed the TSK-2364 branch 3 times, most recently from f13a55d to 421a607 Compare January 30, 2024 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Commit Hooks won't work without JIRA Tickets
3 participants