diff --git a/DEPENDENCIES b/DEPENDENCIES index e7c98b9a6d..99db4e6e2d 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -309,7 +309,6 @@ maven/mavencentral/org.eclipse.jetty/jetty-xml/11.0.15, EPL-2.0 OR Apache-2.0, a maven/mavencentral/org.eclipse.tractusx.irs/irs-api/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx maven/mavencentral/org.eclipse.tractusx.irs/irs-common/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx maven/mavencentral/org.eclipse.tractusx.irs/irs-edc-client/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx -maven/mavencentral/org.eclipse.tractusx.irs/irs-ess/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx maven/mavencentral/org.eclipse.tractusx.irs/irs-models/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx maven/mavencentral/org.eclipse.tractusx.irs/irs-policy-store/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/1.2.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx diff --git a/Dockerfile b/Dockerfile index 39d584ed04..7c60c99605 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,6 @@ COPY .config .config COPY .mvn .mvn COPY pom.xml . -COPY irs-ess irs-ess COPY irs-policy-store irs-policy-store COPY irs-integration-tests irs-integration-tests COPY irs-api irs-api diff --git a/irs-api/pom.xml b/irs-api/pom.xml index 5cf6588da9..de349e1e25 100644 --- a/irs-api/pom.xml +++ b/irs-api/pom.xml @@ -22,12 +22,6 @@ - - - org.eclipse.tractusx.irs - irs-ess - ${revision} - org.eclipse.tractusx.irs irs-edc-client diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java index 3b4d347966..2ce842852e 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/IrsApplication.java @@ -43,7 +43,7 @@ @ComponentScan( basePackages = { "org.eclipse.tractusx.irs", - "org.eclipse.tractusx.ess", + "org.eclipse.tractusx.irs.ess", "org.eclipse.tractusx.irs.edc", "org.eclipse.tractusx.irs.common.auth", }, diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/OpenApiExamples.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/OpenApiExamples.java index 41bdf66021..2382f3daa3 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/OpenApiExamples.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/OpenApiExamples.java @@ -30,7 +30,7 @@ import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.examples.Example; -import org.eclipse.tractusx.ess.service.NotificationSummary; +import org.eclipse.tractusx.irs.ess.service.NotificationSummary; import org.eclipse.tractusx.irs.component.AsyncFetchedItems; import org.eclipse.tractusx.irs.component.BatchResponse; import org.eclipse.tractusx.irs.component.BatchOrderResponse; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/bpn/validation/BPNIncidentValidation.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/bpn/validation/BPNIncidentValidation.java similarity index 97% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/bpn/validation/BPNIncidentValidation.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/bpn/validation/BPNIncidentValidation.java index a8134bdac7..54a89cde3a 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/bpn/validation/BPNIncidentValidation.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/bpn/validation/BPNIncidentValidation.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.bpn.validation; +package org.eclipse.tractusx.irs.ess.bpn.validation; import java.time.ZonedDateTime; import java.util.List; @@ -29,7 +29,7 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; -import org.eclipse.tractusx.ess.service.SupplyChainImpacted; +import org.eclipse.tractusx.irs.ess.service.SupplyChainImpacted; import org.eclipse.tractusx.irs.component.Jobs; import org.eclipse.tractusx.irs.component.assetadministrationshell.AssetAdministrationShellDescriptor; import org.eclipse.tractusx.irs.component.partasplanned.PartAsPlanned; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/EssController.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/EssController.java similarity index 99% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/EssController.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/EssController.java index ba6f9463bf..d2983bcc7d 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/EssController.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/EssController.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.controller; +package org.eclipse.tractusx.irs.ess.controller; import static org.eclipse.tractusx.irs.common.ApiConstants.FORBIDDEN_DESC; import static org.eclipse.tractusx.irs.common.ApiConstants.UNAUTHORIZED_DESC; @@ -40,7 +40,7 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.ess.service.EssService; +import org.eclipse.tractusx.irs.ess.service.EssService; import org.eclipse.tractusx.irs.common.auth.AuthorizationService; import org.eclipse.tractusx.irs.common.auth.IrsRoles; import org.eclipse.tractusx.irs.component.JobHandle; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/EssRecursiveController.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/EssRecursiveController.java similarity index 95% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/EssRecursiveController.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/EssRecursiveController.java index c42953fe47..42f8d4acf3 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/EssRecursiveController.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/EssRecursiveController.java @@ -21,13 +21,13 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.controller; +package org.eclipse.tractusx.irs.ess.controller; import io.swagger.v3.oas.annotations.Hidden; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.ess.service.EssRecursiveService; +import org.eclipse.tractusx.irs.ess.service.EssRecursiveService; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; import org.eclipse.tractusx.irs.edc.client.model.notification.InvestigationNotificationContent; import org.springframework.http.HttpStatus; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/NotificationReceiverController.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/NotificationReceiverController.java similarity index 97% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/NotificationReceiverController.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/NotificationReceiverController.java index aebcd694e3..7ed9404ca7 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/NotificationReceiverController.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/NotificationReceiverController.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.controller; +package org.eclipse.tractusx.irs.ess.controller; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @@ -33,7 +33,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.eclipse.tractusx.ess.service.EssService; +import org.eclipse.tractusx.irs.ess.service.EssService; import org.eclipse.tractusx.irs.dtos.ErrorResponse; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; import org.eclipse.tractusx.irs.edc.client.model.notification.ResponseNotificationContent; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/mock/MockedNotificationReceiverController.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/mock/MockedNotificationReceiverController.java similarity index 97% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/mock/MockedNotificationReceiverController.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/mock/MockedNotificationReceiverController.java index e3f8d8c517..0ae6cc67fe 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/mock/MockedNotificationReceiverController.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/controller/mock/MockedNotificationReceiverController.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.controller.mock; +package org.eclipse.tractusx.irs.ess.controller.mock; import java.util.List; import java.util.Map; @@ -32,8 +32,8 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.ess.discovery.EdcDiscoveryMockConfig; -import org.eclipse.tractusx.ess.service.SupplyChainImpacted; +import org.eclipse.tractusx.irs.ess.discovery.EdcDiscoveryMockConfig; +import org.eclipse.tractusx.irs.ess.service.SupplyChainImpacted; import org.eclipse.tractusx.irs.edc.client.EdcSubmodelFacade; import org.eclipse.tractusx.irs.edc.client.exceptions.EdcClientException; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/discovery/EdcDiscoveryMockConfig.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/discovery/EdcDiscoveryMockConfig.java similarity index 92% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/discovery/EdcDiscoveryMockConfig.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/discovery/EdcDiscoveryMockConfig.java index 91084e8b19..c8f628e1a8 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/discovery/EdcDiscoveryMockConfig.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/discovery/EdcDiscoveryMockConfig.java @@ -21,12 +21,12 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.discovery; +package org.eclipse.tractusx.irs.ess.discovery; import java.util.Map; import lombok.Data; -import org.eclipse.tractusx.ess.service.SupplyChainImpacted; +import org.eclipse.tractusx.irs.ess.service.SupplyChainImpacted; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/AspectTypeNotFoundException.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/AspectTypeNotFoundException.java similarity index 96% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/AspectTypeNotFoundException.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/AspectTypeNotFoundException.java index b9b7298bd6..580585c3ce 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/AspectTypeNotFoundException.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/AspectTypeNotFoundException.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; /** * Exception thrown if ESS Validation could not find the requested aspect model in the job. diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/BpnInvestigationJob.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/BpnInvestigationJob.java similarity index 99% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/BpnInvestigationJob.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/BpnInvestigationJob.java index 552e740e4b..e95dc60fea 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/BpnInvestigationJob.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/BpnInvestigationJob.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import java.time.ZoneOffset; import java.time.ZonedDateTime; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/BpnInvestigationJobCache.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/BpnInvestigationJobCache.java similarity index 98% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/BpnInvestigationJobCache.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/BpnInvestigationJobCache.java index 9d82ea2e2a..324e63369f 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/BpnInvestigationJobCache.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/BpnInvestigationJobCache.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import static java.util.Objects.requireNonNull; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EdcNotificationSender.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcNotificationSender.java similarity index 99% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EdcNotificationSender.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcNotificationSender.java index 0e38af753c..43e133584f 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EdcNotificationSender.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcNotificationSender.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import java.util.UUID; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EdcRegistration.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcRegistration.java similarity index 99% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EdcRegistration.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcRegistration.java index c0dbaffbcc..286bbd597d 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EdcRegistration.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcRegistration.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EssRecursiveNotificationHandler.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveNotificationHandler.java similarity index 99% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EssRecursiveNotificationHandler.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveNotificationHandler.java index 73b41444ef..49f5381a32 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EssRecursiveNotificationHandler.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveNotificationHandler.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import java.util.List; import java.util.Optional; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EssRecursiveService.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveService.java similarity index 99% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EssRecursiveService.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveService.java index db71b55387..edc001412b 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EssRecursiveService.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveService.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import java.util.List; import java.util.Optional; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EssService.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssService.java similarity index 84% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EssService.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssService.java index d260ecfdb5..5e920ddc1d 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/EssService.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EssService.java @@ -21,22 +21,27 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; +import java.util.List; import java.util.Optional; import java.util.UUID; import java.util.function.Predicate; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.ess.irs.IrsFacade; import org.eclipse.tractusx.irs.common.auth.SecurityHelperService; import org.eclipse.tractusx.irs.component.JobHandle; import org.eclipse.tractusx.irs.component.Jobs; +import org.eclipse.tractusx.irs.component.PartChainIdentificationKey; import org.eclipse.tractusx.irs.component.RegisterBpnInvestigationJob; +import org.eclipse.tractusx.irs.component.RegisterJob; +import org.eclipse.tractusx.irs.component.enums.AspectType; +import org.eclipse.tractusx.irs.component.enums.BomLifecycle; import org.eclipse.tractusx.irs.component.enums.JobState; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; import org.eclipse.tractusx.irs.edc.client.model.notification.ResponseNotificationContent; +import org.eclipse.tractusx.irs.services.IrsItemGraphQueryService; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.web.server.ResponseStatusException; @@ -49,7 +54,7 @@ @Slf4j public class EssService { - private final IrsFacade irsFacade; + private final IrsItemGraphQueryService irsItemGraphQueryService; private final SecurityHelperService securityHelperService; private final BpnInvestigationJobCache bpnInvestigationJobCache; private final EssRecursiveNotificationHandler recursiveNotificationHandler; @@ -83,10 +88,10 @@ private static boolean hasUnansweredNotifications(final BpnInvestigationJob inve } public JobHandle startIrsJob(final RegisterBpnInvestigationJob request) { - final JobHandle jobHandle = irsFacade.startIrsJob(request.getKey(), request.getBomLifecycle()); + final JobHandle jobHandle = irsItemGraphQueryService.registerItemJob(bpnInvestigations(request.getKey(), request.getBomLifecycle())); final UUID createdJobId = jobHandle.getId(); - final Jobs createdJob = irsFacade.getIrsJob(createdJobId.toString()); + final Jobs createdJob = irsItemGraphQueryService.getJobForJobId(createdJobId, true); final String owner = securityHelperService.getClientIdClaim(); bpnInvestigationJobCache.store(createdJobId, BpnInvestigationJob.create(createdJob, owner, request.getIncidentBPNSs())); @@ -149,4 +154,15 @@ private Predicate investigationJobNotificationPredicate( return investigationJob -> investigationJob.getUnansweredNotifications() .contains(notification.getHeader().getOriginalNotificationId()); } + + private RegisterJob bpnInvestigations(final PartChainIdentificationKey key, final BomLifecycle bomLifecycle) { + return RegisterJob.builder() + .key(key) + .bomLifecycle(bomLifecycle != null ? bomLifecycle : BomLifecycle.AS_PLANNED) + .depth(1) + .aspects(List.of(AspectType.PART_SITE_INFORMATION_AS_PLANNED.toString(), + AspectType.PART_AS_PLANNED.toString())) + .collectAspects(true) + .build(); + } } diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/InvestigationJobProcessingEventListener.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/InvestigationJobProcessingEventListener.java similarity index 92% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/InvestigationJobProcessingEventListener.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/InvestigationJobProcessingEventListener.java index 914fbe6a0b..5ebd486a1e 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/InvestigationJobProcessingEventListener.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/InvestigationJobProcessingEventListener.java @@ -21,9 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; - -import static org.eclipse.tractusx.ess.service.SupplyChainImpacted.UNKNOWN; +package org.eclipse.tractusx.irs.ess.service; import java.util.Collections; import java.util.HashMap; @@ -34,8 +32,6 @@ import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.ess.bpn.validation.BPNIncidentValidation; -import org.eclipse.tractusx.ess.irs.IrsFacade; import org.eclipse.tractusx.irs.common.JobProcessingFinishedEvent; import org.eclipse.tractusx.irs.component.Jobs; import org.eclipse.tractusx.irs.component.Relationship; @@ -50,7 +46,9 @@ import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotificationResponse; import org.eclipse.tractusx.irs.edc.client.model.notification.InvestigationNotificationContent; import org.eclipse.tractusx.irs.edc.client.model.notification.NotificationContent; +import org.eclipse.tractusx.irs.ess.bpn.validation.BPNIncidentValidation; import org.eclipse.tractusx.irs.registryclient.discovery.ConnectorEndpointsService; +import org.eclipse.tractusx.irs.services.IrsItemGraphQueryService; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.event.EventListener; @@ -68,7 +66,7 @@ }) class InvestigationJobProcessingEventListener { - private final IrsFacade irsFacade; + private final IrsItemGraphQueryService irsItemGraphQueryService; private final ConnectorEndpointsService connectorEndpointsService; private final EdcSubmodelFacade edcSubmodelFacade; private final BpnInvestigationJobCache bpnInvestigationJobCache; @@ -77,13 +75,13 @@ class InvestigationJobProcessingEventListener { private final List mockRecursiveEdcAssets; private final EssRecursiveNotificationHandler recursiveNotificationHandler; - /* package */ InvestigationJobProcessingEventListener(final IrsFacade irsFacade, + /* package */ InvestigationJobProcessingEventListener(final IrsItemGraphQueryService irsItemGraphQueryService, final ConnectorEndpointsService connectorEndpointsService, final EdcSubmodelFacade edcSubmodelFacade, final BpnInvestigationJobCache bpnInvestigationJobCache, @Value("${ess.localBpn}") final String localBpn, @Value("${ess.localEdcEndpoint}") final String localEdcEndpoint, @Value("${ess.discovery.mockRecursiveEdcAsset}") final List mockRecursiveEdcAssets, final EssRecursiveNotificationHandler recursiveNotificationHandler) { - this.irsFacade = irsFacade; + this.irsItemGraphQueryService = irsItemGraphQueryService; this.connectorEndpointsService = connectorEndpointsService; this.edcSubmodelFacade = edcSubmodelFacade; this.bpnInvestigationJobCache = bpnInvestigationJobCache; @@ -140,7 +138,7 @@ private static SupplyChainImpacted validatePartSiteInformationAsPlanned(final Bp investigationJob.getIncidentBpns()); } catch (AspectTypeNotFoundException e) { log.warn("Aspect not found.", e); - partSiteInformationAsPlannedValidity = UNKNOWN; + partSiteInformationAsPlannedValidity = SupplyChainImpacted.UNKNOWN; } return partSiteInformationAsPlannedValidity; } @@ -152,7 +150,7 @@ private static SupplyChainImpacted validatePartAsPlanned(final Jobs completedJob partAsPlannedValidity = BPNIncidentValidation.partAsPlannedValidity(partAsPlanned); } catch (AspectTypeNotFoundException e) { log.warn("Aspect not found.", e); - partAsPlannedValidity = UNKNOWN; + partAsPlannedValidity = SupplyChainImpacted.UNKNOWN; } return partAsPlannedValidity; } @@ -170,7 +168,7 @@ public void handleJobProcessingFinishedEvent(final JobProcessingFinishedEvent jo bpnInvestigationJob.ifPresent(investigationJob -> { log.info("Job is completed. Starting SupplyChainImpacted processing for job {}.", completedJobId); - final Jobs completedJob = irsFacade.getIrsJob(completedJobId.toString()); + final Jobs completedJob = irsItemGraphQueryService.getJobForJobId(completedJobId, false); final SupplyChainImpacted partAsPlannedValidity = validatePartAsPlanned(completedJob); log.info("Local validation of PartAsPlanned Validity was done for job {}. with result {}.", completedJobId, partAsPlannedValidity); @@ -207,7 +205,7 @@ 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, UNKNOWN); + investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN); } // Map> final Map> bpns = getBPNsFromRelationships(completedJob.getRelationships()); @@ -223,15 +221,15 @@ private void triggerInvestigationOnNextLevel(final Jobs completedJob, .toList(); 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 {}", UNKNOWN); - investigationJobUpdate.update(completedJob, UNKNOWN); + + "Updating SupplyChainImpacted to {}", SupplyChainImpacted.UNKNOWN); + investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN); recursiveNotificationHandler.handleNotification(investigationJobUpdate.getJobSnapshot().getJob().getId(), - UNKNOWN); + SupplyChainImpacted.UNKNOWN); } else if (resolvedBPNs.isEmpty()) { - log.info("No BPNs could not be found. Updating SupplyChainImpacted to {}", UNKNOWN); - investigationJobUpdate.update(completedJob, UNKNOWN); + log.info("No BPNs could not be found. Updating SupplyChainImpacted to {}", SupplyChainImpacted.UNKNOWN); + investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN); recursiveNotificationHandler.handleNotification(investigationJobUpdate.getJobSnapshot().getJob().getId(), - UNKNOWN); + SupplyChainImpacted.UNKNOWN); } else { log.debug("Sending notification for BPNs '{}'", bpns); sendNotifications(completedJob, investigationJobUpdate, bpns); @@ -243,8 +241,8 @@ private void sendNotifications(final Jobs completedJob, final BpnInvestigationJo bpns.forEach((bpn, globalAssetIds) -> { final List edcBaseUrl = connectorEndpointsService.fetchConnectorEndpoints(bpn); if (edcBaseUrl.isEmpty()) { - log.warn("No EDC URL found for BPN '{}'. Setting investigation result to '{}'", bpn, UNKNOWN); - investigationJobUpdate.update(completedJob, UNKNOWN); + log.warn("No EDC URL found for BPN '{}'. Setting investigation result to '{}'", bpn, SupplyChainImpacted.UNKNOWN); + investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN); } edcBaseUrl.forEach(url -> { try { @@ -253,7 +251,7 @@ private void sendNotifications(final Jobs completedJob, final BpnInvestigationJo investigationJobUpdate.withNotifications(Collections.singletonList(notificationId)); } catch (final EdcClientException e) { log.error("Exception during sending EDC notification.", e); - investigationJobUpdate.update(completedJob, UNKNOWN); + investigationJobUpdate.update(completedJob, SupplyChainImpacted.UNKNOWN); } }); }); diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/NotificationSummary.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/NotificationSummary.java similarity index 98% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/NotificationSummary.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/NotificationSummary.java index 0285a40f03..e62a5d6b82 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/NotificationSummary.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/NotificationSummary.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Max; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/RelatedInvestigationJobs.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/RelatedInvestigationJobs.java similarity index 81% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/RelatedInvestigationJobs.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/RelatedInvestigationJobs.java index 99b729b19b..7b29a05e17 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/RelatedInvestigationJobs.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/RelatedInvestigationJobs.java @@ -21,16 +21,17 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import java.util.List; import java.util.UUID; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; +import org.eclipse.tractusx.irs.edc.client.model.notification.InvestigationNotificationContent; /** * RelatedInvestigationJobs to store in cache */ -public record RelatedInvestigationJobs(EdcNotification originalNotification, List recursiveRelatedJobIds) { +public record RelatedInvestigationJobs(EdcNotification originalNotification, List recursiveRelatedJobIds) { } diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/RelatedInvestigationJobsCache.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/RelatedInvestigationJobsCache.java similarity index 98% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/RelatedInvestigationJobsCache.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/RelatedInvestigationJobsCache.java index 94208f1301..5077c2a042 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/RelatedInvestigationJobsCache.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/RelatedInvestigationJobsCache.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import java.util.Optional; import java.util.UUID; diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/SupplyChainImpacted.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/SupplyChainImpacted.java similarity index 97% rename from irs-ess/src/main/java/org/eclipse/tractusx/ess/service/SupplyChainImpacted.java rename to irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/SupplyChainImpacted.java index 2b23191f00..019aa5064e 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/SupplyChainImpacted.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/SupplyChainImpacted.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import java.util.Locale; diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/bpn/validation/BPNIncidentValidationTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/bpn/validation/BPNIncidentValidationTest.java similarity index 99% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/bpn/validation/BPNIncidentValidationTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/bpn/validation/BPNIncidentValidationTest.java index 665ba05130..038afb1503 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/bpn/validation/BPNIncidentValidationTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/bpn/validation/BPNIncidentValidationTest.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.bpn.validation; +package org.eclipse.tractusx.irs.ess.bpn.validation; import static org.assertj.core.api.Assertions.assertThat; @@ -30,7 +30,7 @@ import java.util.List; import java.util.Map; -import org.eclipse.tractusx.ess.service.SupplyChainImpacted; +import org.eclipse.tractusx.irs.ess.service.SupplyChainImpacted; import org.eclipse.tractusx.irs.component.GlobalAssetIdentification; import org.eclipse.tractusx.irs.component.Job; import org.eclipse.tractusx.irs.component.Jobs; diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/EssControllerTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/EssControllerTest.java similarity index 98% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/EssControllerTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/EssControllerTest.java index efcb184df9..fd34ee0585 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/EssControllerTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/EssControllerTest.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.controller; +package org.eclipse.tractusx.irs.ess.controller; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; @@ -34,7 +34,7 @@ import java.util.UUID; import com.fasterxml.jackson.databind.ObjectMapper; -import org.eclipse.tractusx.ess.service.EssService; +import org.eclipse.tractusx.irs.ess.service.EssService; import org.eclipse.tractusx.irs.common.auth.AuthorizationService; import org.eclipse.tractusx.irs.common.auth.IrsRoles; import org.eclipse.tractusx.irs.component.JobHandle; diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/EssRecursiveControllerTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/EssRecursiveControllerTest.java similarity index 97% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/EssRecursiveControllerTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/EssRecursiveControllerTest.java index 672f609336..fa74452107 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/EssRecursiveControllerTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/EssRecursiveControllerTest.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.controller; +package org.eclipse.tractusx.irs.ess.controller; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -30,7 +30,7 @@ import java.util.List; import com.fasterxml.jackson.databind.ObjectMapper; -import org.eclipse.tractusx.ess.service.EssRecursiveService; +import org.eclipse.tractusx.irs.ess.service.EssRecursiveService; import org.eclipse.tractusx.irs.common.auth.IrsRoles; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotificationHeader; diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/NotificationReceiverControllerTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/NotificationReceiverControllerTest.java similarity index 94% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/NotificationReceiverControllerTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/NotificationReceiverControllerTest.java index 39316f195b..2bb9cfa496 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/NotificationReceiverControllerTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/NotificationReceiverControllerTest.java @@ -21,12 +21,12 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.controller; +package org.eclipse.tractusx.irs.ess.controller; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; -import org.eclipse.tractusx.ess.service.EssService; +import org.eclipse.tractusx.irs.ess.service.EssService; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; import org.eclipse.tractusx.irs.edc.client.model.notification.ResponseNotificationContent; import org.junit.jupiter.api.Test; diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/mock/MockedNotificationReceiverControllerTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/mock/MockedNotificationReceiverControllerTest.java similarity index 97% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/mock/MockedNotificationReceiverControllerTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/mock/MockedNotificationReceiverControllerTest.java index 642cbe0cd3..fb9bb172d4 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/controller/mock/MockedNotificationReceiverControllerTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/controller/mock/MockedNotificationReceiverControllerTest.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.controller.mock; +package org.eclipse.tractusx.irs.ess.controller.mock; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; @@ -33,8 +33,8 @@ import java.util.Map; import java.util.UUID; -import org.eclipse.tractusx.ess.discovery.EdcDiscoveryMockConfig; -import org.eclipse.tractusx.ess.service.SupplyChainImpacted; +import org.eclipse.tractusx.irs.ess.discovery.EdcDiscoveryMockConfig; +import org.eclipse.tractusx.irs.ess.service.SupplyChainImpacted; import org.eclipse.tractusx.irs.common.auth.IrsRoles; import org.eclipse.tractusx.irs.edc.client.EdcSubmodelFacade; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EdcNotificationSenderTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EdcNotificationSenderTest.java similarity index 99% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EdcNotificationSenderTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EdcNotificationSenderTest.java index f6620e2e06..d6ce4efa71 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EdcNotificationSenderTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EdcNotificationSenderTest.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyString; diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EdcRegistrationTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EdcRegistrationTest.java similarity index 98% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EdcRegistrationTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EdcRegistrationTest.java index c21dd6e5ea..ee40262de7 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EdcRegistrationTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EdcRegistrationTest.java @@ -21,7 +21,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EssRecursiveNotificationHandlerTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveNotificationHandlerTest.java similarity index 91% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EssRecursiveNotificationHandlerTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveNotificationHandlerTest.java index 084874164c..14827db4f6 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EssRecursiveNotificationHandlerTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveNotificationHandlerTest.java @@ -21,11 +21,10 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; @@ -37,8 +36,10 @@ import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotificationHeader; +import org.eclipse.tractusx.irs.edc.client.model.notification.InvestigationNotificationContent; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) @@ -46,9 +47,9 @@ class EssRecursiveNotificationHandlerTest { private final RelatedInvestigationJobsCache relatedInvestigationJobsCache = new InMemoryRelatedInvestigationJobsCache(); private final BpnInvestigationJobCache bpnInvestigationJobCache = new InMemoryBpnInvestigationJobCache(); - private final EdcNotificationSender edcNotificationSender = mock(EdcNotificationSender.class); - private final BpnInvestigationJob currentBpnInvestigationJob = mock(BpnInvestigationJob.class); - private final BpnInvestigationJob pastBpnInvestigationJob = mock(BpnInvestigationJob.class); + private final EdcNotificationSender edcNotificationSender = Mockito.mock(EdcNotificationSender.class); + private final BpnInvestigationJob currentBpnInvestigationJob = Mockito.mock(BpnInvestigationJob.class); + private final BpnInvestigationJob pastBpnInvestigationJob = Mockito.mock(BpnInvestigationJob.class); private final EssRecursiveNotificationHandler cut = new EssRecursiveNotificationHandler(relatedInvestigationJobsCache, bpnInvestigationJobCache, edcNotificationSender); private final UUID jobId = UUID.randomUUID(); @@ -93,7 +94,7 @@ void shouldReplyOnlyWhenAllJobsAreCompleted() { } private RelatedInvestigationJobs createRelatedJobsWith(List uuids) { - return new RelatedInvestigationJobs(EdcNotification.builder() + return new RelatedInvestigationJobs(EdcNotification.builder() .header(EdcNotificationHeader.builder() .notificationId( "notification-id") diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EssRecursiveServiceTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveServiceTest.java similarity index 96% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EssRecursiveServiceTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveServiceTest.java index 5b9a289f27..7519fd3877 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EssRecursiveServiceTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssRecursiveServiceTest.java @@ -21,11 +21,10 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -46,10 +45,10 @@ @ExtendWith(MockitoExtension.class) class EssRecursiveServiceTest { - private final EssService essService = mock(EssService.class); + private final EssService essService = Mockito.mock(EssService.class); private final RelatedInvestigationJobsCache relatedInvestigationJobsCache = new InMemoryRelatedInvestigationJobsCache(); private final String localBpn = "BPNS000000000AAA"; - private final EdcNotificationSender edcNotificationSender = mock(EdcNotificationSender.class); + private final EdcNotificationSender edcNotificationSender = Mockito.mock(EdcNotificationSender.class); private final EssRecursiveService essRecursiveService = new EssRecursiveService(essService, relatedInvestigationJobsCache, localBpn, edcNotificationSender); diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EssServiceTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssServiceTest.java similarity index 95% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EssServiceTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssServiceTest.java index 6e16261d7a..5610665e6f 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/EssServiceTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/EssServiceTest.java @@ -21,13 +21,12 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -36,7 +35,6 @@ import java.util.List; import java.util.UUID; -import org.eclipse.tractusx.ess.irs.IrsFacade; import org.eclipse.tractusx.irs.common.auth.IrsRoles; import org.eclipse.tractusx.irs.common.auth.SecurityHelperService; import org.eclipse.tractusx.irs.component.GlobalAssetIdentification; @@ -45,23 +43,26 @@ import org.eclipse.tractusx.irs.component.Jobs; import org.eclipse.tractusx.irs.component.PartChainIdentificationKey; import org.eclipse.tractusx.irs.component.RegisterBpnInvestigationJob; +import org.eclipse.tractusx.irs.component.RegisterJob; import org.eclipse.tractusx.irs.component.enums.JobState; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotificationHeader; import org.eclipse.tractusx.irs.edc.client.model.notification.ResponseNotificationContent; +import org.eclipse.tractusx.irs.services.IrsItemGraphQueryService; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import org.springframework.web.server.ResponseStatusException; class EssServiceTest { - private final IrsFacade irsFacade = mock(IrsFacade.class); + private final IrsItemGraphQueryService irsItemGraphQueryService = mock(IrsItemGraphQueryService.class); private final SecurityHelperService securityHelperService = mock(SecurityHelperService.class); private final BpnInvestigationJobCache bpnInvestigationJobCache = new InMemoryBpnInvestigationJobCache(); - private final EssRecursiveNotificationHandler recursiveNotificationHandler = mock( + private final EssRecursiveNotificationHandler recursiveNotificationHandler = Mockito.mock( EssRecursiveNotificationHandler.class); - private final EssService essService = new EssService(irsFacade, securityHelperService, bpnInvestigationJobCache, + private final EssService essService = new EssService(irsItemGraphQueryService, securityHelperService, bpnInvestigationJobCache, recursiveNotificationHandler); @Test @@ -88,8 +89,8 @@ void shouldSuccessfullyStartJobAndReturnWithExtendedSubmodelList() { .shells(new ArrayList<>()) .build(); - when(irsFacade.startIrsJob(eq(key), any())).thenReturn(JobHandle.builder().id(createdJobId).build()); - when(irsFacade.getIrsJob(createdJobId.toString())).thenReturn(expectedResponse); + when(irsItemGraphQueryService.registerItemJob(any(RegisterJob.class))).thenReturn(JobHandle.builder().id(createdJobId).build()); + when(irsItemGraphQueryService.getJobForJobId(createdJobId, true)).thenReturn(expectedResponse); when(securityHelperService.isAdmin()).thenReturn(true); final JobHandle jobHandle = essService.startIrsJob(request); diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/InvestigationJobProcessingEventListenerTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/InvestigationJobProcessingEventListenerTest.java similarity index 96% rename from irs-ess/src/test/java/org/eclipse/tractusx/ess/service/InvestigationJobProcessingEventListenerTest.java rename to irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/InvestigationJobProcessingEventListenerTest.java index 813ed22835..83ae37291b 100644 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/service/InvestigationJobProcessingEventListenerTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/ess/service/InvestigationJobProcessingEventListenerTest.java @@ -21,10 +21,10 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.ess.service; +package org.eclipse.tractusx.irs.ess.service; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.tractusx.ess.service.EdcRegistration.ASSET_ID_REQUEST_RECURSIVE; +import static org.eclipse.tractusx.irs.ess.service.EdcRegistration.ASSET_ID_REQUEST_RECURSIVE; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -39,7 +39,6 @@ import java.util.Optional; import java.util.UUID; -import org.eclipse.tractusx.ess.irs.IrsFacade; import org.eclipse.tractusx.irs.common.JobProcessingFinishedEvent; import org.eclipse.tractusx.irs.component.GlobalAssetIdentification; import org.eclipse.tractusx.irs.component.Job; @@ -57,20 +56,22 @@ import org.eclipse.tractusx.irs.edc.client.model.notification.InvestigationNotificationContent; import org.eclipse.tractusx.irs.edc.client.model.notification.NotificationContent; import org.eclipse.tractusx.irs.registryclient.discovery.ConnectorEndpointsService; +import org.eclipse.tractusx.irs.services.IrsItemGraphQueryService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; +import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) class InvestigationJobProcessingEventListenerTest { - private final IrsFacade irsFacade = mock(IrsFacade.class); + private final IrsItemGraphQueryService irsItemGraphQueryService = mock(IrsItemGraphQueryService.class); private final EdcSubmodelFacade edcSubmodelFacade = mock(EdcSubmodelFacade.class); - private final BpnInvestigationJobCache bpnInvestigationJobCache = mock(BpnInvestigationJobCache.class); - private final EssRecursiveNotificationHandler recursiveNotificationHandler = mock( + private final BpnInvestigationJobCache bpnInvestigationJobCache = Mockito.mock(BpnInvestigationJobCache.class); + private final EssRecursiveNotificationHandler recursiveNotificationHandler = Mockito.mock( EssRecursiveNotificationHandler.class); private final UUID jobId = UUID.randomUUID(); private final UUID recursiveJobId = UUID.randomUUID(); @@ -78,7 +79,7 @@ class InvestigationJobProcessingEventListenerTest { private final ConnectorEndpointsService connectorEndpointsService = mock(ConnectorEndpointsService.class); private final InvestigationJobProcessingEventListener jobProcessingEventListener = new InvestigationJobProcessingEventListener( - irsFacade, connectorEndpointsService, edcSubmodelFacade, bpnInvestigationJobCache, "", "", List.of(), + irsItemGraphQueryService, connectorEndpointsService, edcSubmodelFacade, bpnInvestigationJobCache, "", "", List.of(), recursiveNotificationHandler); @Captor @@ -348,7 +349,7 @@ private void createMockForJobIdAndShell(final UUID mockedJobId, final String moc final BpnInvestigationJob bpnInvestigationJob = BpnInvestigationJob.create(jobs, "owner", incindentBPNSs); when(bpnInvestigationJobCache.findByJobId(mockedJobId)).thenReturn(Optional.of(bpnInvestigationJob)); - when(irsFacade.getIrsJob(mockedJobId.toString())).thenReturn(jobs); + when(irsItemGraphQueryService.getJobForJobId(mockedJobId, false)).thenReturn(jobs); } private void createMockForJobIdAndShell(final UUID mockedJobId, final String mockedShell, @@ -368,7 +369,7 @@ private void createMockForJobIdAndShells(final UUID mockedJobId, final List - - 4.0.0 - - - org.eclipse.tractusx.irs - irs-parent-spring-boot - ${revision} - ../irs-parent-spring-boot - - - irs-ess - ESS - Environmental- and Social Standards - - - - org.eclipse.tractusx.irs - irs-models - ${revision} - - - org.yaml - snakeyaml - - - - - org.eclipse.tractusx.irs - irs-edc-client - ${revision} - - - org.eclipse.tractusx.irs - irs-registry-client - ${irs-registry-client.version} - - - org.yaml - snakeyaml - - - - - org.eclipse.tractusx.irs - irs-common - ${revision} - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - - org.yaml - snakeyaml - - - - - org.springframework.boot - spring-boot-starter-validation - - - org.springframework.boot - spring-boot-starter-logging - - - jakarta.annotation - jakarta.annotation-api - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-log4j2 - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-oauth2-resource-server - - - org.projectlombok - lombok - true - - - io.swagger - swagger-annotations - 1.6.8 - compile - - - - org.eclipse.tractusx.irs - irs-testing - ${revision} - test - - - org.yaml - snakeyaml - - - - - org.springframework.security - spring-security-test - test - - - io.rest-assured - rest-assured - 5.2.0 - test - - - - org.apache.groovy - groovy-xml - - - - - io.rest-assured - json-path - 5.2.0 - test - - - - io.rest-assured - xml-path - 5.2.0 - test - - - io.rest-assured - rest-assured-common - 5.2.0 - test - - - - diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/irs/IrsClient.java b/irs-ess/src/main/java/org/eclipse/tractusx/ess/irs/IrsClient.java deleted file mode 100644 index 597c4e6e31..0000000000 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/irs/IrsClient.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021,2022,2023 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -package org.eclipse.tractusx.ess.irs; - -import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.irs.component.JobHandle; -import org.eclipse.tractusx.irs.component.Jobs; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -/** - * IRS Client to fetch IRS Response - */ -@Service -@Slf4j -class IrsClient { - - private final RestTemplate restTemplate; - private final String irsUrl; - - /* package */ IrsClient(final RestTemplate oAuthRestTemplate, @Value("${ess.irs.url:}") final String irsUrl) { - this.restTemplate = oAuthRestTemplate; - this.irsUrl = irsUrl; - } - - public JobHandle startJob(final IrsRequest irsRequest) { - return restTemplate.postForObject(irsUrl + "/irs/jobs", new HttpEntity<>(irsRequest), JobHandle.class); - } - - public Jobs getJobDetails(final String jobId) { - final UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString(irsUrl); - uriBuilder.path("/irs/jobs/").path(jobId); - - return restTemplate.getForObject( - uriBuilder.build().toUri(), - Jobs.class); - } - -} diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/irs/IrsFacade.java b/irs-ess/src/main/java/org/eclipse/tractusx/ess/irs/IrsFacade.java deleted file mode 100644 index a8b833ada9..0000000000 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/irs/IrsFacade.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021,2022,2023 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -package org.eclipse.tractusx.ess.irs; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.irs.component.JobHandle; -import org.eclipse.tractusx.irs.component.Jobs; -import org.eclipse.tractusx.irs.component.PartChainIdentificationKey; -import org.eclipse.tractusx.irs.component.enums.BomLifecycle; -import org.springframework.stereotype.Service; - -/** - * Public API Facade for IRS domain - */ -@Service -@RequiredArgsConstructor -@Slf4j -public class IrsFacade { - - private final IrsClient irsClient; - - public JobHandle startIrsJob(final PartChainIdentificationKey key, final BomLifecycle bomLifecycle) { - final JobHandle response = irsClient.startJob(IrsRequest.bpnInvestigations(key, bomLifecycle)); - log.info("Registered IRS job with jobId: {}", response.getId()); - return response; - } - - public Jobs getIrsJob(final String jobId) { - final Jobs response = irsClient.getJobDetails(jobId); - log.info("Retrieved IRS job with jobId: {}", response.getJob().getId()); - return response; - } - -} diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/irs/IrsRequest.java b/irs-ess/src/main/java/org/eclipse/tractusx/ess/irs/IrsRequest.java deleted file mode 100644 index c814be8b64..0000000000 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/irs/IrsRequest.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021,2022,2023 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -package org.eclipse.tractusx.ess.irs; - -import java.util.List; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Value; -import org.eclipse.tractusx.irs.component.PartChainIdentificationKey; -import org.eclipse.tractusx.irs.component.enums.AspectType; -import org.eclipse.tractusx.irs.component.enums.BomLifecycle; - -/** - * Irs Request for IRS API - */ -@Value -@Builder(toBuilder = true) -@AllArgsConstructor -class IrsRequest { - private PartChainIdentificationKey key; - private String bomLifecycle; - private List aspects; - private boolean collectAspects; - private int depth; - - /** - * Predefined request body for SupplyChain processing - * - * @param key the key to identify the asset - * @param bomLifecycle lifecycle - default is asPlanned - * @return request body - */ - /* package */ static IrsRequest bpnInvestigations(final PartChainIdentificationKey key, final BomLifecycle bomLifecycle) { - return IrsRequest.builder() - .key(key) - .bomLifecycle( - bomLifecycle != null ? bomLifecycle.getName() : BomLifecycle.AS_PLANNED.getName()) - .depth(1) - .aspects(List.of(AspectType.PART_SITE_INFORMATION_AS_PLANNED.toString(), - AspectType.PART_AS_PLANNED.toString())) - .collectAspects(true) - .build(); - } - -} diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/TestApplication.java b/irs-ess/src/test/java/org/eclipse/tractusx/ess/TestApplication.java deleted file mode 100644 index 43610ff6bb..0000000000 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/TestApplication.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.eclipse.tractusx.ess; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class TestApplication {} diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/irs/IrsClientTest.java b/irs-ess/src/test/java/org/eclipse/tractusx/ess/irs/IrsClientTest.java deleted file mode 100644 index b3518274c6..0000000000 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/irs/IrsClientTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021,2022,2023 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -package org.eclipse.tractusx.ess.irs; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; - -import java.net.URI; -import java.util.UUID; - -import org.eclipse.tractusx.irs.component.Job; -import org.eclipse.tractusx.irs.component.JobHandle; -import org.eclipse.tractusx.irs.component.Jobs; -import org.eclipse.tractusx.irs.component.PartChainIdentificationKey; -import org.eclipse.tractusx.irs.component.enums.JobState; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.springframework.http.HttpEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -class IrsClientTest { - - private static final String URL = "https://irs-esr.dev.demo.catena-x.net/"; - private static final String JOB_ID = "1545da82-e5b3-4fda-bc35-866dc6a29c4c"; - private final RestTemplate restTemplate = Mockito.mock(RestTemplate.class); - - @Test - void shouldStartJob() { - // given - IrsClient irsClient = new IrsClient(restTemplate, URL); - IrsRequest irsRequest = IrsRequest.builder().key( - PartChainIdentificationKey.builder().globalAssetId("global-id").bpn("BPNL0000000000DD").build()).bomLifecycle("asBuilt").build(); - JobHandle expectedResponse = JobHandle.builder().id(UUID.fromString(JOB_ID)).build(); - - given(restTemplate.postForObject(URL + "/irs/jobs", - new HttpEntity<>(irsRequest), JobHandle.class)) - .willReturn(expectedResponse); - - // when - final JobHandle actualResponse = irsClient.startJob(irsRequest); - - // then - assertThat(actualResponse).isEqualTo(expectedResponse); - } - - @Test - void shouldFetchResponseWithEmptyList() { - // given - IrsClient irsClient = new IrsClient(restTemplate, URL); - Jobs expectedResponse = Jobs.builder().job(Job.builder().id(UUID.randomUUID()).state(JobState.COMPLETED).build()).build(); - - given(restTemplate.getForObject(getUriWithJobId(URL, JOB_ID), Jobs.class)) - .willReturn(expectedResponse); - - // when - final Jobs actualResponse = irsClient.getJobDetails(JOB_ID); - - // then - assertThat(actualResponse).isEqualTo(expectedResponse); - } - - private URI getUriWithJobId(String url, String jobId) { - final UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString(url); - uriBuilder.path("/irs/jobs/").path(jobId); - return uriBuilder.build().toUri(); - } - -} diff --git a/irs-ess/src/test/java/org/eclipse/tractusx/ess/irs/IrsFacadeTest.java b/irs-ess/src/test/java/org/eclipse/tractusx/ess/irs/IrsFacadeTest.java deleted file mode 100644 index bde339a947..0000000000 --- a/irs-ess/src/test/java/org/eclipse/tractusx/ess/irs/IrsFacadeTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021,2022,2023 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -package org.eclipse.tractusx.ess.irs; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; - -import java.util.ArrayList; -import java.util.UUID; - -import org.eclipse.tractusx.irs.component.Job; -import org.eclipse.tractusx.irs.component.JobHandle; -import org.eclipse.tractusx.irs.component.Jobs; -import org.eclipse.tractusx.irs.component.PartChainIdentificationKey; -import org.eclipse.tractusx.irs.component.enums.BomLifecycle; -import org.eclipse.tractusx.irs.component.enums.JobState; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class IrsFacadeTest { - - @Mock - private IrsClient irsClient; - - @InjectMocks - private IrsFacade irsFacade; - - @Test - void shouldFetchIrsJobResponse() { - // given - final UUID jobId = UUID.randomUUID(); - final Jobs expectedResponse = Jobs.builder() - .job(Job.builder().state(JobState.COMPLETED).id(jobId).build()) - .relationships(new ArrayList<>()) - .shells(new ArrayList<>()) - .build(); - - given(irsClient.getJobDetails(jobId.toString())).willReturn(expectedResponse); - - // when - final Jobs actualResponse = irsFacade.getIrsJob(jobId.toString()); - - // then - assertThat(actualResponse).isEqualTo(expectedResponse); - } - - @Test - void shouldStartIrsJobAndReturnJobId() { - // given - final UUID jobId = UUID.randomUUID(); - final JobHandle expectedResponse = JobHandle.builder().id(jobId).build(); - - given(irsClient.startJob(any())).willReturn(JobHandle.builder().id(jobId).build()); - - // when - final JobHandle actualResponse = irsFacade.startIrsJob(PartChainIdentificationKey.builder() - .globalAssetId( - UUID.randomUUID() - .toString()) - .bpn("BPNL000000000DD") - .build(), - BomLifecycle.AS_PLANNED); - - // then - assertThat(actualResponse).isEqualTo(expectedResponse); - } - -} diff --git a/pom.xml b/pom.xml index 412ae003cb..ea4ffb478a 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,6 @@ irs-common irs-edc-client irs-registry-client - irs-ess irs-policy-store irs-api irs-models