From bc18dc885cfc66a4ac8c7e139b92fdfee71e6c42 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Tue, 29 Oct 2024 09:42:39 +0100 Subject: [PATCH] OZG-6721 WIP --- .../postfach/PostfachSettingsService.java | 8 +++++ .../postfach/PostfachSettingsServiceTest.java | 30 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/postfach/PostfachSettingsService.java b/alfa-service/src/main/java/de/ozgcloud/alfa/postfach/PostfachSettingsService.java index 84ffbf35e8..ce91372b01 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/postfach/PostfachSettingsService.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/postfach/PostfachSettingsService.java @@ -1,5 +1,6 @@ package de.ozgcloud.alfa.postfach; +import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -15,6 +16,8 @@ import lombok.RequiredArgsConstructor; @Service class PostfachSettingsService { + static final String FIELD_SIGNATUR = "signatur"; + private PostfachConfigGroup postfachConfigGroup; private final PostfachMailRemoteService remoteService; @@ -76,4 +79,9 @@ class PostfachSettingsService { Optional<OrganisationsEinheitSettings> getOrganisationsEinheitSettings(final String organisationId) { return Optional.ofNullable(postfachProperties.getOrganisationsEinheitSettings().get(organisationId)); } + + OrganisationsEinheitSettings mapOrganisationsEinheitSettings(Map<String, Object> organisationsEinheitSettings) { + var signatur = Optional.ofNullable(organisationsEinheitSettings.get(FIELD_SIGNATUR)).map(Object::toString).orElse(null); + return OrganisationsEinheitSettings.builder().signatur(signatur).build(); + } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachSettingsServiceTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachSettingsServiceTest.java index a772c4fdc0..ea0f34531c 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachSettingsServiceTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachSettingsServiceTest.java @@ -3,6 +3,7 @@ package de.ozgcloud.alfa.postfach; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; @@ -361,6 +362,7 @@ class PostfachSettingsServiceTest { class TestGetOrganisationsEinheitSettings { private final OrganisationsEinheitSettings organisationsEinheitSettings = OrganisationsEinheitSettingsTestFactory.create(); + private final Map<String, Object> organisationsEinheitSettingsMap = Map.of(PostfachSettingsService.FIELD_SIGNATUR, signatur); @BeforeEach void setUp() { @@ -375,6 +377,13 @@ class PostfachSettingsServiceTest { verify(postfachProperties).getOrganisationsEinheitSettings(); } + @Test + void shouldMapToOrganisationsEinheitSettings() { + service.getOrganisationsEinheitSettings(OrganisationsEinheitTestFactory.ID); + + verify(service).mapOrganisationsEinheitSettings() + } + @Test void shouldReturnSettings() { var settings = service.getOrganisationsEinheitSettings(OrganisationsEinheitTestFactory.ID); @@ -389,4 +398,25 @@ class PostfachSettingsServiceTest { assertThat(settings).isEmpty(); } } + + @Nested + class TestMapOrganisationsEinheitSettings { + + private final String signatur = LoremIpsum.getInstance().getWords(2); + private final Map<String, Object> organisationsEinheitSettings = Map.of(PostfachSettingsService.FIELD_SIGNATUR, signatur); + + @Test + void shouldMap() { + var settings = service.mapOrganisationsEinheitSettings(organisationsEinheitSettings); + + assertThat(settings.getSignatur()).isEqualTo(signatur); + } + + @Test + void shouldReturnSettingsWithNullSignatur() { + var settings = service.mapOrganisationsEinheitSettings(Collections.emptyMap()); + + assertThat(settings.getSignatur()).isNull(); + } + } } -- GitLab