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 18609a3e02a160c36a6bff251093faf42ac17c43..97161e464b811f749f38385e992bf37f7b1d0dfd 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 e825c374cce0a8e55a656bdbf3656032a1f8526f..9861b8bbf8db75cfe620b3f723f1906023e1d63e 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 4ee81e36e98a17bea65d0f9472ae31b693ac5f73..fe0b433c030563f152f66ea4f12d94a8c0c3964c 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 0000000000000000000000000000000000000000..0607dc0a262f63d07c0da67060e3243a9b3c0712 --- /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 aa707651cdc6c5f822f0dcb2ba123c0ce4e2aa2e..4be17f3b766715348c9d8a217b700df8b37e4b59 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>