From 1a0ea21f77469fa1e0ddfeea00af292ac4713b99 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Wed, 19 Jun 2024 16:02:08 +0200 Subject: [PATCH] feature(refactoring):962 refactored e2e-test. --- .../common/mapper/NotificationMapper.java | 11 ++++++++--- .../service/AbstractNotificationReceiverService.java | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapper.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapper.java index ca5038b949..96377fac30 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapper.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapper.java @@ -25,9 +25,11 @@ import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; import org.springframework.stereotype.Component; import java.time.Instant; @@ -35,6 +37,7 @@ import java.util.List; import static org.apache.commons.collections4.ListUtils.emptyIfNull; +import static org.eclipse.tractusx.traceability.common.date.DateUtil.convertInstantToString; @RequiredArgsConstructor @Component @@ -44,11 +47,11 @@ public class NotificationMapper { * Creates an Notification object representing the notification received by the receiver for a given notification. * * @param bpn the BPN of the notification - * @param description the description of the notification + * @param edcNotification the edcNotification of the notification * @param notification the notification associated with the alert or investigation * @return an Notification object representing the notification received by the receiver */ - public Notification toNotification(BPN bpn, String description, NotificationMessage notification, NotificationType notificationType) { + public Notification toNotification(BPN bpn, EDCNotification edcNotification, NotificationMessage notification, NotificationType notificationType) { List assetIds = new ArrayList<>(); emptyIfNull(notification.getAffectedParts()).stream() @@ -59,8 +62,10 @@ public Notification toNotification(BPN bpn, String description, NotificationMess .notificationStatus(NotificationStatus.RECEIVED) .notificationSide(NotificationSide.RECEIVER) .notificationType(notificationType) - .description(description) + .description(edcNotification.getInformation()) .createdAt(Instant.now()) + .severity(NotificationSeverity.fromString(edcNotification.getSeverity())) + .targetDate(convertInstantToString(edcNotification.getTargetDate())) .affectedPartIds(assetIds) .notifications(List.of(notification)) .build(); diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/AbstractNotificationReceiverService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/AbstractNotificationReceiverService.java index c92d5189e8..f4bfe27206 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/AbstractNotificationReceiverService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/AbstractNotificationReceiverService.java @@ -48,7 +48,7 @@ public abstract class AbstractNotificationReceiverService implements Notificatio public void handleReceive(EDCNotification edcNotification, NotificationType notificationType) { BPN investigationCreatorBPN = BPN.of(edcNotification.getSenderBPN()); NotificationMessage notification = getNotificationMessageMapper().toNotificationMessage(edcNotification, notificationType); - Notification investigation = getNotificationMapper().toNotification(investigationCreatorBPN, edcNotification.getInformation(), notification, notificationType); + Notification investigation = getNotificationMapper().toNotification(investigationCreatorBPN, edcNotification, notification, notificationType); NotificationId investigationId = getRepository().saveNotification(investigation); log.info("Stored received edcNotification in investigation with id {}", investigationId); }