From 6f8657d25aa9c9d5c2fe26b39f410734d78df4ea Mon Sep 17 00:00:00 2001 From: Matthias Ronge Date: Tue, 10 Sep 2024 09:37:55 +0200 Subject: [PATCH] Fix tests --- .../services/workflow/WorkflowControllerService.java | 12 ++++++++++-- .../workflow/WorkflowControllerServiceIT.java | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java b/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java index 3c207f8c789..c7a7d92021a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java @@ -52,6 +52,7 @@ import org.kitodo.production.helper.tasks.TaskManager; import org.kitodo.production.metadata.MetadataLock; import org.kitodo.production.services.ServiceManager; +import org.kitodo.production.services.data.CommentService; import org.kitodo.production.services.data.TaskService; import org.kitodo.production.thread.TaskScriptThread; @@ -63,6 +64,7 @@ public class WorkflowControllerService { private final WebDav webDav = new WebDav(); private static final Logger logger = LogManager.getLogger(WorkflowControllerService.class); private final TaskService taskService = ServiceManager.getTaskService(); + private final CommentService commentService = ServiceManager.getCommentService(); /** * Set Task status up. @@ -372,7 +374,11 @@ public void reportProblem(Comment comment, TaskEditType taskEditType) throws DAO correctionTask.setProcessingEnd(null); correctionTask.setCorrection(true); taskService.save(correctionTask); - lockTasksBetweenCurrentAndCorrectionTask(currentTask, correctionTask); + if (lockTasksBetweenCurrentAndCorrectionTask(currentTask, correctionTask) + && Objects.nonNull(comment.getId())) { + commentService.refresh(comment); + currentTask = comment.getCurrentTask(); + } } updateProcessSortHelperStatus(currentTask.getProcess()); } @@ -474,7 +480,8 @@ private void closeParent(Process process) throws DAOException { } } - private void lockTasksBetweenCurrentAndCorrectionTask(Task currentTask, Task correctionTask) throws DAOException { + private boolean lockTasksBetweenCurrentAndCorrectionTask(Task currentTask, Task correctionTask) + throws DAOException { List allTasksInBetween = taskService.getAllTasksInBetween(correctionTask.getOrdering(), currentTask.getOrdering(), currentTask.getProcess().getId()); for (Task taskInBetween : allTasksInBetween) { @@ -483,6 +490,7 @@ private void lockTasksBetweenCurrentAndCorrectionTask(Task currentTask, Task cor taskInBetween.setProcessingEnd(null); taskService.save(taskInBetween); } + return !allTasksInBetween.isEmpty(); } private List getAllHigherTasks(List tasks, Task task) { diff --git a/Kitodo/src/test/java/org/kitodo/production/services/workflow/WorkflowControllerServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/workflow/WorkflowControllerServiceIT.java index 09b0afa4a0b..cd07bd6e676 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/workflow/WorkflowControllerServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/workflow/WorkflowControllerServiceIT.java @@ -450,7 +450,7 @@ public void shouldReportProblem() throws Exception { "Report of problem was incorrect - task '" + correctionTask.getTitle() + "' is not a correction task!", correctionTask.isCorrection()); - Process process = currentTask.getProcess(); + Process process = problem.getCurrentTask().getProcess(); for (Task task : process.getTasks()) { if (correctionTask.getOrdering() < task.getOrdering() && task.getOrdering() < currentTask.getOrdering()) { assertEquals("Report of problem was incorrect - tasks between were not set up to locked!",