Skip to content
Snippets Groups Projects
Commit 939c7481 authored by Jan Zickermann's avatar Jan Zickermann
Browse files

OZG-4097 receive-attachment: Map to empty list of attachments if null

parent de4b2fe2
Branches
Tags
1 merge request!15Ozg 4097 senden und empfangen von anhängen
Pipeline #1748 failed
Showing with 171 additions and 35 deletions
...@@ -38,14 +38,14 @@ public interface Osi2ResponseMapper { ...@@ -38,14 +38,14 @@ public interface Osi2ResponseMapper {
String POSTFACH_ADDRESS_VERSION = "2.0"; String POSTFACH_ADDRESS_VERSION = "2.0";
int POSTFACH_ADDRESS_TYPE = 2; int POSTFACH_ADDRESS_TYPE = 2;
@Mapping(target = "vorgangId", source = "message.sequencenumber") @Mapping(target = "vorgangId", source = "sequencenumber")
@Mapping(target = "postfachAddress", source = "message.messageBox") @Mapping(target = "postfachAddress", source = "messageBox")
@Mapping(target = "messageId", source = "message.guid") @Mapping(target = "messageId", source = "guid")
@Mapping(target = "createdAt", source = "message.responseTime", qualifiedByName = "mapOffsetDateTimeToZoned") @Mapping(target = "createdAt", source = "responseTime", qualifiedByName = "mapOffsetDateTimeToZoned")
@Mapping(target = "subject", source = "subject") @Mapping(target = "subject", source = "subject")
@Mapping(target = "mailBody", source = ".", qualifiedByName = "mapMailBody") @Mapping(target = "mailBody", source = ".", qualifiedByName = "mapMailBody")
@Mapping(target = "replyOption", source = "replyAction") @Mapping(target = "replyOption", source = "replyAction")
@Mapping(target = "attachments", source = "files") @Mapping(target = "attachments", source = "files", defaultExpression = "java(List.of())")
Osi2Message toMessage(V1ReplyMessage message); Osi2Message toMessage(V1ReplyMessage message);
@Mapping(target = "contentType", source = "mimeType") @Mapping(target = "contentType", source = "mimeType")
......
...@@ -73,7 +73,7 @@ public class PostfachApiFacadeService { ...@@ -73,7 +73,7 @@ public class PostfachApiFacadeService {
quarantineApi.deleteUpload(UUID.fromString(fileUploadId)); quarantineApi.deleteUpload(UUID.fromString(fileUploadId));
} }
public Resource downloadAttachment(String messageId, String attachmentGuid) { public Resource downloadAttachment(String messageGuid, String attachmentGuid) {
return messageExchangeApi.getMessageAttachment(UUID.fromString(messageId), UUID.fromString(attachmentGuid)); return messageExchangeApi.getMessageAttachment(UUID.fromString(messageGuid), UUID.fromString(attachmentGuid));
} }
} }
...@@ -5,7 +5,6 @@ import static de.ozgcloud.nachrichten.NachrichtenManagerConfiguration.*; ...@@ -5,7 +5,6 @@ import static de.ozgcloud.nachrichten.NachrichtenManagerConfiguration.*;
import static de.ozgcloud.nachrichten.postfach.osiv2.factory.JwtFactory.*; import static de.ozgcloud.nachrichten.postfach.osiv2.factory.JwtFactory.*;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import java.time.OffsetDateTime;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.function.Function; import java.util.function.Function;
...@@ -25,6 +24,7 @@ import org.springframework.test.context.TestPropertySource; ...@@ -25,6 +24,7 @@ import org.springframework.test.context.TestPropertySource;
import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
import com.thedeanda.lorem.LoremIpsum;
import de.ozgcloud.nachrichten.postfach.PostfachMessageCode; import de.ozgcloud.nachrichten.postfach.PostfachMessageCode;
import de.ozgcloud.nachrichten.postfach.osiv2.attachment.Osi2AttachmentFileService; import de.ozgcloud.nachrichten.postfach.osiv2.attachment.Osi2AttachmentFileService;
...@@ -37,6 +37,7 @@ import de.ozgcloud.nachrichten.postfach.osiv2.factory.JsonUtil; ...@@ -37,6 +37,7 @@ import de.ozgcloud.nachrichten.postfach.osiv2.factory.JsonUtil;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.MessageExchangeReceiveMessagesResponseTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.MessageExchangeReceiveMessagesResponseTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.MessageExchangeSendMessageResponseTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.MessageExchangeSendMessageResponseTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachNachrichtTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachNachrichtTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.V1ReplyFilesTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.V1ReplyMessageTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.V1ReplyMessageTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.QuarantineFileResult; import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.QuarantineFileResult;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.QuarantineStatus; import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.QuarantineStatus;
...@@ -227,6 +228,12 @@ class OsiPostfachRemoteServiceITCase { ...@@ -227,6 +228,12 @@ class OsiPostfachRemoteServiceITCase {
var messageList = osiPostfachRemoteService.getAllMessages().toList(); var messageList = osiPostfachRemoteService.getAllMessages().toList();
assertThat(messageList).hasSize(1); assertThat(messageList).hasSize(1);
var firstMessage = messageList.getFirst();
assertThat(firstMessage.getAttachments()).hasSize(1);
var fileMetadata = osi2AttachmentFileService.getFileMetadataOfIds(firstMessage.getAttachments());
var firstAttachment = fileMetadata.getFirst();
assertThat(firstAttachment.getName()).isNotBlank();
assertThat(firstAttachment.getContentType()).isEqualTo("text/plain");
} }
@DisplayName("should receive two messages") @DisplayName("should receive two messages")
...@@ -240,23 +247,37 @@ class OsiPostfachRemoteServiceITCase { ...@@ -240,23 +247,37 @@ class OsiPostfachRemoteServiceITCase {
assertThat(messageList).hasSize(2); assertThat(messageList).hasSize(2);
} }
private void mockPostfachMessageAndResponse(final String... uuids) { private void mockPostfachMessageAndResponse(final String... messageGuids) {
// Stub message listing response (MessageExchangeApi::receiveMessages) // Stub message listing response (MessageExchangeApi::receiveMessages)
postfachFacadeMockServer.stubFor(get(urlPathEqualTo("/MessageExchange/v1/Receive")) postfachFacadeMockServer.stubFor(get(urlPathEqualTo("/MessageExchange/v1/Receive"))
.withQueryParam("take", equalTo("100")) .withQueryParam("take", equalTo("100"))
.withQueryParam("skip", equalTo("0")) .withQueryParam("skip", equalTo("0"))
.willReturn(okJsonObj(MessageExchangeReceiveMessagesResponseTestFactory.create(uuids))) .willReturn(okJsonObj(MessageExchangeReceiveMessagesResponseTestFactory.create(messageGuids)))
); );
for (String uuid : uuids) { for (String messageGuid : messageGuids) {
var attachmentText = LoremIpsum.getInstance().getParagraphs(10, 20);
var attachment = V1ReplyFilesTestFactory.createBuilder()
.guid(UUID.randomUUID())
.name(LoremIpsum.getInstance().getName() + ".txt")
.build();
// Stub individual response for message (MessageExchangeApi::getMessage) // Stub individual response for message (MessageExchangeApi::getMessage)
postfachFacadeMockServer.stubFor(get(urlPathTemplate("/MessageExchange/v1/Receive/{messageId}")) postfachFacadeMockServer.stubFor(get(urlPathTemplate("/MessageExchange/v1/Receive/{messageId}"))
.withPathParam("messageId", equalTo(uuid)) .withPathParam("messageId", equalTo(messageGuid))
.willReturn(okJsonObj( .willReturn(okJsonObj(V1ReplyMessageTestFactory.create()
V1ReplyMessageTestFactory.create() .guid(UUID.fromString(messageGuid))
.messageBox(UUID.fromString(uuid)) .files(List.of(attachment))
.responseTime(OffsetDateTime.now())
)) ))
); );
// Stub attachment response (MessageExchangeApi::getMessageAttachment)
postfachFacadeMockServer.stubFor(get(urlPathTemplate("/MessageExchange/v1/Receive/{messageId}/Attachment/{attachmentId}"))
.withPathParam("messageId", equalTo(messageGuid))
.withPathParam("attachmentId", equalTo(attachment.getGuid().toString()))
.willReturn(ok()
.withHeader("Content-Type", "application/octet-stream")
.withBody(attachmentText.getBytes())
)
);
} }
} }
......
...@@ -17,7 +17,7 @@ public class AttachmentExampleUploadUtil { ...@@ -17,7 +17,7 @@ public class AttachmentExampleUploadUtil {
public static String uploadTextFile(Osi2AttachmentFileService remoteService) { public static String uploadTextFile(Osi2AttachmentFileService remoteService) {
return remoteService.uploadFileAndReturnId(AttachmentFile.builder() return remoteService.uploadFileAndReturnId(AttachmentFile.builder()
.contentType("test/plain") .contentType("text/plain")
.name("test.txt") .name("test.txt")
.vorgangId(UUID.randomUUID().toString()) .vorgangId(UUID.randomUUID().toString())
.build(), new ByteArrayInputStream(EXAMPLE_TEXT_DATA)); .build(), new ByteArrayInputStream(EXAMPLE_TEXT_DATA));
......
package de.ozgcloud.nachrichten.postfach.osiv2.factory;
import java.util.UUID;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1ReplyFiles;
public class V1ReplyFilesTestFactory {
public static final String ATTACHMENT_GUID = UUID.randomUUID().toString();
public static final String ATTACHMENT_NAME = "test.txt";
public static final String ATTACHMENT_CONTENT_TYPE = "text/plain";
public static final Long ATTACHMENT_SIZE = 1000L;
public static V1ReplyFiles create() {
return createBuilder().build();
}
public static V1ReplyFiles.Builder createBuilder() {
return V1ReplyFiles.builder()
.guid(UUID.fromString(ATTACHMENT_GUID))
.name(ATTACHMENT_NAME)
.mimeType(ATTACHMENT_CONTENT_TYPE)
.size(ATTACHMENT_SIZE);
}
}
...@@ -2,6 +2,7 @@ package de.ozgcloud.nachrichten.postfach.osiv2.factory; ...@@ -2,6 +2,7 @@ package de.ozgcloud.nachrichten.postfach.osiv2.factory;
import java.time.OffsetDateTime; import java.time.OffsetDateTime;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1EidasLevel; import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1EidasLevel;
...@@ -23,14 +24,20 @@ public class V1ReplyMessageTestFactory { ...@@ -23,14 +24,20 @@ public class V1ReplyMessageTestFactory {
public static final ZonedDateTime RESPONSE_TIME = ZonedDateTime.now(); public static final ZonedDateTime RESPONSE_TIME = ZonedDateTime.now();
public static V1ReplyMessage create() { public static V1ReplyMessage create() {
return new V1ReplyMessage() return createBuilder().build();
}
public static V1ReplyMessage.Builder createBuilder() {
return V1ReplyMessage.builder()
.sequencenumber(SEQUENCE_NUMMER) .sequencenumber(SEQUENCE_NUMMER)
.subject(SUBJECT) .subject(SUBJECT)
.replyAction(V1ReplyBehavior.REPLYPOSSIBLE) .replyAction(V1ReplyBehavior.REPLYPOSSIBLE)
.isObligatory(false) .isObligatory(false)
.eidasLevel(V1EidasLevel.LOW) .eidasLevel(V1EidasLevel.LOW)
.isHtml(false) .isHtml(false)
.body(REPLY_BODY)
.guid(UUID.fromString(MESSAGE_ID)) .guid(UUID.fromString(MESSAGE_ID))
.files(List.of(V1ReplyFilesTestFactory.create()))
.messageBox(UUID.fromString(MESSAGE_BOX_ID)) .messageBox(UUID.fromString(MESSAGE_BOX_ID))
.responseTime(OffsetDateTime.of(RESPONSE_TIME.toLocalDateTime(), RESPONSE_TIME.getOffset())); .responseTime(OffsetDateTime.of(RESPONSE_TIME.toLocalDateTime(), RESPONSE_TIME.getOffset()));
} }
......
package de.ozgcloud.nachrichten.postfach.osiv2.transfer; package de.ozgcloud.nachrichten.postfach.osiv2.transfer;
import static de.ozgcloud.nachrichten.postfach.osiv2.factory.QuarantineFileResultTestFactory.*; import static de.ozgcloud.nachrichten.postfach.osiv2.factory.QuarantineFileResultTestFactory.*;
import static de.ozgcloud.nachrichten.postfach.osiv2.factory.V1ReplyFilesTestFactory.*;
import static de.ozgcloud.nachrichten.postfach.osiv2.factory.V1ReplyMessageTestFactory.*; import static de.ozgcloud.nachrichten.postfach.osiv2.factory.V1ReplyMessageTestFactory.*;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
...@@ -21,10 +22,13 @@ import de.ozgcloud.nachrichten.postfach.osiv2.exception.Osi2RuntimeException; ...@@ -21,10 +22,13 @@ import de.ozgcloud.nachrichten.postfach.osiv2.exception.Osi2RuntimeException;
import de.ozgcloud.nachrichten.postfach.osiv2.exception.Osi2UploadException; import de.ozgcloud.nachrichten.postfach.osiv2.exception.Osi2UploadException;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.Osi2FileUploadTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.Osi2FileUploadTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.QuarantineFileResultTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.QuarantineFileResultTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.V1ReplyFilesTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.V1ReplyMessageTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.V1ReplyMessageTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.QuarantineStatus; import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.QuarantineStatus;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1ReplyBehavior; import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1ReplyBehavior;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1ReplyFiles;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1ReplyMessage; import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1ReplyMessage;
import de.ozgcloud.nachrichten.postfach.osiv2.model.AttachmentInfo;
import de.ozgcloud.nachrichten.postfach.osiv2.model.Osi2Message; import de.ozgcloud.nachrichten.postfach.osiv2.model.Osi2Message;
import lombok.SneakyThrows; import lombok.SneakyThrows;
...@@ -34,9 +38,9 @@ class Osi2ResponseMapperTest { ...@@ -34,9 +38,9 @@ class Osi2ResponseMapperTest {
private Osi2ResponseMapper mapper = Mappers.getMapper(Osi2ResponseMapper.class); private Osi2ResponseMapper mapper = Mappers.getMapper(Osi2ResponseMapper.class);
private final V1ReplyMessage message = V1ReplyMessageTestFactory.create(); private final V1ReplyMessage message = V1ReplyMessageTestFactory.create();
@DisplayName("map V1ReplyMessage to Osi2Message") @DisplayName("toMessage")
@Nested @Nested
class V1ReplyOsi2MessageToOsi2Message { class TestToMessage {
@Test @Test
void shouldMapVorgangId() { void shouldMapVorgangId() {
...@@ -69,7 +73,11 @@ class Osi2ResponseMapperTest { ...@@ -69,7 +73,11 @@ class Osi2ResponseMapperTest {
@Test @Test
void shouldMapNullBodyToEmptyString() { void shouldMapNullBodyToEmptyString() {
var result = doMapping(); var noBodyMessage = V1ReplyMessageTestFactory.createBuilder()
.body(null)
.build();
var result = mapper.toMessage(noBodyMessage);
assertThat(result.mailBody()).isEmpty(); assertThat(result.mailBody()).isEmpty();
} }
...@@ -77,9 +85,10 @@ class Osi2ResponseMapperTest { ...@@ -77,9 +85,10 @@ class Osi2ResponseMapperTest {
@DisplayName("should map modified HTML body if HTML message") @DisplayName("should map modified HTML body if HTML message")
@Test @Test
void shouldMapModifiedHtmlBodyIfHtmlMessage() { void shouldMapModifiedHtmlBodyIfHtmlMessage() {
var htmlMessage = V1ReplyMessageTestFactory.create() var htmlMessage = V1ReplyMessageTestFactory.createBuilder()
.body(HTML_REPLY_BODY) .body(HTML_REPLY_BODY)
.isHtml(true); .isHtml(true)
.build();
var result = mapper.toMessage(htmlMessage); var result = mapper.toMessage(htmlMessage);
...@@ -90,9 +99,10 @@ class Osi2ResponseMapperTest { ...@@ -90,9 +99,10 @@ class Osi2ResponseMapperTest {
@ParameterizedTest @ParameterizedTest
@ValueSource(strings = { REPLY_BODY, HTML_REPLY_BODY }) @ValueSource(strings = { REPLY_BODY, HTML_REPLY_BODY })
void shouldMapUnmodifiedBodyIfNotHtmlMessage(String body) { void shouldMapUnmodifiedBodyIfNotHtmlMessage(String body) {
var htmlMessage = V1ReplyMessageTestFactory.create() var htmlMessage = V1ReplyMessageTestFactory.createBuilder()
.body(body) .body(body)
.isHtml(false); .isHtml(false)
.build();
var result = mapper.toMessage(htmlMessage); var result = mapper.toMessage(htmlMessage);
...@@ -111,9 +121,10 @@ class Osi2ResponseMapperTest { ...@@ -111,9 +121,10 @@ class Osi2ResponseMapperTest {
@ParameterizedTest @ParameterizedTest
@MethodSource("replyOptionValues") @MethodSource("replyOptionValues")
void shouldMapReplyOption(V1ReplyBehavior replyAction, PostfachNachricht.ReplyOption expected) { void shouldMapReplyOption(V1ReplyBehavior replyAction, PostfachNachricht.ReplyOption expected) {
var replyActionMessage = V1ReplyMessageTestFactory.create() var replyActionMessage = V1ReplyMessageTestFactory.createBuilder()
.replyAction(replyAction) .replyAction(replyAction)
.isHtml(false); .isHtml(false)
.build();
var result = mapper.toMessage(replyActionMessage); var result = mapper.toMessage(replyActionMessage);
...@@ -128,6 +139,32 @@ class Osi2ResponseMapperTest { ...@@ -128,6 +139,32 @@ class Osi2ResponseMapperTest {
assertThat(result.messageId()).isEqualTo(MESSAGE_ID); assertThat(result.messageId()).isEqualTo(MESSAGE_ID);
} }
@DisplayName("should map attachments")
@Test
void shouldMapAttachments() {
assert message.getFiles() != null;
var expectedAttachments = message.getFiles()
.stream()
.map(file -> mapper.toAttachmentInfo(file))
.toList();
var result = doMapping();
assertThat(result.attachments()).usingRecursiveComparison().isEqualTo(expectedAttachments);
}
@DisplayName("should map null attachments to empty list")
@Test
void shouldMapNullAttachmentsToEmptyList() {
var messageWithoutAttachments = V1ReplyMessageTestFactory.createBuilder()
.files(null)
.build();
var result = mapper.toMessage(messageWithoutAttachments);
assertThat(result.attachments()).isEmpty();
}
@DisplayName("should not fail if all fields are null") @DisplayName("should not fail if all fields are null")
@Test @Test
void shouldNotFailIfAllFieldsAreNull() { void shouldNotFailIfAllFieldsAreNull() {
...@@ -152,6 +189,49 @@ class Osi2ResponseMapperTest { ...@@ -152,6 +189,49 @@ class Osi2ResponseMapperTest {
} }
} }
@DisplayName("to AttachmentInfo")
@Nested
class TestToAttachmentInfo {
private final V1ReplyFiles file = V1ReplyFilesTestFactory.create();
@DisplayName("should map guid")
@Test
void shouldMapGuid() {
var result = doMapping();
assertThat(result.guid()).isEqualTo(ATTACHMENT_GUID);
}
@DisplayName("should map name")
@Test
void shouldMapName() {
var result = doMapping();
assertThat(result.name()).isEqualTo(ATTACHMENT_NAME);
}
@DisplayName("should map size")
@Test
void shouldMapSize() {
var result = doMapping();
assertThat(result.size()).isEqualTo(ATTACHMENT_SIZE);
}
@DisplayName("should map content type")
@Test
void shouldMapContentType() {
var result = doMapping();
assertThat(result.contentType()).isEqualTo(ATTACHMENT_CONTENT_TYPE);
}
private AttachmentInfo doMapping() {
return mapper.toAttachmentInfo(file);
}
}
@DisplayName("is safe") @DisplayName("is safe")
@Nested @Nested
class TestIsSafe { class TestIsSafe {
......
...@@ -25,6 +25,7 @@ import de.ozgcloud.nachrichten.postfach.osiv2.factory.MessageExchangeReceiveMess ...@@ -25,6 +25,7 @@ import de.ozgcloud.nachrichten.postfach.osiv2.factory.MessageExchangeReceiveMess
import de.ozgcloud.nachrichten.postfach.osiv2.factory.Osi2FileUploadTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.Osi2FileUploadTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.Osi2MessageTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.Osi2MessageTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachNachrichtTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachNachrichtTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.V1ReplyMessageTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.api.MessageExchangeApi; import de.ozgcloud.nachrichten.postfach.osiv2.gen.api.MessageExchangeApi;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.api.QuarantineApi; import de.ozgcloud.nachrichten.postfach.osiv2.gen.api.QuarantineApi;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.DomainChunkMetaData; import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.DomainChunkMetaData;
...@@ -36,6 +37,7 @@ import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.QuarantineStatus; ...@@ -36,6 +37,7 @@ import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.QuarantineStatus;
import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1ReplyMessage; import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1ReplyMessage;
import de.ozgcloud.nachrichten.postfach.osiv2.model.FileChunkInfo; import de.ozgcloud.nachrichten.postfach.osiv2.model.FileChunkInfo;
import de.ozgcloud.nachrichten.postfach.osiv2.model.Osi2Attachment; import de.ozgcloud.nachrichten.postfach.osiv2.model.Osi2Attachment;
import de.ozgcloud.nachrichten.postfach.osiv2.model.Osi2Message;
import lombok.SneakyThrows; import lombok.SneakyThrows;
class PostfachApiFacadeServiceTest { class PostfachApiFacadeServiceTest {
...@@ -179,8 +181,8 @@ class PostfachApiFacadeServiceTest { ...@@ -179,8 +181,8 @@ class PostfachApiFacadeServiceTest {
@Nested @Nested
class TestFetchMessageById { class TestFetchMessageById {
@Mock private final V1ReplyMessage replyMessage = V1ReplyMessageTestFactory.create();
V1ReplyMessage replyMessage; private final Osi2Message message = Osi2MessageTestFactory.create();
@Test @Test
void shouldCallGetMessage() { void shouldCallGetMessage() {
...@@ -188,7 +190,7 @@ class PostfachApiFacadeServiceTest { ...@@ -188,7 +190,7 @@ class PostfachApiFacadeServiceTest {
service.fetchMessageById(MESSAGE_ID_1); service.fetchMessageById(MESSAGE_ID_1);
verify(messageExchangeApi).getMessage(any()); verify(messageExchangeApi).getMessage(UUID.fromString(MESSAGE_ID_1));
} }
@Test @Test
...@@ -198,17 +200,18 @@ class PostfachApiFacadeServiceTest { ...@@ -198,17 +200,18 @@ class PostfachApiFacadeServiceTest {
service.fetchMessageById(MESSAGE_ID_1); service.fetchMessageById(MESSAGE_ID_1);
verify(osi2ResponseMapper).toMessage(any()); verify(osi2ResponseMapper).toMessage(replyMessage);
} }
@DisplayName("should return")
@Test @Test
void shouldReturnPostfachNachricht() { void shouldReturn() {
when(messageExchangeApi.getMessage(any())).thenReturn(replyMessage); when(messageExchangeApi.getMessage(any())).thenReturn(replyMessage);
when(osi2ResponseMapper.toMessage(any())).thenReturn(Osi2MessageTestFactory.create()); when(osi2ResponseMapper.toMessage(any())).thenReturn(message);
var message = service.fetchMessageById(MESSAGE_ID_1); var result = service.fetchMessageById(MESSAGE_ID_1);
assertThat(message).isEqualTo(Osi2MessageTestFactory.create()); assertThat(result).isEqualTo(message);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment