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..babbc9de0317a3d4fd3fb96abf14253fd3f0138e 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,7 +230,20 @@ class PostfachService { } public Stream<Postfach> getPostfachs() { - return isPostfachConfigured() ? Stream.of(buildPostfach(postfachRemoteService)) : Stream.empty(); + return isPostfachConfigured() ? getPostfaecher() : Stream.empty(); + } + + private Stream<Postfach> getPostfaecher() { + var postfach = buildPostfach(postfachRemoteService); + // TODO Nach Umstellung auf BAYERN_ID entfernen + 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) { 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..7355c0c544c960eca1c258c24856a18039599e67 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(BAYERN_ID_POSTFACH); + } + + private Stream<Postfach> getPostfaecher() { + return service.getPostfachs(); + } + } + @Nested class TestBuildPostfach {