From eefcc74078f1c748e0662fcbf985fde0c3377e6b Mon Sep 17 00:00:00 2001 From: Robert Jasny Date: Mon, 4 Nov 2024 12:42:27 +0100 Subject: [PATCH] imports added after applying review suggestions, naming conventions for tests --- .../WaehleranzahlClientMapper.java | 3 +- .../WaehleranzahlClientMapperTest.java | 41 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/wls-monitoring-service/src/main/java/de/muenchen/oss/wahllokalsystem/monitoringservice/client/waehleranzahl/WaehleranzahlClientMapper.java b/wls-monitoring-service/src/main/java/de/muenchen/oss/wahllokalsystem/monitoringservice/client/waehleranzahl/WaehleranzahlClientMapper.java index a549fafd8..3c798e2a9 100644 --- a/wls-monitoring-service/src/main/java/de/muenchen/oss/wahllokalsystem/monitoringservice/client/waehleranzahl/WaehleranzahlClientMapper.java +++ b/wls-monitoring-service/src/main/java/de/muenchen/oss/wahllokalsystem/monitoringservice/client/waehleranzahl/WaehleranzahlClientMapper.java @@ -4,7 +4,8 @@ import de.muenchen.oss.wahllokalsystem.monitoringservice.service.waehleranzahl.WaehleranzahlModel; import java.time.LocalDateTime; import java.time.OffsetDateTime; -import java.time.ZoneOffset; +import java.time.ZoneId; +import lombok.val; import org.mapstruct.Mapper; import org.mapstruct.Mapping; diff --git a/wls-monitoring-service/src/test/java/de/muenchen/oss/wahllokalsystem/monitoringservice/client/waehleranzahl/WaehleranzahlClientMapperTest.java b/wls-monitoring-service/src/test/java/de/muenchen/oss/wahllokalsystem/monitoringservice/client/waehleranzahl/WaehleranzahlClientMapperTest.java index 8124e37bb..d10dd75af 100644 --- a/wls-monitoring-service/src/test/java/de/muenchen/oss/wahllokalsystem/monitoringservice/client/waehleranzahl/WaehleranzahlClientMapperTest.java +++ b/wls-monitoring-service/src/test/java/de/muenchen/oss/wahllokalsystem/monitoringservice/client/waehleranzahl/WaehleranzahlClientMapperTest.java @@ -4,6 +4,8 @@ import de.muenchen.oss.wahllokalsystem.monitoringservice.service.waehleranzahl.WaehleranzahlModel; import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID; import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneId; import java.time.ZoneOffset; import lombok.val; import org.assertj.core.api.Assertions; @@ -19,7 +21,7 @@ public class WaehleranzahlClientMapperTest { class FromModelToRemoteClientDTO { @Test - void isMappedWithSomething() { + void should_return_RemoteClientDTO_when_modelIsGiven() { val wahlID = "wahlID01"; val wahlbezirkID = "wahlbezirkID01"; val anzahlWahler = 99L; @@ -31,8 +33,9 @@ void isMappedWithSomething() { val result = unitUnderTest.fromModelToRemoteClientDTO(waehleranzahlModel); + val zoneOffset = ZoneId.systemDefault().getRules().getOffset(meldeZeitpunkt); val expectedWahlbeteiligungsMeldungDTO = new WahlbeteiligungsMeldungDTO().wahlID(null).wahlbezirkID(wahlbezirkID).anzahlWaehler(anzahlWahler) - .meldeZeitpunkt(meldeZeitpunkt.atOffset(ZoneOffset.UTC)); + .meldeZeitpunkt(meldeZeitpunkt.atOffset(zoneOffset)); Assertions.assertThat(result).isEqualTo(expectedWahlbeteiligungsMeldungDTO); } } @@ -40,29 +43,25 @@ void isMappedWithSomething() { @Nested class LocalDateTimeToOffsetDateTime { - @Nested - class WithZoneIdWithDaylightSavingTime { - - @Test - void should_useSummerSeasonOffset_when_mapping() { - val localDateTime = LocalDateTime.parse("2024-06-12T12:13:14.567"); - val zoneID = ZoneId.of("Europe/Berlin"); + @Test + void should_useSummerSeasonOffset_when_mapping() { + val localDateTime = LocalDateTime.parse("2024-06-12T12:13:14.567"); + val zoneID = ZoneId.of("Europe/Berlin"); - val result = unitUnderTest.localDateTimeToOffsetDateTime(localDateTime, zoneID); + val result = unitUnderTest.localDateTimeToOffsetDateTime(localDateTime, zoneID); - val expectedResult = OffsetDateTime.of(localDateTime, ZoneOffset.ofHours(2)); - Assertions.assertThat(result).isEqualTo(expectedResult); - } + val expectedResult = OffsetDateTime.of(localDateTime, ZoneOffset.ofHours(2)); + Assertions.assertThat(result).isEqualTo(expectedResult); + } - @Test - void should_useWinterSeasonOffset_when_mapping() { - val localDateTime = LocalDateTime.parse("2024-11-12T12:13:14.567"); - val zoneID = ZoneId.of("Europe/Berlin"); - val result = unitUnderTest.localDateTimeToOffsetDateTime(localDateTime, zoneID); + @Test + void should_useWinterSeasonOffset_when_mapping() { + val localDateTime = LocalDateTime.parse("2024-11-12T12:13:14.567"); + val zoneID = ZoneId.of("Europe/Berlin"); + val result = unitUnderTest.localDateTimeToOffsetDateTime(localDateTime, zoneID); - val expectedResult = OffsetDateTime.of(localDateTime, ZoneOffset.ofHours(1)); - Assertions.assertThat(result).isEqualTo(expectedResult); - } + val expectedResult = OffsetDateTime.of(localDateTime, ZoneOffset.ofHours(1)); + Assertions.assertThat(result).isEqualTo(expectedResult); } } }