diff --git a/goofy-server/src/main/java/de/itvsh/goofy/postfach/PostfachMailRemoteService.java b/goofy-server/src/main/java/de/itvsh/goofy/postfach/PostfachMailRemoteService.java index f8be24fef2844b138109ab3eb3356f2836bcee8a..3a86a2826cfc0c51bf56aad0b824411c5ea24685 100644 --- a/goofy-server/src/main/java/de/itvsh/goofy/postfach/PostfachMailRemoteService.java +++ b/goofy-server/src/main/java/de/itvsh/goofy/postfach/PostfachMailRemoteService.java @@ -52,8 +52,9 @@ class PostfachMailRemoteService { } public Optional<PostfachMail> findById(PostfachNachrichtId nachrichtId) { - serviceStub.findPostfachMail(buildFindPostfachMailRequest(nachrichtId)); - return Optional.empty(); + var response = serviceStub.findPostfachMail(buildFindPostfachMailRequest(nachrichtId)); + + return Optional.ofNullable(response.getNachricht()).map(mailMapper::toPostfachMail); } private GrpcFindPostfachMailRequest buildFindPostfachMailRequest(PostfachNachrichtId nachrichtId) { diff --git a/goofy-server/src/test/java/de/itvsh/goofy/postfach/GrpcPostfachMailTestFactory.java b/goofy-server/src/test/java/de/itvsh/goofy/postfach/GrpcPostfachMailTestFactory.java index d0c7de56fe880391ad1682e4f4f50987ab05c311..bba3c6d06a02a9846010dea9496d026fd39f54db 100644 --- a/goofy-server/src/test/java/de/itvsh/goofy/postfach/GrpcPostfachMailTestFactory.java +++ b/goofy-server/src/test/java/de/itvsh/goofy/postfach/GrpcPostfachMailTestFactory.java @@ -5,6 +5,7 @@ import static de.itvsh.goofy.postfach.PostfachMailTestFactory.*; import java.util.Arrays; import de.itvsh.ozg.mail.postfach.GrpcDirection; +import de.itvsh.ozg.mail.postfach.GrpcFindPostfachMailResponse; import de.itvsh.ozg.mail.postfach.GrpcFindPostfachMailsResponse; import de.itvsh.ozg.mail.postfach.GrpcPostfachMail; @@ -36,4 +37,10 @@ public class GrpcPostfachMailTestFactory { .addAllMails(Arrays.asList(create())) .build(); } + + public static GrpcFindPostfachMailResponse createFindPostfachMailResponse() { + return GrpcFindPostfachMailResponse.newBuilder() + .setNachricht(create()) + .build(); + } } \ No newline at end of file diff --git a/goofy-server/src/test/java/de/itvsh/goofy/postfach/PostfachMailRemoteServiceTest.java b/goofy-server/src/test/java/de/itvsh/goofy/postfach/PostfachMailRemoteServiceTest.java index d0f6efab4612be7185bdd4e8eac0e32efa0f1dbd..3e92af7804a35c62fa2492a9190a0650c93ceae4 100644 --- a/goofy-server/src/test/java/de/itvsh/goofy/postfach/PostfachMailRemoteServiceTest.java +++ b/goofy-server/src/test/java/de/itvsh/goofy/postfach/PostfachMailRemoteServiceTest.java @@ -84,6 +84,11 @@ class PostfachMailRemoteServiceTest { @Captor private ArgumentCaptor<GrpcFindPostfachMailRequest> requestCaptor; + @BeforeEach + void init() { + when(serviceStub.findPostfachMail(any())).thenReturn(GrpcPostfachMailTestFactory.createFindPostfachMailResponse()); + } + @Test void shouldCallStub() { service.findById(PostfachMailTestFactory.NACHRICHT_ID); @@ -106,6 +111,13 @@ class PostfachMailRemoteServiceTest { assertThat(requestCaptor.getValue().getNachrichtId()).isEqualTo(PostfachMailTestFactory.ID); } + + @Test + void shouldCallMapper() { + service.findById(PostfachMailTestFactory.NACHRICHT_ID); + + verify(mapper).toPostfachMail(any()); + } } @Nested