diff --git a/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachService.java b/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachService.java index d8fb86c86b20151383f51983e43a02c71e51a5d9..6d3118b2ff5b6160df4a81133731c062ddbbca45 100644 --- a/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachService.java +++ b/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachService.java @@ -230,9 +230,22 @@ class PostfachService { } public Stream<Postfach> getPostfachs() { - return isPostfachConfigured() ? Stream.of(buildPostfach(postfachRemoteService)) : Stream.empty(); + return isPostfachConfigured() ? getPostfaecher() : Stream.empty(); } + // TODO Nach Umstellung auf BAYERN_ID entfernen + private Stream<Postfach> getPostfaecher() { + var postfach = buildPostfach(postfachRemoteService); + if (postfachRemoteService.getPostfachType().equals("BAYERN_ID")) { + return Stream.of(postfach, Postfach.builder() + .type("BayernId") + .isReplyAllowed(postfach.isReplyAllowed()) + .build()); + } + return Stream.of(postfach); + } + // + Postfach buildPostfach(PostfachRemoteService postfachRemoteService) { return Postfach.builder().type(postfachRemoteService.getPostfachType()).isReplyAllowed(isReplyAllowed(postfachRemoteService)).build(); } diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachServiceTest.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachServiceTest.java index 7a88f0f81a573698705430c9587144ef4180751d..ea915a98dd566fe4e546fc095ecd088a75de11fb 100644 --- a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachServiceTest.java +++ b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachServiceTest.java @@ -733,6 +733,7 @@ class PostfachServiceTest { } } + @DisplayName("Get postfachs") @Nested class TestGetPostfachs { @@ -749,6 +750,7 @@ class PostfachServiceTest { @Test void shouldReturnPostfachs() { + when(postfachRemoteService.getPostfachType()).thenReturn(PostfachTestFactory.POSTFACH_TYPE); doReturn(postfach).when(service).buildPostfach(any()); var result = service.getPostfachs(); @@ -765,6 +767,45 @@ class PostfachServiceTest { assertThat(result).isEmpty(); } + @DisplayName("on bayern id postfach") + @Nested + class TestOnBayernIdPostfach { + + private static final String BAYERN_ID_POSTFACH = "BAYERN_ID"; + private static final String DEPRECATED_BAYERN_ID_POSTFACH = "BayernId"; + + @BeforeEach + void mock() { + doReturn(true).when(service).isPostfachConfigured(); + when(postfachRemoteService.getPostfachType()).thenReturn(BAYERN_ID_POSTFACH); + } + + @Test + void shouldReturnTwoPostfach() { + var postfaecher = getPostfaecher(); + + assertThat(postfaecher).hasSize(2); + } + + @Test + void shouldContainsBayernIdCamelCase() { + var postfaecher = getPostfaecher(); + + assertThat(postfaecher).extracting(Postfach::getType).contains(DEPRECATED_BAYERN_ID_POSTFACH); + } + + @Test + void shouldContainsBayernIdUnderscore() { + var postfaecher = getPostfaecher(); + + assertThat(postfaecher).extracting(Postfach::getType).contains(DEPRECATED_BAYERN_ID_POSTFACH); + } + + private Stream<Postfach> getPostfaecher() { + return service.getPostfachs(); + } + } + @Nested class TestBuildPostfach {