Skip to content

Commit

Permalink
Merge pull request #1100 from eclipse-tractusx/feature/962-notificati…
Browse files Browse the repository at this point in the history
…on-model-update

feature(chore):962 fixed sentToBpn.
  • Loading branch information
ds-mmaul committed Jun 24, 2024
2 parents e5e0669 + 5a7e971 commit cac9e41
Show file tree
Hide file tree
Showing 9 changed files with 1,904 additions and 1,919 deletions.
1,896 changes: 948 additions & 948 deletions docs/api/traceability-foss-backend.json

Large diffs are not rendered by default.

1,896 changes: 948 additions & 948 deletions tx-backend/openapi/traceability-foss-backend.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,4 @@ public interface BpnRepository {

BpnEntity save(BusinessPartnerResponse businessPartner);

List<BpnEdcMapping> findAllByIdIn(List<String> bpns);

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ public BpnEntity save(BusinessPartnerResponse businessPartner) {
return repository.save(entity);
}

@Override
public List<BpnEdcMapping> findAllByIdIn(List<String> bpns) {
return this.toDTOList(repository.findAllById(bpns));
}

@Override
public List<BpnEdcMapping> saveAll(List<BpnMappingRequest> bpnEdcMappings) {
List<BpnEntity> bpnEdcMappingEntities = bpnEdcMappings.stream().map(this::toEntity).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.tractusx.traceability.common.model.PageResult;
import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification;
import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage;
import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
Expand All @@ -46,7 +47,7 @@ public static NotificationResponse from(Notification notification) {
.id(notification.getNotificationId().value())
.status(NotificationMessageMapper.from(notification.getNotificationStatus()))
.description(notification.getDescription())
.createdBy(getSenderBPN(notification.getNotifications()))
.createdBy(getSenderBPN(notification))
.createdByName(getSenderName(notification.getNotifications()))
.createdDate(notification.getCreatedAt().toString())
.assetIds(Collections.unmodifiableList(notification.getAffectedPartIds()))
Expand All @@ -73,11 +74,8 @@ public static PageResult<NotificationResponse> fromAsPageResult(PageResult<Notif
return new PageResult<>(investigationDataPage);
}

private static String getSenderBPN(Collection<NotificationMessage> notifications) {
return notifications.stream()
.findFirst()
.map(NotificationMessage::getSentBy)
.orElse(null);
private static String getSenderBPN(Notification notification) {
return notification.getNotificationSide().equals(NotificationSide.SENDER) ? notification.getBpn() : notification.getSendTo();
}

private static String getSenderName(Collection<NotificationMessage> notifications) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public static NotificationMessage create(BPN applicationBpn, String receiverBpn,
.sentByName(creator)
.sentTo(StringUtils.isBlank(receiverBpn) ? asset.getKey() : receiverBpn)
.sendToName(sendToName)
.message(description)
.notificationStatus(NotificationStatus.SENT)
.affectedParts(asset.getValue().stream().map(AssetBase::getId).map(NotificationAffectedPart::new).toList())
.edcNotificationId(notificationId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ private void createMessages(Notification notification, BPN applicationBPN, Asset
.entrySet()
.stream()
.map(it -> {
String creator = getManufacturerNameByBpn(applicationBPN.value());

String firstReceiverBpn = notification.getInitialReceiverBpns().stream()
.findFirst()
.orElseThrow(() -> new NotificationNotFoundException("Initial receiver BPNs not found"));
String sendToName = getManufacturerNameByBpn(firstReceiverBpn);
String creator = getManufacturerNameByBpn(applicationBPN.value());
return NotificationMessage.create(
applicationBPN,
firstReceiverBpn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ void givenNotification_whenFrom_thenConstructProperAlertResponse() {
.hasFieldOrPropertyWithValue("id", notification.getNotificationId().value())
.hasFieldOrPropertyWithValue("status", NotificationStatusResponse.ACCEPTED)
.hasFieldOrPropertyWithValue("description", notification.getDescription())
.hasFieldOrPropertyWithValue("createdBy", notification.getNotifications().stream()
.findFirst()
.map(NotificationMessage::getSentBy)
.orElse(null))
.hasFieldOrPropertyWithValue("createdBy", notification.getBpn())
.hasFieldOrPropertyWithValue("createdByName", notification.getNotifications().stream()
.findFirst()
.map(NotificationMessage::getSentByName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ void givenRequest_whenGetAlert_thenProperResponse() {
.hasFieldOrPropertyWithValue("id", notification.getNotificationId().value())
.hasFieldOrPropertyWithValue("status", NotificationStatusResponse.ACCEPTED)
.hasFieldOrPropertyWithValue("description", notification.getDescription())
.hasFieldOrPropertyWithValue("createdBy", notification.getNotifications().stream()
.findFirst()
.map(NotificationMessage::getSentBy)
.orElse(null))
.hasFieldOrPropertyWithValue("createdBy", notification.getBpn())
.hasFieldOrPropertyWithValue("createdByName", notification.getNotifications().stream()
.findFirst()
.map(NotificationMessage::getSentByName)
Expand Down

0 comments on commit cac9e41

Please sign in to comment.