From 6a989f0bb5b04f6d7185e55a73bedb9e30f7baf7 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Thu, 20 Feb 2025 13:18:41 +0100 Subject: [PATCH] OZG-4097 pom: Update nachrichten-manager version --- pom.xml | 10 +- .../attachment/Osi2AttachmentFileMapper.java | 5 +- .../attachment/Osi2AttachmentFileService.java | 5 +- .../Osi2PersistAttachmentService.java | 2 +- .../osiv2/config/Osi2PostfachProperties.java | 2 + .../osiv2/exception/Osi2ExceptionHandler.java | 1 - .../postfach/osiv2/model/AttachmentFile.java | 10 ++ .../osiv2/transfer/Osi2RequestMapper.java | 6 +- .../osiv2/transfer/Osi2ResponseMapper.java | 24 +--- .../osiv2/OsiPostfachRemoteServiceITCase.java | 2 +- .../OsiPostfachRemoteServiceRemoteITCase.java | 9 +- .../postfach/osiv2/TestApplication.java | 17 ++- .../Osi2AttachmentFileMapperTest.java | 108 ++++++++++++++++++ .../AttachmentExampleUploadUtil.java | 2 +- .../factory/AttachmentFileTestFactory.java | 21 ++++ .../factory/DummyStringBasedIdentifier.java | 23 ---- .../osiv2/factory/GrpcOzgFileTestFactory.java | 24 ++++ .../factory/PostfachAddressTestFactory.java | 5 +- .../osiv2/transfer/Osi2RequestMapperTest.java | 6 - 19 files changed, 196 insertions(+), 86 deletions(-) create mode 100644 src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/model/AttachmentFile.java create mode 100644 src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileMapperTest.java create mode 100644 src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/AttachmentFileTestFactory.java delete mode 100644 src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/DummyStringBasedIdentifier.java create mode 100644 src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/GrpcOzgFileTestFactory.java diff --git a/pom.xml b/pom.xml index dba3c05..707857d 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ <properties> <api-lib.version>0.16.0</api-lib.version> - <nachrichten-manager.version>2.17.0-SNAPSHOT</nachrichten-manager.version> + <nachrichten-manager-postfach-interface.version>2.18.0-SNAPSHOT</nachrichten-manager-postfach-interface.version> <openapi-generator.version>7.11.0</openapi-generator.version> <swagger-parser.version>2.1.23</swagger-parser.version> <wiremock.version>3.12.0</wiremock.version> @@ -34,14 +34,8 @@ <dependency> <groupId>de.ozgcloud.nachrichten</groupId> <artifactId>nachrichten-manager-postfach-interface</artifactId> - <version>${nachrichten-manager.version}</version> + <version>${nachrichten-manager-postfach-interface.version}</version> </dependency> - <dependency> - <groupId>de.ozgcloud.nachrichten</groupId> - <artifactId>nachrichten-manager-server</artifactId> - <version>${nachrichten-manager.version}</version> - </dependency> - <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> diff --git a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileMapper.java b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileMapper.java index 436a70e..74e8433 100644 --- a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileMapper.java +++ b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileMapper.java @@ -7,8 +7,7 @@ import org.mapstruct.ReportingPolicy; import de.ozgcloud.apilib.file.OzgCloudFile; import de.ozgcloud.apilib.file.OzgCloudFileId; import de.ozgcloud.apilib.file.OzgCloudUploadFile; -import de.ozgcloud.nachrichten.file.AttachmentFile; -import de.ozgcloud.nachrichten.postfach.osiv2.model.AttachmentInfo; +import de.ozgcloud.nachrichten.postfach.osiv2.model.AttachmentFile; import de.ozgcloud.vorgang.grpc.file.GrpcOzgFile; @Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR) @@ -26,6 +25,4 @@ public interface Osi2AttachmentFileMapper { @Mapping(target = "fieldName", constant = ATTACHMENT_FIELD_NAME) OzgCloudUploadFile toOzgCloudUploadFile(AttachmentFile attachmentFile); - AttachmentFile createAttachmentFile(AttachmentInfo attachment, String vorgangId); - } diff --git a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileService.java b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileService.java index 311c84e..5029aa3 100644 --- a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileService.java +++ b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileService.java @@ -1,18 +1,17 @@ package de.ozgcloud.nachrichten.postfach.osiv2.attachment; -import static de.ozgcloud.nachrichten.NachrichtenManagerConfiguration.*; +import static de.ozgcloud.nachrichten.postfach.osiv2.config.Osi2PostfachProperties.*; import java.io.InputStream; import java.util.Iterator; import java.util.List; -import java.util.function.Supplier; import de.ozgcloud.apilib.common.callcontext.OzgCloudCallContextAttachingInterceptor; import de.ozgcloud.apilib.common.callcontext.OzgCloudCallContextProvider; import de.ozgcloud.apilib.file.OzgCloudFile; import de.ozgcloud.apilib.file.OzgCloudFileService; -import de.ozgcloud.nachrichten.file.AttachmentFile; import de.ozgcloud.nachrichten.postfach.osiv2.ServiceIfOsi2Enabled; +import de.ozgcloud.nachrichten.postfach.osiv2.model.AttachmentFile; import de.ozgcloud.vorgang.grpc.binaryFile.BinaryFileServiceGrpc; import de.ozgcloud.vorgang.grpc.binaryFile.GrpcBinaryFilesRequest; import de.ozgcloud.vorgang.grpc.binaryFile.GrpcGetBinaryFileDataRequest; diff --git a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2PersistAttachmentService.java b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2PersistAttachmentService.java index d58e1ff..5e56103 100644 --- a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2PersistAttachmentService.java +++ b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2PersistAttachmentService.java @@ -5,7 +5,7 @@ import java.util.List; import org.springframework.core.io.Resource; -import de.ozgcloud.nachrichten.file.AttachmentFile; +import de.ozgcloud.nachrichten.postfach.osiv2.model.AttachmentFile; import de.ozgcloud.nachrichten.postfach.osiv2.ServiceIfOsi2Enabled; import de.ozgcloud.nachrichten.postfach.osiv2.exception.Osi2RuntimeException; import de.ozgcloud.nachrichten.postfach.osiv2.model.AttachmentInfo; diff --git a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/config/Osi2PostfachProperties.java b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/config/Osi2PostfachProperties.java index f670ec7..0329d8c 100644 --- a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/config/Osi2PostfachProperties.java +++ b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/config/Osi2PostfachProperties.java @@ -18,6 +18,8 @@ import lombok.Setter; @ConditionalOnProperty(prefix = Osi2PostfachProperties.PREFIX, name = "enabled", havingValue = "true") @RequiredArgsConstructor public class Osi2PostfachProperties { + // From de.ozgcloud.nachrichten.NachrichtenManagerConfiguration + public static final String GRPC_FILE_MANAGER_NAME = "file-manager"; public static final String PREFIX = "ozgcloud.osiv2"; diff --git a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/exception/Osi2ExceptionHandler.java b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/exception/Osi2ExceptionHandler.java index 1c1dc73..b90e797 100644 --- a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/exception/Osi2ExceptionHandler.java +++ b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/exception/Osi2ExceptionHandler.java @@ -20,7 +20,6 @@ public class Osi2ExceptionHandler { if (exception instanceof ResourceAccessException) { return PostfachMessageCode.SERVER_CONNECTION_FAILED_MESSAGE_CODE; } - // TODO KOP-3021 add message code for unsafe upload file return PostfachMessageCode.PROCESS_FAILED_MESSAGE_CODE; } diff --git a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/model/AttachmentFile.java b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/model/AttachmentFile.java new file mode 100644 index 0000000..2486622 --- /dev/null +++ b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/model/AttachmentFile.java @@ -0,0 +1,10 @@ +package de.ozgcloud.nachrichten.postfach.osiv2.model; +import lombok.Builder; + +@Builder +public record AttachmentFile( + String name, + String contentType, + String vorgangId +) { +} diff --git a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2RequestMapper.java b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2RequestMapper.java index 2f22828..86aa86d 100644 --- a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2RequestMapper.java +++ b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2RequestMapper.java @@ -87,10 +87,8 @@ public interface Osi2RequestMapper { default String mapMailboxId(PostfachNachricht nachricht) { return Optional.ofNullable(nachricht.getPostfachAddress()) .map(PostfachAddress::getIdentifier) - .filter(PostfachAddressIdentifier::isStringBasedIdentifier) - .map(Object::toString) - .orElseThrow(() -> new IllegalArgumentException( - "Missing MailboxId! Expect MailboxId to be a string-based PostfachAddress of PostfachNachricht.")); + .map(PostfachAddressIdentifier::getStringRepresentation) + .orElseThrow(() -> new IllegalArgumentException("Missing MailboxId!")); } } diff --git a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2ResponseMapper.java b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2ResponseMapper.java index dbbdf6a..74a34e0 100644 --- a/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2ResponseMapper.java +++ b/src/main/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2ResponseMapper.java @@ -14,8 +14,8 @@ import org.mapstruct.Named; import org.mapstruct.ReportingPolicy; import de.ozgcloud.nachrichten.postfach.PostfachAddress; -import de.ozgcloud.nachrichten.postfach.PostfachAddressIdentifier; import de.ozgcloud.nachrichten.postfach.PostfachNachricht; +import de.ozgcloud.nachrichten.postfach.StringBasedIdentifier; import de.ozgcloud.nachrichten.postfach.osiv2.OsiPostfachRemoteService; import de.ozgcloud.nachrichten.postfach.osiv2.exception.Osi2RuntimeException; import de.ozgcloud.nachrichten.postfach.osiv2.exception.Osi2UploadException; @@ -29,8 +29,6 @@ import de.ozgcloud.nachrichten.postfach.osiv2.gen.model.V1ReplyFiles; 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 lombok.Builder; -import lombok.Getter; @Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR, imports = { Osi2HtmlDocument.class }) public interface Osi2ResponseMapper { @@ -55,7 +53,6 @@ public interface Osi2ResponseMapper { return value == null ? "" : value; } - @Named("mapOffsetDateTimeToZoned") default ZonedDateTime mapOffsetDateTimeToZoned(OffsetDateTime offsetDateTime) { return offsetDateTime == null ? null : offsetDateTime.toZonedDateTime(); @@ -76,7 +73,7 @@ public interface Osi2ResponseMapper { .type(POSTFACH_ADDRESS_TYPE) .version(POSTFACH_ADDRESS_VERSION) .identifier(StringBasedIdentifier.builder() - .mailboxId(messageBox.toString()) + .postfachId(messageBox.toString()) .build()) .serviceKontoType(OsiPostfachRemoteService.POSTFACH_TYPE_OSI) .build(); @@ -130,21 +127,4 @@ public interface Osi2ResponseMapper { .orElse(null); } - - @Builder - @Getter - class StringBasedIdentifier implements PostfachAddressIdentifier { - - private String mailboxId; - - @Override - public boolean isStringBasedIdentifier() { - return true; - } - - @Override - public String toString() { - return mailboxId; - } - } } diff --git a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/OsiPostfachRemoteServiceITCase.java b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/OsiPostfachRemoteServiceITCase.java index 79c86ce..cf4e572 100644 --- a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/OsiPostfachRemoteServiceITCase.java +++ b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/OsiPostfachRemoteServiceITCase.java @@ -1,7 +1,7 @@ package de.ozgcloud.nachrichten.postfach.osiv2; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static de.ozgcloud.nachrichten.NachrichtenManagerConfiguration.*; +import static de.ozgcloud.nachrichten.postfach.osiv2.config.Osi2PostfachProperties.*; import static de.ozgcloud.nachrichten.postfach.osiv2.factory.JwtFactory.*; import static org.assertj.core.api.Assertions.*; diff --git a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/OsiPostfachRemoteServiceRemoteITCase.java b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/OsiPostfachRemoteServiceRemoteITCase.java index 2cbc582..f9aa6ea 100644 --- a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/OsiPostfachRemoteServiceRemoteITCase.java +++ b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/OsiPostfachRemoteServiceRemoteITCase.java @@ -1,10 +1,9 @@ package de.ozgcloud.nachrichten.postfach.osiv2; -import static de.ozgcloud.nachrichten.NachrichtenManagerConfiguration.*; +import static de.ozgcloud.nachrichten.postfach.osiv2.config.Osi2PostfachProperties.*; import static org.assertj.core.api.Assertions.*; import java.util.Arrays; -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -17,10 +16,10 @@ import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; import de.ozgcloud.nachrichten.postfach.PostfachNachricht; +import de.ozgcloud.nachrichten.postfach.StringBasedIdentifier; import de.ozgcloud.nachrichten.postfach.osiv2.attachment.Osi2AttachmentFileService; import de.ozgcloud.nachrichten.postfach.osiv2.extension.AttachmentExampleUploadUtil; import de.ozgcloud.nachrichten.postfach.osiv2.extension.VorgangManagerServerExtension; -import de.ozgcloud.nachrichten.postfach.osiv2.factory.DummyStringBasedIdentifier; import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachAddressTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachNachrichtTestFactory; import lombok.SneakyThrows; @@ -67,8 +66,8 @@ class OsiPostfachRemoteServiceRemoteITCase { .replyOption(PostfachNachricht.ReplyOption.POSSIBLE) .attachments(Arrays.stream(attachmentIds).toList()) .postfachAddress(PostfachAddressTestFactory.createBuilder() - .identifier(DummyStringBasedIdentifier.builder() - .mailboxId("49b5a7e2-5e60-4baf-8ccf-1f5b94b570f3") + .identifier(StringBasedIdentifier.builder() + .postfachId("49b5a7e2-5e60-4baf-8ccf-1f5b94b570f3") .build()) .build()) .build(); diff --git a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/TestApplication.java b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/TestApplication.java index 2a3358f..ab1c656 100644 --- a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/TestApplication.java +++ b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/TestApplication.java @@ -1,6 +1,6 @@ package de.ozgcloud.nachrichten.postfach.osiv2; -import static de.ozgcloud.nachrichten.NachrichtenManagerConfiguration.*; +import static de.ozgcloud.nachrichten.postfach.osiv2.config.Osi2PostfachProperties.*; import org.mapstruct.factory.Mappers; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -13,7 +13,6 @@ import de.ozgcloud.apilib.file.OzgCloudFileService; import de.ozgcloud.apilib.file.grpc.GrpcOzgCloudFileService; import de.ozgcloud.apilib.file.grpc.OzgCloudFileMapper; import de.ozgcloud.apilib.vorgang.OzgCloudUserIdMapper; -import de.ozgcloud.nachrichten.common.grpc.NachrichtenCallContextAttachingInterceptor; import de.ozgcloud.vorgang.grpc.binaryFile.BinaryFileServiceGrpc; import net.devh.boot.grpc.client.inject.GrpcClient; @@ -21,6 +20,13 @@ import net.devh.boot.grpc.client.inject.GrpcClient; @AutoConfiguration public class TestApplication { + // From de.ozgcloud.nachrichten.common.grpc.NachrichtenCallContextAttachingInterceptor + public static final String NACHRICHTEN_MANAGER_CLIENT_NAME = "OzgCloud_NachrichtenManager"; + public static final String NACHRICHTEN_MANAGER_SENDER_USER_ID = "system-nachrichten_manager-sender"; + + // From de.ozgcloud.nachrichten.NachrichtenManagerConfiguration + public static final String OZG_CLOUD_FILE_SERVICE_NAME = "nachrichten_OzgCloudFileService"; + @GrpcClient(GRPC_FILE_MANAGER_NAME) private BinaryFileServiceGrpc.BinaryFileServiceBlockingStub fileServiceBlockingStub; @GrpcClient(GRPC_FILE_MANAGER_NAME) @@ -29,12 +35,13 @@ public class TestApplication { @Bean OzgCloudCallContextProvider ozgCloudCallContextProvider() { var userIdMapper = Mappers.getMapper(OzgCloudUserIdMapper.class); - return () -> CallContext.builder().clientName(NachrichtenCallContextAttachingInterceptor.NACHRICHTEN_MANAGER_CLIENT_NAME) - .userId(userIdMapper.toUserId(NachrichtenCallContextAttachingInterceptor.NACHRICHTEN_MANAGER_SENDER_USER_ID)).build(); + return () -> CallContext.builder().clientName(NACHRICHTEN_MANAGER_CLIENT_NAME) + .userId(userIdMapper.toUserId(NACHRICHTEN_MANAGER_SENDER_USER_ID)).build(); } @Bean(OZG_CLOUD_FILE_SERVICE_NAME) OzgCloudFileService grpcOzgCloudFileService(OzgCloudCallContextProvider contextProvider) { - return new GrpcOzgCloudFileService(fileServiceBlockingStub, fileServiceAsyncServiceStub, contextProvider, Mappers.getMapper(OzgCloudFileMapper.class)); + return new GrpcOzgCloudFileService(fileServiceBlockingStub, fileServiceAsyncServiceStub, contextProvider, + Mappers.getMapper(OzgCloudFileMapper.class)); } } diff --git a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileMapperTest.java b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileMapperTest.java new file mode 100644 index 0000000..8370879 --- /dev/null +++ b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/attachment/Osi2AttachmentFileMapperTest.java @@ -0,0 +1,108 @@ +package de.ozgcloud.nachrichten.postfach.osiv2.attachment; + +import static de.ozgcloud.nachrichten.postfach.osiv2.factory.AttachmentFileTestFactory.*; +import static de.ozgcloud.nachrichten.postfach.osiv2.factory.Osi2FileUploadTestFactory.*; +import static org.assertj.core.api.Assertions.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mapstruct.factory.Mappers; + +import de.ozgcloud.apilib.file.OzgCloudFile; +import de.ozgcloud.apilib.file.OzgCloudUploadFile; +import de.ozgcloud.nachrichten.postfach.osiv2.factory.AttachmentFileTestFactory; +import de.ozgcloud.nachrichten.postfach.osiv2.factory.GrpcOzgFileTestFactory; +import de.ozgcloud.nachrichten.postfach.osiv2.model.AttachmentFile; +import de.ozgcloud.vorgang.grpc.file.GrpcOzgFile; + +class Osi2AttachmentFileMapperTest { + + private final Osi2AttachmentFileMapper mapper = Mappers.getMapper(Osi2AttachmentFileMapper.class); + + @DisplayName("map to upload file metadata") + @Nested + class TestMapToUploadFileMetadata { + + private final GrpcOzgFile grpcOzgFile = GrpcOzgFileTestFactory.create(); + + @DisplayName("should map id") + @Test + void shouldMapId() { + var result = doMapping(); + + assertThat(result.getId()).hasToString(grpcOzgFile.getId()); + } + + @DisplayName("should map name") + @Test + void shouldMapName() { + var result = doMapping(); + + assertThat(result.getName()).isEqualTo(grpcOzgFile.getName()); + } + + @DisplayName("should map contentType") + @Test + void shouldMapContentType() { + var result = doMapping(); + + assertThat(result.getContentType()).isEqualTo(grpcOzgFile.getContentType()); + } + + @DisplayName("should map size") + @Test + void shouldMapSize() { + var result = doMapping(); + + assertThat(result.getSize()).isEqualTo(grpcOzgFile.getSize()); + } + + private OzgCloudFile doMapping() { + return mapper.mapToUploadFileMetadata(grpcOzgFile); + } + } + + @DisplayName("to ozg cloud upload file") + @Nested + class TestToOzgCloudUploadFile { + private final AttachmentFile attachmentFile = AttachmentFileTestFactory.create(); + + @DisplayName("should map fileName") + @Test + void shouldMapFileName() { + var result = doMapping(); + + assertThat(result.getFileName()).isEqualTo(UPLOAD_NAME); + } + + @DisplayName("should map contentType") + @Test + void shouldMapContentType() { + var result = doMapping(); + + assertThat(result.getContentType()).isEqualTo(UPLOAD_CONTENT_TYPE); + } + + @DisplayName("should map fieldName") + @Test + void shouldMapFieldName() { + var result = doMapping(); + + assertThat(result.getFieldName()).isEqualTo(Osi2AttachmentFileMapper.ATTACHMENT_FIELD_NAME); + } + + @DisplayName("should map vorgangId") + @Test + void shouldMapVorgangId() { + var result = doMapping(); + + assertThat(result.getVorgangId()).isEqualTo(UPLOAD_VORGANG_ID); + } + + private OzgCloudUploadFile doMapping() { + return mapper.toOzgCloudUploadFile(attachmentFile); + } + } + +} \ No newline at end of file diff --git a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/extension/AttachmentExampleUploadUtil.java b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/extension/AttachmentExampleUploadUtil.java index b8cea08..8aa5491 100644 --- a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/extension/AttachmentExampleUploadUtil.java +++ b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/extension/AttachmentExampleUploadUtil.java @@ -5,8 +5,8 @@ import java.util.UUID; import com.thedeanda.lorem.LoremIpsum; -import de.ozgcloud.nachrichten.file.AttachmentFile; import de.ozgcloud.nachrichten.postfach.osiv2.attachment.Osi2AttachmentFileService; +import de.ozgcloud.nachrichten.postfach.osiv2.model.AttachmentFile; import lombok.extern.log4j.Log4j2; @Log4j2 diff --git a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/AttachmentFileTestFactory.java b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/AttachmentFileTestFactory.java new file mode 100644 index 0000000..1d80639 --- /dev/null +++ b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/AttachmentFileTestFactory.java @@ -0,0 +1,21 @@ +package de.ozgcloud.nachrichten.postfach.osiv2.factory; + +import static de.ozgcloud.nachrichten.postfach.osiv2.factory.Osi2FileUploadTestFactory.*; + +import de.ozgcloud.nachrichten.postfach.osiv2.model.AttachmentFile; + +public class AttachmentFileTestFactory { + + public static final String UPLOAD_VORGANG_ID = "vorgangId1"; + + public static AttachmentFile create() { + return createBuilder().build(); + } + + public static AttachmentFile.AttachmentFileBuilder createBuilder() { + return AttachmentFile.builder() + .name(UPLOAD_NAME) + .contentType(UPLOAD_CONTENT_TYPE) + .vorgangId(UPLOAD_VORGANG_ID); + } +} diff --git a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/DummyStringBasedIdentifier.java b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/DummyStringBasedIdentifier.java deleted file mode 100644 index cc2ef17..0000000 --- a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/DummyStringBasedIdentifier.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.ozgcloud.nachrichten.postfach.osiv2.factory; - -import de.ozgcloud.nachrichten.postfach.PostfachAddressIdentifier; -import lombok.Builder; -import lombok.Getter; - -@Builder -@Getter -public class DummyStringBasedIdentifier implements PostfachAddressIdentifier { - - private String mailboxId; - - @Override - public boolean isStringBasedIdentifier() { - return true; - } - - @Override - public String toString() { - return mailboxId; - } -} - diff --git a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/GrpcOzgFileTestFactory.java b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/GrpcOzgFileTestFactory.java new file mode 100644 index 0000000..d26f681 --- /dev/null +++ b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/GrpcOzgFileTestFactory.java @@ -0,0 +1,24 @@ +package de.ozgcloud.nachrichten.postfach.osiv2.factory; + +import de.ozgcloud.vorgang.grpc.file.GrpcOzgFile; + +public class GrpcOzgFileTestFactory { + + public static final String FILE_ID = "ozgfileId1"; + public static final String FILE_NAME = "ozgfileName1"; + public static final String FILE_CONTENT_TYPE = "ozgfileContentType1"; + public static final Long FILE_SIZE = 124L; + + + public static GrpcOzgFile create() { + return createBuilder().build(); + } + + public static GrpcOzgFile.Builder createBuilder() { + return GrpcOzgFile.newBuilder() + .setId(FILE_ID) + .setName(FILE_NAME) + .setContentType(FILE_CONTENT_TYPE) + .setSize(FILE_SIZE); + } +} diff --git a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/PostfachAddressTestFactory.java b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/PostfachAddressTestFactory.java index 046f298..9b3590d 100644 --- a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/PostfachAddressTestFactory.java +++ b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/factory/PostfachAddressTestFactory.java @@ -1,6 +1,7 @@ package de.ozgcloud.nachrichten.postfach.osiv2.factory; import de.ozgcloud.nachrichten.postfach.PostfachAddress; +import de.ozgcloud.nachrichten.postfach.StringBasedIdentifier; public class PostfachAddressTestFactory { @@ -15,8 +16,8 @@ public class PostfachAddressTestFactory { return PostfachAddress.builder() .type(1) .serviceKontoType("TYPE1") - .identifier(DummyStringBasedIdentifier.builder() - .mailboxId(MAILBOX_ID) + .identifier(StringBasedIdentifier.builder() + .postfachId(MAILBOX_ID) .build()); } } diff --git a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2RequestMapperTest.java b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2RequestMapperTest.java index f62ec8d..bdf27c7 100644 --- a/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2RequestMapperTest.java +++ b/src/test/java/de/ozgcloud/nachrichten/postfach/osiv2/transfer/Osi2RequestMapperTest.java @@ -20,7 +20,6 @@ import org.mapstruct.factory.Mappers; import de.ozgcloud.apilib.file.OzgCloudFileTestFactory; import de.ozgcloud.nachrichten.postfach.PostfachAddress; -import de.ozgcloud.nachrichten.postfach.PostfachAddressIdentifier; import de.ozgcloud.nachrichten.postfach.PostfachNachricht; import de.ozgcloud.nachrichten.postfach.osiv2.factory.FileChunkInfoTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.Osi2FileUploadTestFactory; @@ -67,11 +66,6 @@ class Osi2RequestMapperTest { null, Arguments.of(PostfachAddressTestFactory.createBuilder() .identifier(null) - .build()), - Arguments.of(PostfachAddressTestFactory.createBuilder() - .identifier(new PostfachAddressIdentifier() { - - }) .build()) ); } -- GitLab