From 214f2919cd4d715b3e3f3458f812446639de83be Mon Sep 17 00:00:00 2001 From: Pawel Sosnowski Date: Thu, 16 Nov 2023 12:43:47 +0100 Subject: [PATCH] feat(irs-api):[#246] First level supply chain changed to show only lowest level of hops, code clean up, added test --- docs/src/api/irs-api.yaml | 2 +- .../irs/ess/service/BpnInvestigationJob.java | 60 +++++++++--------- .../ess/service/EdcNotificationSender.java | 2 +- .../EssRecursiveNotificationHandler.java | 27 +++----- .../tractusx/irs/ess/service/EssService.java | 4 +- ...vestigationJobProcessingEventListener.java | 20 +++--- .../service/SupplyChainImpactedAspect.java | 4 +- .../irs/ess/service/EssServiceTest.java | 63 ++++++++++++------- .../ResponseNotificationContent.java | 2 +- .../tractusx/irs/component/Notification.java | 2 +- 10 files changed, 94 insertions(+), 92 deletions(-) diff --git a/docs/src/api/irs-api.yaml b/docs/src/api/irs-api.yaml index 984d1be77b..dce6586307 100644 --- a/docs/src/api/irs-api.yaml +++ b/docs/src/api/irs-api.yaml @@ -2524,7 +2524,7 @@ components: hops: type: integer format: int32 - parentBpn: + bpn: type: string result: type: string diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/BpnInvestigationJob.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/BpnInvestigationJob.java index ef3682493e..6ef37b2514 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/BpnInvestigationJob.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/BpnInvestigationJob.java @@ -27,9 +27,9 @@ import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Optional; -import java.util.Set; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -65,14 +65,13 @@ public BpnInvestigationJob(final Jobs jobSnapshot, final List incidentBp this(jobSnapshot, incidentBpns, new ArrayList<>(), new ArrayList<>(), JobState.RUNNING); } - public BpnInvestigationJob update(final Jobs jobSnapshot, final SupplyChainImpacted newSupplyChain, - final String bpn) { + public BpnInvestigationJob update(final Jobs jobSnapshot, final SupplyChainImpacted newSupplyChain) { final Optional previousSupplyChain = getSupplyChainImpacted(); final SupplyChainImpacted supplyChainImpacted = previousSupplyChain.map( prevSupplyChain -> prevSupplyChain.or(newSupplyChain)).orElse(newSupplyChain); - this.jobSnapshot = extendJobWithSupplyChainSubmodel(jobSnapshot, supplyChainImpacted, bpn); + this.jobSnapshot = extendJobWithSupplyChainSubmodel(jobSnapshot, supplyChainImpacted); this.jobSnapshot = extendSummary(this.jobSnapshot); this.jobSnapshot = updateLastModified(this.jobSnapshot, ZonedDateTime.now(ZoneOffset.UTC)); return this; @@ -85,21 +84,21 @@ public BpnInvestigationJob withUnansweredNotifications(final List public BpnInvestigationJob withAnsweredNotification( final EdcNotification notification) { - final Optional parentBpn = getParentBpn(notification); + final Optional bpn = getChildBpn(notification); removeFromUnansweredNotification(notification); - notification.getContent().setParentBpn(parentBpn.orElse(null)); + notification.getContent().setBpn(bpn.orElse(null)); notification.getContent().incrementHops(); this.answeredNotifications.add(notification); return this; } - private Optional getParentBpn(final EdcNotification notification) { + private Optional getChildBpn(final EdcNotification notification) { return this.unansweredNotifications.stream() .filter(unansweredNotification -> unansweredNotification.notificationId() .equals(notification.getHeader() .getOriginalNotificationId())) - .map(Notification::bpn) + .map(Notification::childBpn) .findAny(); } @@ -125,40 +124,41 @@ public BpnInvestigationJob complete() { .findFirst(); } - private Jobs extendJobWithSupplyChainSubmodel(final Jobs irsJob, final SupplyChainImpacted supplyChainImpacted, - final String bpn) { - log.debug(bpn); + private Jobs extendJobWithSupplyChainSubmodel(final Jobs irsJob, final SupplyChainImpacted supplyChainImpacted) { final SupplyChainImpactedAspect.SupplyChainImpactedAspectBuilder supplyChainImpactedAspectBuilder = SupplyChainImpactedAspect.builder() .supplyChainImpacted( supplyChainImpacted); if (getUnansweredNotifications().isEmpty()) { - final List incidentWithMinHopsValue = getAnsweredNotifications().stream() - .map(EdcNotification::getContent) - .filter(ResponseNotificationContent::thereIsIncident) - .toList(); - - final List suppliersFirstLevel = incidentWithMinHopsValue.stream() - .map(impacted -> new SupplyChainImpactedAspect.ImpactedSupplierFirstLevel( - impacted.getParentBpn(), - impacted.getHops())) - .toList(); - - supplyChainImpactedAspectBuilder.impactedSuppliersOnFirstTier(Set.copyOf(suppliersFirstLevel)); + final Optional impactedSupplierWithLowestHopsNumber = getImpactedSupplierWithLowestHopsNumber(); + supplyChainImpactedAspectBuilder.impactedSuppliersOnFirstTier( + impactedSupplierWithLowestHopsNumber.orElse(null)); } - final Submodel supplyChainImpactedSubmodel = Submodel.builder() - .aspectType(SUPPLY_CHAIN_ASPECT_TYPE) - .payload(new JsonUtil().asMap( - supplyChainImpactedAspectBuilder.build())) - .build(); - return irsJob.toBuilder() .clearSubmodels() - .submodels(Collections.singletonList(supplyChainImpactedSubmodel)) + .submodels(Collections.singletonList( + createSupplyChainImpactedSubmodel(supplyChainImpactedAspectBuilder))) .build(); } + private Optional getImpactedSupplierWithLowestHopsNumber() { + return getAnsweredNotifications().stream() + .map(EdcNotification::getContent) + .filter(ResponseNotificationContent::thereIsIncident) + .min(Comparator.comparing(ResponseNotificationContent::getHops)) + .map(impacted -> new SupplyChainImpactedAspect.ImpactedSupplierFirstLevel( + impacted.getBpn(), impacted.getHops())); + } + + private static Submodel createSupplyChainImpactedSubmodel( + final SupplyChainImpactedAspect.SupplyChainImpactedAspectBuilder supplyChainImpactedAspectBuilder) { + return Submodel.builder() + .aspectType(SUPPLY_CHAIN_ASPECT_TYPE) + .payload(new JsonUtil().asMap(supplyChainImpactedAspectBuilder.build())) + .build(); + } + private Jobs updateLastModified(final Jobs irsJob, final ZonedDateTime lastModifiedOn) { final Job job = irsJob.getJob().toBuilder().completedOn(lastModifiedOn).lastModifiedOn(lastModifiedOn).build(); return irsJob.toBuilder().job(job).build(); diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcNotificationSender.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcNotificationSender.java index 3195b71d20..78373abcbb 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcNotificationSender.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcNotificationSender.java @@ -70,7 +70,7 @@ public void sendEdcNotification(final EdcNotification responseNotification = edcRequest(notificationId, originalNotificationId, essLocalEdcEndpoint, localBpn, recipientBpn, notificationContent); diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveNotificationHandler.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveNotificationHandler.java index 041899d752..26f902ab28 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveNotificationHandler.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveNotificationHandler.java @@ -23,15 +23,12 @@ ********************************************************************************/ package org.eclipse.tractusx.irs.ess.service; -import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.UUID; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; -import org.eclipse.tractusx.irs.edc.client.model.notification.ResponseNotificationContent; import org.springframework.stereotype.Service; /** @@ -42,14 +39,12 @@ @Slf4j public class EssRecursiveNotificationHandler { - private static final Integer FIRST_HOP = 0; - private final RelatedInvestigationJobsCache relatedInvestigationJobsCache; private final BpnInvestigationJobCache bpnInvestigationJobCache; private final EdcNotificationSender edcNotificationSender; - /* package */ void handleNotification(final UUID finishedJobId, final SupplyChainImpacted supplyChainImpacted, final String bpn, - final Integer hops) { + /* package */ void handleNotification(final UUID finishedJobId, final SupplyChainImpacted supplyChainImpacted, + final String bpn, final Integer hops) { final Optional relatedJobsId = relatedInvestigationJobsCache.findByRecursiveRelatedJobId( finishedJobId); @@ -57,7 +52,8 @@ public class EssRecursiveNotificationHandler { relatedJobsId.ifPresentOrElse(relatedJobs -> { if (SupplyChainImpacted.YES.equals(supplyChainImpacted)) { log.debug("SupplyChain is impacted. Sending notification back to requestor."); - edcNotificationSender.sendEdcNotification(relatedJobs.originalNotification(), supplyChainImpacted, hops, bpn); + edcNotificationSender.sendEdcNotification(relatedJobs.originalNotification(), supplyChainImpacted, hops, + bpn); relatedInvestigationJobsCache.remove( relatedJobs.originalNotification().getHeader().getNotificationId()); } else { @@ -76,6 +72,7 @@ private void sendNotificationAfterAllCompleted(final RelatedInvestigationJobs re .map(bpnInvestigationJobCache::findByJobId) .flatMap(Optional::stream) .toList(); + if (checkAllFinished(allInvestigationJobs)) { final SupplyChainImpacted finalResult = allInvestigationJobs.stream() .map(BpnInvestigationJob::getSupplyChainImpacted) @@ -83,21 +80,11 @@ private void sendNotificationAfterAllCompleted(final RelatedInvestigationJobs re .reduce(SupplyChainImpacted.NO, SupplyChainImpacted::or); - edcNotificationSender.sendEdcNotification(relatedInvestigationJobs.originalNotification(), finalResult, hops, bpn); + edcNotificationSender.sendEdcNotification(relatedInvestigationJobs.originalNotification(), finalResult, + hops, bpn); } } - private Integer getMinHops(final List allInvestigationJobs) { - return allInvestigationJobs - .stream() - .flatMap(investigationJobs -> investigationJobs.getAnsweredNotifications().stream()) - .map(EdcNotification::getContent) - .filter(ResponseNotificationContent::thereIsIncident) - .min(Comparator.comparing(ResponseNotificationContent::getHops)) - .map(ResponseNotificationContent::getHops) - .orElse(FIRST_HOP); - } - private boolean checkAllFinished(final List allInvestigationJobs) { return allInvestigationJobs.stream() .allMatch(bpnInvestigationJob -> bpnInvestigationJob.getSupplyChainImpacted() diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssService.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssService.java index 5a71931b08..e260de0ccb 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssService.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssService.java @@ -127,9 +127,9 @@ public void handleNotificationCallback(final EdcNotification mockRecursiveEdcAssets; private final EssRecursiveNotificationHandler recursiveNotificationHandler; + private static final int FIRST_HOP = 0; /* package */ InvestigationJobProcessingEventListener(final IrsItemGraphQueryService irsItemGraphQueryService, final ConnectorEndpointsService connectorEndpointsService, final EdcSubmodelFacade edcSubmodelFacade, @@ -111,14 +112,14 @@ public void handleJobProcessingFinishedEvent(final JobProcessingFinishedEvent jo completedJobId); final BpnInvestigationJob investigationJobUpdate = investigationJob.update( - investigationResult.completedJob(), investigationResult.supplyChainImpacted(), job.getJobParameter().getBpn()); + investigationResult.completedJob(), investigationResult.supplyChainImpacted()); if (leafNodeIsReached(investigationResult.completedJob()) || supplyChainIsImpacted( investigationResult.supplyChainImpacted())) { bpnInvestigationJobCache.store(completedJobId, investigationJobUpdate.complete()); recursiveNotificationHandler.handleNotification(investigationJob.getJobSnapshot().getJob().getId(), investigationResult.supplyChainImpacted(), job.getJobParameter().getBpn(), - 0); + FIRST_HOP); } else { triggerInvestigationOnNextLevel(investigationResult.completedJob(), investigationJobUpdate, job.getJobParameter().getBpn()); bpnInvestigationJobCache.store(completedJobId, investigationJobUpdate); @@ -155,8 +156,9 @@ private void triggerInvestigationOnNextLevel(final Jobs completedJob, log.debug("Triggering investigation on the next level."); if (anyBpnIsMissingFromRelationship(completedJob)) { log.error("One or more Relationship items did not contain a BPN."); - investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN, jobBpn); + investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN); } + // Map> final Map> bpns = getBPNsFromRelationships(completedJob.getRelationships()); log.debug("Extracted BPNs '{}'", bpns); @@ -171,14 +173,14 @@ private void triggerInvestigationOnNextLevel(final Jobs completedJob, log.debug("BPNs '{}' could not be resolved to an EDC address using DiscoveryService.", unresolvedBPNs); log.info("Some EDC addresses could not be resolved with DiscoveryService. " + "Updating SupplyChainImpacted to {}", SupplyChainImpacted.UNKNOWN); - investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN, jobBpn); + investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN); recursiveNotificationHandler.handleNotification(investigationJobUpdate.getJobSnapshot().getJob().getId(), - SupplyChainImpacted.UNKNOWN, jobBpn, 0); + SupplyChainImpacted.UNKNOWN, jobBpn, FIRST_HOP); } else if (resolvedBPNs.isEmpty()) { log.info("No BPNs could not be found. Updating SupplyChainImpacted to {}", SupplyChainImpacted.UNKNOWN); - investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN, jobBpn); + investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN); recursiveNotificationHandler.handleNotification(investigationJobUpdate.getJobSnapshot().getJob().getId(), - SupplyChainImpacted.UNKNOWN, jobBpn, 0); + SupplyChainImpacted.UNKNOWN, jobBpn, FIRST_HOP); } else { log.debug("Sending notification for BPNs '{}'", bpns); sendNotifications(completedJob, investigationJobUpdate, bpns); @@ -192,7 +194,7 @@ private void sendNotifications(final Jobs completedJob, final BpnInvestigationJo if (edcBaseUrl.isEmpty()) { log.warn("No EDC URL found for BPN '{}'. Setting investigation result to '{}'", bpn, SupplyChainImpacted.UNKNOWN); - investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN, bpn); + investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN); } edcBaseUrl.forEach(url -> { try { @@ -201,7 +203,7 @@ private void sendNotifications(final Jobs completedJob, final BpnInvestigationJo investigationJobUpdate.withUnansweredNotifications(Collections.singletonList(new Notification(notificationId, bpn))); } catch (final EdcClientException e) { log.error("Exception during sending EDC notification.", e); - investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN, bpn); + investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN); } }); }); diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/SupplyChainImpactedAspect.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/SupplyChainImpactedAspect.java index 3f20e186cb..633f4a96c0 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/SupplyChainImpactedAspect.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/SupplyChainImpactedAspect.java @@ -23,8 +23,6 @@ ********************************************************************************/ package org.eclipse.tractusx.irs.ess.service; -import java.util.Set; - import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -41,7 +39,7 @@ @Builder public class SupplyChainImpactedAspect { private SupplyChainImpacted supplyChainImpacted; - private Set impactedSuppliersOnFirstTier; + private ImpactedSupplierFirstLevel impactedSuppliersOnFirstTier; /** * BPNLs on first tier level where infection was detected diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssServiceTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssServiceTest.java index c802be5025..c5eab5527d 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssServiceTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssServiceTest.java @@ -118,7 +118,7 @@ void shouldUpdateJobSnapshotIfNotificationFound() { final UUID jobId = UUID.randomUUID(); final String owner = securityHelperService.getClientIdClaim(); - final ResponseNotificationContent resultNo = ResponseNotificationContent.builder().result("No").hops(0).parentBpn("bot-impacted-bpn").build(); + final ResponseNotificationContent resultNo = ResponseNotificationContent.builder().result("No").hops(0).bpn("bot-impacted-bpn").build(); final EdcNotificationHeader header1 = EdcNotificationHeader.builder() .notificationId(notificationId) .originalNotificationId(notificationId) @@ -127,7 +127,7 @@ void shouldUpdateJobSnapshotIfNotificationFound() { .header(header1) .content(resultNo) .build(); - final ResponseNotificationContent resultYes = ResponseNotificationContent.builder().result("Yes").hops(0).parentBpn("impacted-bpn").build(); + final ResponseNotificationContent resultYes = ResponseNotificationContent.builder().result("Yes").hops(0).bpn("impacted-bpn").build(); final EdcNotificationHeader header2 = EdcNotificationHeader.builder() .notificationId(notificationId) .originalNotificationId(notificationId2) @@ -163,61 +163,76 @@ void shouldUpdateJobSnapshotIfNotificationFound() { final Map supplyChainPayload = job2.getJobSnapshot().getSubmodels().get(0).getPayload(); final SupplyChainImpactedAspect supplyChainImpactedAspect = new ObjectMapper().convertValue(supplyChainPayload, SupplyChainImpactedAspect.class); assertThat(supplyChainImpactedAspect.getSupplyChainImpacted()).isEqualTo(SupplyChainImpacted.YES); - assertThat(supplyChainImpactedAspect.getImpactedSuppliersOnFirstTier()).isNotEmpty(); - assertThat(supplyChainImpactedAspect.getImpactedSuppliersOnFirstTier().stream().findAny().get().getHops()).isPositive(); + assertThat(supplyChainImpactedAspect.getImpactedSuppliersOnFirstTier()).isNotNull(); + assertThat(supplyChainImpactedAspect.getImpactedSuppliersOnFirstTier().getHops()).isPositive(); assertThat(job.getState()).isEqualTo(JobState.COMPLETED); } @Test - void shouldReturnFirstImpactedSupplierWhenNotificationFound() { + void shouldReturnCorrectFirstLevelImpactedSupplierBpnAndHopsNumberWhenImpactedSupplierIsOnThirdLevel() { // given final String notificationId = UUID.randomUUID().toString(); final String notificationId2 = UUID.randomUUID().toString(); final UUID jobId = UUID.randomUUID(); + final UUID jobId2 = UUID.randomUUID(); + final UUID jobId3 = UUID.randomUUID(); final String owner = securityHelperService.getClientIdClaim(); final String bpnLevel0 = "bpn-level-0"; final String bpnLevel1 = "bpn-level-1"; + final String bpnLevel2 = "bpn-level-2"; - final ResponseNotificationContent responseNotificationContentLevel1 = ResponseNotificationContent.builder().result("No").hops(0).parentBpn(bpnLevel0).build(); + final ResponseNotificationContent responseNotificationContentLevel1 = ResponseNotificationContent.builder().result("Yes").hops(1).bpn(bpnLevel0).build(); final EdcNotificationHeader header1 = EdcNotificationHeader.builder() .notificationId(notificationId) .originalNotificationId(notificationId) .build(); final EdcNotification responseNotificationLevel1 = EdcNotification.builder() - .header(header1) - .content(responseNotificationContentLevel1) - .build(); - + .header(header1) + .content(responseNotificationContentLevel1) + .build(); - final ResponseNotificationContent impactedResponseNotificationContent = ResponseNotificationContent.builder().result("Yes").hops(0).parentBpn(bpnLevel1).build(); + final ResponseNotificationContent responseNotificationContent2 = ResponseNotificationContent.builder().result("Yes").hops(0).bpn(bpnLevel1).build(); final EdcNotificationHeader header2 = EdcNotificationHeader.builder() .notificationId(notificationId) .originalNotificationId(notificationId2) .build(); final EdcNotification responseNotificationLevel2 = EdcNotification.builder() - .header(header2) - .content(impactedResponseNotificationContent) - .build(); + .header(header2) + .content(responseNotificationContent2) + .build(); final BpnInvestigationJob bpnInvestigationJob = new BpnInvestigationJob( Jobs.builder().job(Job.builder().id(jobId).owner(owner).build()).build(), - new ArrayList<>()).withUnansweredNotifications(List.of(new Notification(notificationId, bpnLevel0), new Notification(notificationId2, bpnLevel1))); + new ArrayList<>()).withUnansweredNotifications(List.of(new Notification(notificationId, bpnLevel1))); bpnInvestigationJobCache.store(jobId, bpnInvestigationJob); + final BpnInvestigationJob bpnInvestigationJob2 = new BpnInvestigationJob( + Jobs.builder().job(Job.builder().id(jobId2).owner(owner).build()).build(), + new ArrayList<>()).withUnansweredNotifications(List.of(new Notification(notificationId2, bpnLevel2))); + bpnInvestigationJobCache.store(jobId2, bpnInvestigationJob2); + + final BpnInvestigationJob bpnInvestigationJob3 = new BpnInvestigationJob( + Jobs.builder().job(Job.builder().id(jobId3).owner(owner).build()).build(), + new ArrayList<>()); + bpnInvestigationJobCache.store(jobId3, bpnInvestigationJob3); + // when - essService.handleNotificationCallback(responseNotificationLevel1); essService.handleNotificationCallback(responseNotificationLevel2); + essService.handleNotificationCallback(responseNotificationLevel1); // then - final BpnInvestigationJob job2 = bpnInvestigationJobCache.findAll().get(0); - final List> supplyChainImpacted2 = (List>) job2.getJobSnapshot() - .getSubmodels() - .get(0) - .getPayload() - .get("impactedSuppliersOnFirstTier"); + final Optional investigationJobLevel1 = bpnInvestigationJobCache.findByJobId(jobId); + assertThat(investigationJobLevel1).isPresent(); + + final Map supplyChainImpacted2 = (Map) investigationJobLevel1.get().getJobSnapshot() + .getSubmodels() + .get(0) + .getPayload() + .get("impactedSuppliersOnFirstTier"); - assertThat(supplyChainImpacted2.get(0).get("bpnl").toString()).isEqualTo(bpnLevel1); + assertThat(supplyChainImpacted2.get("bpnl").toString()).isEqualTo(bpnLevel1); + assertThat(supplyChainImpacted2.get("hops").toString()).isEqualTo("2"); } @Test @@ -286,7 +301,7 @@ void shouldCompleteJobIfFinalNotificationWasReceived() { final Jobs jobSnapshot = job(jobId, owner); final String notificationId = UUID.randomUUID().toString(); final BpnInvestigationJob bpnInvestigationJob = new BpnInvestigationJob(jobSnapshot, null).update(jobSnapshot, - SupplyChainImpacted.NO, "bpn").withUnansweredNotifications(List.of(new Notification(notificationId, "bpn"))); + SupplyChainImpacted.NO).withUnansweredNotifications(List.of(new Notification(notificationId, "bpn"))); bpnInvestigationJobCache.store(jobId, bpnInvestigationJob); final ResponseNotificationContent resultNo = ResponseNotificationContent.builder().result("No").hops(0).build(); final EdcNotificationHeader header1 = EdcNotificationHeader.builder() diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/notification/ResponseNotificationContent.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/notification/ResponseNotificationContent.java index 08438d293f..e160dd91c0 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/notification/ResponseNotificationContent.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/notification/ResponseNotificationContent.java @@ -39,7 +39,7 @@ public class ResponseNotificationContent implements NotificationContent { private final String result; private Integer hops; - private String parentBpn; + private String bpn; /** * Incrementing hops value diff --git a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/Notification.java b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/Notification.java index 9641d1e37c..a03c47bdd6 100644 --- a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/Notification.java +++ b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/Notification.java @@ -26,5 +26,5 @@ /** * Response notification body containing notificationId and parent bpn */ -public record Notification(String notificationId, String bpn) { +public record Notification(String notificationId, String childBpn) { }