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

OZG-1194 return loaded nachricht

parent 4c113ab9
No related branches found
No related tags found
No related merge requests found
...@@ -52,8 +52,9 @@ class PostfachMailRemoteService { ...@@ -52,8 +52,9 @@ class PostfachMailRemoteService {
} }
public Optional<PostfachMail> findById(PostfachNachrichtId nachrichtId) { public Optional<PostfachMail> findById(PostfachNachrichtId nachrichtId) {
serviceStub.findPostfachMail(buildFindPostfachMailRequest(nachrichtId)); var response = serviceStub.findPostfachMail(buildFindPostfachMailRequest(nachrichtId));
return Optional.empty();
return Optional.ofNullable(response.getNachricht()).map(mailMapper::toPostfachMail);
} }
private GrpcFindPostfachMailRequest buildFindPostfachMailRequest(PostfachNachrichtId nachrichtId) { private GrpcFindPostfachMailRequest buildFindPostfachMailRequest(PostfachNachrichtId nachrichtId) {
......
...@@ -5,6 +5,7 @@ import static de.itvsh.goofy.postfach.PostfachMailTestFactory.*; ...@@ -5,6 +5,7 @@ import static de.itvsh.goofy.postfach.PostfachMailTestFactory.*;
import java.util.Arrays; import java.util.Arrays;
import de.itvsh.ozg.mail.postfach.GrpcDirection; 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.GrpcFindPostfachMailsResponse;
import de.itvsh.ozg.mail.postfach.GrpcPostfachMail; import de.itvsh.ozg.mail.postfach.GrpcPostfachMail;
...@@ -36,4 +37,10 @@ public class GrpcPostfachMailTestFactory { ...@@ -36,4 +37,10 @@ public class GrpcPostfachMailTestFactory {
.addAllMails(Arrays.asList(create())) .addAllMails(Arrays.asList(create()))
.build(); .build();
} }
public static GrpcFindPostfachMailResponse createFindPostfachMailResponse() {
return GrpcFindPostfachMailResponse.newBuilder()
.setNachricht(create())
.build();
}
} }
\ No newline at end of file
...@@ -84,6 +84,11 @@ class PostfachMailRemoteServiceTest { ...@@ -84,6 +84,11 @@ class PostfachMailRemoteServiceTest {
@Captor @Captor
private ArgumentCaptor<GrpcFindPostfachMailRequest> requestCaptor; private ArgumentCaptor<GrpcFindPostfachMailRequest> requestCaptor;
@BeforeEach
void init() {
when(serviceStub.findPostfachMail(any())).thenReturn(GrpcPostfachMailTestFactory.createFindPostfachMailResponse());
}
@Test @Test
void shouldCallStub() { void shouldCallStub() {
service.findById(PostfachMailTestFactory.NACHRICHT_ID); service.findById(PostfachMailTestFactory.NACHRICHT_ID);
...@@ -106,6 +111,13 @@ class PostfachMailRemoteServiceTest { ...@@ -106,6 +111,13 @@ class PostfachMailRemoteServiceTest {
assertThat(requestCaptor.getValue().getNachrichtId()).isEqualTo(PostfachMailTestFactory.ID); assertThat(requestCaptor.getValue().getNachrichtId()).isEqualTo(PostfachMailTestFactory.ID);
} }
@Test
void shouldCallMapper() {
service.findById(PostfachMailTestFactory.NACHRICHT_ID);
verify(mapper).toPostfachMail(any());
}
} }
@Nested @Nested
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment