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

Bugfix / timezone for follow-up date #1203

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down
Loading