diff --git a/digiwf-task/digiwf-tasklist-service/src/main/java/de/muenchen/oss/digiwf/task/service/adapter/out/engine/RemoteTaskCommandRestAdapter.java b/digiwf-task/digiwf-tasklist-service/src/main/java/de/muenchen/oss/digiwf/task/service/adapter/out/engine/RemoteTaskCommandRestAdapter.java index eeef736635..ae61af8765 100644 --- a/digiwf-task/digiwf-tasklist-service/src/main/java/de/muenchen/oss/digiwf/task/service/adapter/out/engine/RemoteTaskCommandRestAdapter.java +++ b/digiwf-task/digiwf-tasklist-service/src/main/java/de/muenchen/oss/digiwf/task/service/adapter/out/engine/RemoteTaskCommandRestAdapter.java @@ -51,7 +51,7 @@ public void unassignUserTask(String taskId) { public void deferUserTask(String taskId, Instant followUpDate) { var task = taskService.createTaskQuery().taskId(taskId).singleResult(); if (task != null) { - task.setFollowUpDate(Date.from(followUpDate.truncatedTo(ChronoUnit.DAYS))); + task.setFollowUpDate(Date.from(followUpDate)); taskService.saveTask(task); } } diff --git a/digiwf-task/digiwf-tasklist-service/src/test/java/de/muenchen/oss/digiwf/task/service/adapter/out/engine/RemoteTaskCommandRestAdapterTest.java b/digiwf-task/digiwf-tasklist-service/src/test/java/de/muenchen/oss/digiwf/task/service/adapter/out/engine/RemoteTaskCommandRestAdapterTest.java index 50d4df8682..b80d3bb3f7 100644 --- a/digiwf-task/digiwf-tasklist-service/src/test/java/de/muenchen/oss/digiwf/task/service/adapter/out/engine/RemoteTaskCommandRestAdapterTest.java +++ b/digiwf-task/digiwf-tasklist-service/src/test/java/de/muenchen/oss/digiwf/task/service/adapter/out/engine/RemoteTaskCommandRestAdapterTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test; import java.time.LocalDateTime; +import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.UUID; @@ -74,13 +75,19 @@ void save() { @Test void deferUserTask() { - val instant = LocalDateTime.of(2023, 5, 24, 12, 0).toInstant(ZoneOffset.UTC); + val originalTZ = System.getProperty("user.timezone"); + System.setProperty("user.timezone", "Europe/Berlin"); + val offsetDateTimeFromFrontend = OffsetDateTime.parse("2024-01-18T00:00:00.000+01:00"); + val instant = offsetDateTimeFromFrontend.toInstant(); + final TaskFake task = TaskFake.builder().build(); QueryMocks.mockTaskQuery(taskService).singleResult(task); taskCommandPort.deferUserTask(taskId, instant); - assertThat(task.getFollowUpDate()).isNotNull(); // check only if there is an interaction, no Instant to DateTime transformation is tested + assertThat(task.getFollowUpDate()).isNotNull(); + assertThat(task.getFollowUpDate()).isEqualTo("2024-01-18T00:00:00.000+01:00"); verify(taskService).saveTask(task); + System.setProperty("user.timezone", originalTZ); } @Test void undeferUserTask() {