Skip to content

Commit

Permalink
feature(refactoring):962 refactored e2e-test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-mwesener committed Jun 19, 2024
1 parent 7c5a7fc commit 1a0ea21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@
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;
import java.util.ArrayList;
import java.util.List;

import static org.apache.commons.collections4.ListUtils.emptyIfNull;
import static org.eclipse.tractusx.traceability.common.date.DateUtil.convertInstantToString;

@RequiredArgsConstructor
@Component
Expand All @@ -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<String> assetIds = new ArrayList<>();
emptyIfNull(notification.getAffectedParts()).stream()
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 1a0ea21

Please sign in to comment.