diff --git a/src/test/java/de/focusshift/zeiterfassung/report/ReportDayTest.java b/src/test/java/de/focusshift/zeiterfassung/report/ReportDayTest.java index 83f90983..ea279f6a 100644 --- a/src/test/java/de/focusshift/zeiterfassung/report/ReportDayTest.java +++ b/src/test/java/de/focusshift/zeiterfassung/report/ReportDayTest.java @@ -43,12 +43,13 @@ void reportDayEntries() { final ZonedDateTime to = dateTime(2024, 11, 13, 2, 0); final ReportDayEntry reportDayEntry = new ReportDayEntry(batman, "hard work", from, to, true); - LocalDate reportDate = LocalDate.of(2024, 11, 13); - ReportDay reportDay = new ReportDay(reportDate, Map.of(), Map.of(batmanIdComposite, List.of(reportDayEntry)), Map.of()); + final LocalDate reportDate = LocalDate.of(2024, 11, 13); + final ReportDay sut = new ReportDay(reportDate, Map.of(), Map.of(batmanIdComposite, List.of(reportDayEntry)), Map.of()); - List reportDayEntries = reportDay.reportDayEntries(); - - assertThat(reportDayEntries).hasSize(1).containsExactly(reportDayEntry); + final List reportDayEntries = sut.reportDayEntries(); + assertThat(reportDayEntries) + .hasSize(1) + .containsExactly(reportDayEntry); } @Test @@ -61,17 +62,18 @@ void plannedWorkingHours() { final UserLocalId robinLocalId = new UserLocalId(1337L); final UserIdComposite robinIdComposite = new UserIdComposite(robinId, robinLocalId); - LocalDate reportDate = LocalDate.of(2024, 11, 13); - ReportDay reportDay = new ReportDay( - reportDate, - Map.of( - batmanIdComposite, new WorkingTimeCalendar(Map.of(reportDate, PlannedWorkingHours.EIGHT), Map.of()), - robinIdComposite, new WorkingTimeCalendar(Map.of(reportDate, new PlannedWorkingHours(Duration.ofHours(4))), Map.of()) - ), - Map.of(), - Map.of()); - - assertThat(reportDay.plannedWorkingHours().duration()).isEqualTo(Duration.ofHours(12)); + final LocalDate reportDate = LocalDate.of(2024, 11, 13); + + final ReportDay sut = new ReportDay( + reportDate, + Map.of( + batmanIdComposite, new WorkingTimeCalendar(Map.of(reportDate, PlannedWorkingHours.EIGHT), Map.of()), + robinIdComposite, new WorkingTimeCalendar(Map.of(reportDate, new PlannedWorkingHours(Duration.ofHours(4))), Map.of()) + ), + Map.of(), + Map.of()); + + assertThat(sut.plannedWorkingHours().duration()).isEqualTo(Duration.ofHours(12)); } @Test @@ -86,11 +88,11 @@ void ensureToRemoveBreaks() { final ZonedDateTime to = dateTime(2021, 1, 4, 2, 0); final ReportDayEntry reportDayEntry = new ReportDayEntry(batman, "hard work", from, to, true); - LocalDate reportDate = LocalDate.of(2021, 1, 4); - WorkingTimeCalendar workingTimeCalendar = new WorkingTimeCalendar(Map.of(reportDate, PlannedWorkingHours.EIGHT), Map.of()); - final ReportDay reportDay = new ReportDay(reportDate, Map.of(batmanIdComposite, workingTimeCalendar), Map.of(batmanIdComposite, List.of(reportDayEntry)), Map.of()); + final LocalDate reportDate = LocalDate.of(2021, 1, 4); + final WorkingTimeCalendar workingTimeCalendar = new WorkingTimeCalendar(Map.of(reportDate, PlannedWorkingHours.EIGHT), Map.of()); - assertThat(reportDay.workDuration().duration()).isEqualTo(Duration.ZERO); + final ReportDay sut = new ReportDay(reportDate, Map.of(batmanIdComposite, workingTimeCalendar), Map.of(batmanIdComposite, List.of(reportDayEntry)), Map.of()); + assertThat(sut.workDuration().duration()).isEqualTo(Duration.ZERO); } @Test @@ -103,13 +105,13 @@ void shouldWorkingHoursReturnsZeroForFullyAbsentUser() { final ZonedDateTime from = dateTime(2021, 1, 4, 1, 0); final ZonedDateTime to = dateTime(2021, 1, 4, 2, 0); - Absence absence = new Absence(batmanId, from, to, FULL, locale -> "foo", RED, HOLIDAY); + final Absence absence = new Absence(batmanId, from, to, FULL, locale -> "foo", RED, HOLIDAY); - LocalDate reportDate = LocalDate.of(2021, 1, 4); - WorkingTimeCalendar workingTimeCalendar = new WorkingTimeCalendar(Map.of(reportDate, PlannedWorkingHours.EIGHT), Map.of(reportDate, List.of(absence))); - final ReportDay reportDay = new ReportDay(reportDate, Map.of(batmanIdComposite, workingTimeCalendar), Map.of(batmanIdComposite, List.of()), Map.of(batmanIdComposite, List.of(new ReportDayAbsence(batman, absence)))); + final LocalDate reportDate = LocalDate.of(2021, 1, 4); + final WorkingTimeCalendar workingTimeCalendar = new WorkingTimeCalendar(Map.of(reportDate, PlannedWorkingHours.EIGHT), Map.of(reportDate, List.of(absence))); - assertThat(reportDay.shouldWorkingHours()).isEqualTo(new ShouldWorkingHours(Duration.ZERO)); + final ReportDay sut = new ReportDay(reportDate, Map.of(batmanIdComposite, workingTimeCalendar), Map.of(batmanIdComposite, List.of()), Map.of(batmanIdComposite, List.of(new ReportDayAbsence(batman, absence)))); + assertThat(sut.shouldWorkingHours()).isEqualTo(new ShouldWorkingHours(Duration.ZERO)); } @ParameterizedTest @@ -123,13 +125,13 @@ void shouldWorkingHoursReturnsHalfShouldWorkingHoursForHalfDayAbsentUser(DayLeng final ZonedDateTime from = dateTime(2021, 1, 4, 1, 0); final ZonedDateTime to = dateTime(2021, 1, 4, 2, 0); - Absence absence = new Absence(batmanId, from, to, dayLength, locale -> "foo", RED, HOLIDAY); + final Absence absence = new Absence(batmanId, from, to, dayLength, locale -> "foo", RED, HOLIDAY); - LocalDate reportDate = LocalDate.of(2021, 1, 4); - WorkingTimeCalendar workingTimeCalendar = new WorkingTimeCalendar(Map.of(reportDate, PlannedWorkingHours.EIGHT), Map.of(reportDate, List.of(absence))); - final ReportDay reportDay = new ReportDay(LocalDate.of(2021, 1, 4), Map.of(batmanIdComposite, workingTimeCalendar), Map.of(batmanIdComposite, List.of()), Map.of(batmanIdComposite, List.of(new ReportDayAbsence(batman, absence)))); + final LocalDate reportDate = LocalDate.of(2021, 1, 4); + final WorkingTimeCalendar workingTimeCalendar = new WorkingTimeCalendar(Map.of(reportDate, PlannedWorkingHours.EIGHT), Map.of(reportDate, List.of(absence))); - assertThat(reportDay.shouldWorkingHours()).isEqualTo(new ShouldWorkingHours(Duration.ofHours(4))); + final ReportDay sut = new ReportDay(LocalDate.of(2021, 1, 4), Map.of(batmanIdComposite, workingTimeCalendar), Map.of(batmanIdComposite, List.of()), Map.of(batmanIdComposite, List.of(new ReportDayAbsence(batman, absence)))); + assertThat(sut.shouldWorkingHours()).isEqualTo(new ShouldWorkingHours(Duration.ofHours(4))); } @Test @@ -142,27 +144,27 @@ void shouldWorkingHoursReturnsShouldHoursForOneAbsentUserAndOneWorkingUser() { final ZonedDateTime from = dateTime(2021, 1, 4, 1, 0); final ZonedDateTime to = dateTime(2021, 1, 4, 2, 0); - Absence absence = new Absence(batmanId, from, to, FULL, locale -> "foo", RED, HOLIDAY); + final Absence absence = new Absence(batmanId, from, to, FULL, locale -> "foo", RED, HOLIDAY); final UserId robinId = new UserId("uuid2"); final UserLocalId robinLocalId = new UserLocalId(1337L); final UserIdComposite robinIdComposite = new UserIdComposite(robinId, robinLocalId); - Map> entriesByUser = Map.of(batmanIdComposite, List.of(), robinIdComposite, List.of()); - Map> absencesByUser = Map.of(batmanIdComposite, List.of(new ReportDayAbsence(batman, absence)), robinIdComposite, List.of()); - - LocalDate reportDate = LocalDate.of(2021, 1, 4); - Map plannedWorkingHoursByUser = Map.of( - batmanIdComposite, new WorkingTimeCalendar( - Map.of(reportDate, PlannedWorkingHours.EIGHT), - Map.of(reportDate, List.of(absence))), - robinIdComposite, new WorkingTimeCalendar( - Map.of(reportDate, new PlannedWorkingHours(Duration.ofHours(4))), - Map.of(reportDate, List.of())) + final Map> entriesByUser = Map.of(batmanIdComposite, List.of(), robinIdComposite, List.of()); + final Map> absencesByUser = Map.of(batmanIdComposite, List.of(new ReportDayAbsence(batman, absence)), robinIdComposite, List.of()); + + final LocalDate reportDate = LocalDate.of(2021, 1, 4); + final Map plannedWorkingHoursByUser = Map.of( + batmanIdComposite, new WorkingTimeCalendar( + Map.of(reportDate, PlannedWorkingHours.EIGHT), + Map.of(reportDate, List.of(absence))), + robinIdComposite, new WorkingTimeCalendar( + Map.of(reportDate, new PlannedWorkingHours(Duration.ofHours(4))), + Map.of(reportDate, List.of())) ); - final ReportDay reportDay = new ReportDay(reportDate, plannedWorkingHoursByUser, entriesByUser, absencesByUser); - assertThat(reportDay.shouldWorkingHours()).isEqualTo(new ShouldWorkingHours(Duration.ofHours(4L))); + final ReportDay sut = new ReportDay(reportDate, plannedWorkingHoursByUser, entriesByUser, absencesByUser); + assertThat(sut.shouldWorkingHours()).isEqualTo(new ShouldWorkingHours(Duration.ofHours(4L))); } @ParameterizedTest @@ -176,26 +178,26 @@ void shouldWorkingHoursReturnsSummedShouldHoursForOneHalfAbsentUserAndOneWorking final ZonedDateTime from = dateTime(2021, 1, 4, 1, 0); final ZonedDateTime to = dateTime(2021, 1, 4, 2, 0); - Absence absence = new Absence(batmanId, from, to, dayLength, locale -> "foo", RED, HOLIDAY); + final Absence absence = new Absence(batmanId, from, to, dayLength, locale -> "foo", RED, HOLIDAY); final UserId robinId = new UserId("uuid2"); final UserLocalId robinLocalId = new UserLocalId(1337L); final UserIdComposite robinIdComposite = new UserIdComposite(robinId, robinLocalId); - Map> entriesByUser = Map.of(batmanIdComposite, List.of(), robinIdComposite, List.of()); - Map> absencesByUser = Map.of(batmanIdComposite, List.of(new ReportDayAbsence(batman, absence)), robinIdComposite, List.of()); - LocalDate reportDate = LocalDate.of(2021, 1, 4); - Map plannedWorkingHoursByUser = Map.of( - batmanIdComposite, new WorkingTimeCalendar( - Map.of(reportDate, PlannedWorkingHours.EIGHT), - Map.of(reportDate, List.of(absence))), - robinIdComposite, new WorkingTimeCalendar( - Map.of(reportDate, new PlannedWorkingHours(Duration.ofHours(4))), - Map.of(reportDate, List.of())) + final Map> entriesByUser = Map.of(batmanIdComposite, List.of(), robinIdComposite, List.of()); + final Map> absencesByUser = Map.of(batmanIdComposite, List.of(new ReportDayAbsence(batman, absence)), robinIdComposite, List.of()); + final LocalDate reportDate = LocalDate.of(2021, 1, 4); + final Map plannedWorkingHoursByUser = Map.of( + batmanIdComposite, new WorkingTimeCalendar( + Map.of(reportDate, PlannedWorkingHours.EIGHT), + Map.of(reportDate, List.of(absence))), + robinIdComposite, new WorkingTimeCalendar( + Map.of(reportDate, new PlannedWorkingHours(Duration.ofHours(4))), + Map.of(reportDate, List.of())) ); - final ReportDay reportDay = new ReportDay(reportDate, plannedWorkingHoursByUser, entriesByUser, absencesByUser); - assertThat(reportDay.shouldWorkingHours()).isEqualTo(new ShouldWorkingHours(Duration.ofHours(8L))); + final ReportDay sut = new ReportDay(reportDate, plannedWorkingHoursByUser, entriesByUser, absencesByUser); + assertThat(sut.shouldWorkingHours()).isEqualTo(new ShouldWorkingHours(Duration.ofHours(8L))); } private static ZonedDateTime dateTime(int year, int month, int dayOfMonth, int hour, int minute) {