Skip to content
Snippets Groups Projects
Commit bc18dc88 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6721 WIP

parent cf7f0f4c
No related branches found
No related tags found
No related merge requests found
package de.ozgcloud.alfa.postfach; package de.ozgcloud.alfa.postfach;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
...@@ -15,6 +16,8 @@ import lombok.RequiredArgsConstructor; ...@@ -15,6 +16,8 @@ import lombok.RequiredArgsConstructor;
@Service @Service
class PostfachSettingsService { class PostfachSettingsService {
static final String FIELD_SIGNATUR = "signatur";
private PostfachConfigGroup postfachConfigGroup; private PostfachConfigGroup postfachConfigGroup;
private final PostfachMailRemoteService remoteService; private final PostfachMailRemoteService remoteService;
...@@ -76,4 +79,9 @@ class PostfachSettingsService { ...@@ -76,4 +79,9 @@ class PostfachSettingsService {
Optional<OrganisationsEinheitSettings> getOrganisationsEinheitSettings(final String organisationId) { Optional<OrganisationsEinheitSettings> getOrganisationsEinheitSettings(final String organisationId) {
return Optional.ofNullable(postfachProperties.getOrganisationsEinheitSettings().get(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();
}
} }
...@@ -3,6 +3,7 @@ package de.ozgcloud.alfa.postfach; ...@@ -3,6 +3,7 @@ package de.ozgcloud.alfa.postfach;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
...@@ -361,6 +362,7 @@ class PostfachSettingsServiceTest { ...@@ -361,6 +362,7 @@ class PostfachSettingsServiceTest {
class TestGetOrganisationsEinheitSettings { class TestGetOrganisationsEinheitSettings {
private final OrganisationsEinheitSettings organisationsEinheitSettings = OrganisationsEinheitSettingsTestFactory.create(); private final OrganisationsEinheitSettings organisationsEinheitSettings = OrganisationsEinheitSettingsTestFactory.create();
private final Map<String, Object> organisationsEinheitSettingsMap = Map.of(PostfachSettingsService.FIELD_SIGNATUR, signatur);
@BeforeEach @BeforeEach
void setUp() { void setUp() {
...@@ -375,6 +377,13 @@ class PostfachSettingsServiceTest { ...@@ -375,6 +377,13 @@ class PostfachSettingsServiceTest {
verify(postfachProperties).getOrganisationsEinheitSettings(); verify(postfachProperties).getOrganisationsEinheitSettings();
} }
@Test
void shouldMapToOrganisationsEinheitSettings() {
service.getOrganisationsEinheitSettings(OrganisationsEinheitTestFactory.ID);
verify(service).mapOrganisationsEinheitSettings()
}
@Test @Test
void shouldReturnSettings() { void shouldReturnSettings() {
var settings = service.getOrganisationsEinheitSettings(OrganisationsEinheitTestFactory.ID); var settings = service.getOrganisationsEinheitSettings(OrganisationsEinheitTestFactory.ID);
...@@ -389,4 +398,25 @@ class PostfachSettingsServiceTest { ...@@ -389,4 +398,25 @@ class PostfachSettingsServiceTest {
assertThat(settings).isEmpty(); 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();
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment