From 3015c2e1077cf2cc3d6267f1f9f8c7ff149d2ea6 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Tue, 28 May 2024 14:40:11 +0200 Subject: [PATCH] OZG-5571 Added GrpcSentInfoMapping --- .../alfa/bescheid/BescheidMapper.java | 10 ++++---- .../alfa/bescheid/BescheidMapperTest.java | 25 +++++++++++++++++++ .../bescheid/GrpcBescheidTestFactory.java | 5 +++- .../bescheid/GrpcSentInfoTestFactory.java | 22 ++++++++++++++++ pom.xml | 2 +- 5 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/GrpcSentInfoTestFactory.java diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/bescheid/BescheidMapper.java b/alfa-service/src/main/java/de/ozgcloud/alfa/bescheid/BescheidMapper.java index 18609a3e02..97161e464b 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/bescheid/BescheidMapper.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/bescheid/BescheidMapper.java @@ -1,8 +1,6 @@ package de.ozgcloud.alfa.bescheid; -import java.time.ZonedDateTime; import java.util.List; -import java.util.UUID; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -15,17 +13,19 @@ import de.ozgcloud.alfa.common.binaryfile.FileId; import de.ozgcloud.alfa.common.binaryfile.FileIdMapper; import de.ozgcloud.alfa.common.user.UserId; import de.ozgcloud.bescheid.GrpcBescheid; +import de.ozgcloud.bescheid.GrpcSentInfo; @Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, uses = FileIdMapper.class) interface BescheidMapper { @Mapping(target = "attachments", source = "grpcBescheid.attachmentsList") - @Mapping(target = "sentInfo", expression = "java(sentInfoDummyMapping())") Bescheid fromGrpc(GrpcBescheid grpcBescheid, String vorgangId); List<FileId> fromProtocolStringList(ProtocolStringList value); - default SentInfo sentInfoDummyMapping() { - return SentInfo.builder().sentBy(UserId.from(UUID.randomUUID().toString())).sentAt(ZonedDateTime.now()).build(); + SentInfo fromGrpcSentInfo(GrpcSentInfo grpcSentInfo); + + default UserId map(String value) { + return UserId.from(value); } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/BescheidMapperTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/BescheidMapperTest.java index e825c374cc..9861b8bbf8 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/BescheidMapperTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/BescheidMapperTest.java @@ -4,6 +4,8 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; +import java.time.ZonedDateTime; + import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.mapstruct.factory.Mappers; @@ -11,6 +13,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import de.ozgcloud.alfa.common.binaryfile.FileIdMapper; +import de.ozgcloud.alfa.common.user.UserId; import de.ozgcloud.alfa.vorgang.VorgangHeaderTestFactory; class BescheidMapperTest { @@ -88,6 +91,28 @@ class BescheidMapperTest { assertThat(bescheid.getStatus()).isEqualTo(BescheidTestFactory.STATUS); } + @Nested + class TestMapSentInfo { + private final SentInfo expectedSentInfo = SentInfoTestFactory.createBuilder() + .sentAt(ZonedDateTime.parse(GrpcSentInfoTestFactory.SENT_AT)) + .sentBy(UserId.from(GrpcSentInfoTestFactory.SENT_BY)) + .build(); + + @Test + void shouldMapSentBy() { + var bescheid = map(); + + assertThat(bescheid.getSentInfo().getSentBy()).isEqualTo(expectedSentInfo.getSentBy()); + } + + @Test + void shouldMapSentAt() { + var bescheid = map(); + + assertThat(bescheid.getSentInfo().getSentAt()).isEqualTo(expectedSentInfo.getSentAt()); + } + } + private Bescheid map() { return mapper.fromGrpc(GrpcBescheidTestFactory.create(), VorgangHeaderTestFactory.ID); } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/GrpcBescheidTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/GrpcBescheidTestFactory.java index 4ee81e36e9..fe0b433c03 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/GrpcBescheidTestFactory.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/GrpcBescheidTestFactory.java @@ -3,6 +3,7 @@ package de.ozgcloud.alfa.bescheid; import java.util.List; import de.ozgcloud.bescheid.GrpcBescheid; +import de.ozgcloud.bescheid.GrpcSentInfo; import de.ozgcloud.common.datatype.StringBasedValue; public class GrpcBescheidTestFactory { @@ -14,6 +15,7 @@ public class GrpcBescheidTestFactory { public static final List<String> ATTACHMENTS = BescheidTestFactory.ATTACHMENTS.stream().map(StringBasedValue::toString).toList(); public static final String NACHRICHT_TEXT = BescheidTestFactory.NACHRICHT_TEXT; public static final String NACHRICHT_SUBJECT = BescheidTestFactory.NACHRICHT_SUBJECT; + public static final GrpcSentInfo SENT_INFO = GrpcSentInfoTestFactory.create(); public static GrpcBescheid create() { return createBuilder().build(); @@ -29,6 +31,7 @@ public class GrpcBescheidTestFactory { .addAllAttachments(ATTACHMENTS) .setNachrichtText(NACHRICHT_TEXT) .setNachrichtSubject(NACHRICHT_SUBJECT) - .setSendBy(BescheidTestFactory.SEND_BY.toString()); + .setSendBy(BescheidTestFactory.SEND_BY.toString()) + .setSentInfo(SENT_INFO); } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/GrpcSentInfoTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/GrpcSentInfoTestFactory.java new file mode 100644 index 0000000000..0607dc0a26 --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/GrpcSentInfoTestFactory.java @@ -0,0 +1,22 @@ +package de.ozgcloud.alfa.bescheid; + +import java.time.ZonedDateTime; +import java.util.UUID; + +import de.ozgcloud.bescheid.GrpcSentInfo; + +public class GrpcSentInfoTestFactory { + + public static final String SENT_AT = ZonedDateTime.now().toString(); + public static final String SENT_BY = UUID.randomUUID().toString(); + + public static GrpcSentInfo create() { + return createBuilder().build(); + } + + public static GrpcSentInfo.Builder createBuilder() { + return GrpcSentInfo.newBuilder() + .setSentAt(SENT_AT) + .setSentBy(SENT_BY); + } +} diff --git a/pom.xml b/pom.xml index aa707651cd..4be17f3b76 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <vorgang-manager.version>2.7.0</vorgang-manager.version> + <vorgang-manager.version>2.8.0-SNAPSHOT</vorgang-manager.version> <nachrichten-manager.version>2.7.0</nachrichten-manager.version> <ozgcloud-common-pdf.version>3.0.1</ozgcloud-common-pdf.version> <user-manager.version>2.2.0</user-manager.version> -- GitLab