diff --git a/.github/workflows/helm-test.yaml b/.github/workflows/helm-test.yaml index 7b3c8caa71..2876dbbcb6 100644 --- a/.github/workflows/helm-test.yaml +++ b/.github/workflows/helm-test.yaml @@ -78,8 +78,8 @@ jobs: run: | helm repo add bitnami https://charts.bitnami.com/bitnami helm repo add irs-helm https://eclipse-tractusx.github.io/item-relationship-service - helm repo add irs-edc-consumer https://eclipse-tractusx.github.io/item-relationship-service helm repo add postgresql https://charts.bitnami.com/bitnami + helm repo add tractusx-connector https://eclipse-tractusx.github.io/charts/dev helm repo add runix https://helm.runix.net ct install --charts charts/traceability-foss --helm-extra-set-args "--set backend.image.repository=${{ env.REGISTRY }}/${{ env.APP_NAME}} --set backend.image.tag=${{ env.TAG }} --set frontend.image.repository=${{ env.REGISTRY }}/traceability-foss --set frontend.image.tag=${{ env.TAG }} --set postgresql.enabled=false" if: steps.list-changed.outputs.changed == 'true' diff --git a/.github/workflows/pull-request_backend.yml b/.github/workflows/pull-request_backend.yml index a0153d8d42..f68ab38bd8 100644 --- a/.github/workflows/pull-request_backend.yml +++ b/.github/workflows/pull-request_backend.yml @@ -24,7 +24,7 @@ jobs: cache: 'maven' - name: Run unit & integration tests - run: mvn -pl tx-models,tx-backend,tx-coverage -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B verify -PiT + run: mvn -pl tx-models,tx-backend,tx-coverage -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B verify - name: Publish integration test results uses: EnricoMi/publish-unit-test-result-action@v2 diff --git a/.github/workflows/sonar-scan-backend.yml b/.github/workflows/sonar-scan-backend.yml index 7dd714a121..f86bf51c9e 100644 --- a/.github/workflows/sonar-scan-backend.yml +++ b/.github/workflows/sonar-scan-backend.yml @@ -33,7 +33,7 @@ jobs: restore-keys: ${{ runner.os }}-sonar - name: Run unit & integration tests - run: mvn -pl tx-models,tx-backend,tx-coverage -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B verify -PiT + run: mvn -pl tx-models,tx-backend,tx-coverage -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B verify - name: Verify Sonar Scan env: diff --git a/AUTHORS.md b/AUTHORS.md index 4d01970504..425e3eca60 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -18,3 +18,5 @@ The following people have contributed to this repository: - Thomas Braun, ZF Friedrichshafen AG, https://github.com/tbraun-zf - Maximilian Wesener, doubleSlash Net-Business GmbH, https://github.com/ds-mwesener - László Graf, msg systems Romania, https://www.msg-systems.ro +- Martin Maul, doubleSlash Net-Business GmbH, https://github.com/ds-mmaul +- Lucas Capellino, doubleSlash Net-Business GmbH, https://github.com/ds-lcapellino diff --git a/CHANGELOG.md b/CHANGELOG.md index e50bc66d5a..106592e8c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] ### Added +- Added back button in notification detailed view +- EDC SPI Dependency for using provided models ### Changed +- Changed Layout in notification detailed view +- Changed request parameter for registerjob request to irs to match requirements of irs +- Migration of edc 0.4.1 endpoints and api flow ### Removed diff --git a/DEPENDENCIES_BACKEND b/DEPENDENCIES_BACKEND index 087859b378..d63cf144f6 100644 --- a/DEPENDENCIES_BACKEND +++ b/DEPENDENCIES_BACKEND @@ -1,13 +1,18 @@ maven/mavencentral/ch.qos.logback/logback-classic/1.4.7, EPL-1.0 OR LGPL-2.1-only, approved, #3435 maven/mavencentral/ch.qos.logback/logback-core/1.4.7, EPL-1.0 OR LGPL-2.1-only, approved, #3373 +maven/mavencentral/com.apicatalog/titanium-json-ld/1.3.2, Apache-2.0, approved, #8912 maven/mavencentral/com.auth0/java-jwt/4.4.0, MIT, approved, #8459 maven/mavencentral/com.electronwill.night-config/core/3.6.6, LGPL-3.0-only, approved, #3767 maven/mavencentral/com.electronwill.night-config/toml/3.6.6, LGPL-3.0-only, approved, #3766 maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.14.3, Apache-2.0, approved, #5303 +maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.14.2, Apache-2.0 AND MIT, approved, #4303 maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.14.3, Apache-2.0 AND MIT, approved, #4303 +maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.14.2, Apache-2.0, approved, #4105 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.14.3, Apache-2.0, approved, #4105 maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.14.0, Apache-2.0, approved, #5933 maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.14.3, Apache-2.0, approved, #5933 +maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jakarta-jsonp/2.14.3, , restricted, clearlydefined +maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jakarta-jsonp/2.15.1, Apache-2.0, approved, #9179 maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.14.3, Apache-2.0, approved, #8597 maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.14.3, Apache-2.0, approved, #4699 maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.14.3, Apache-2.0, approved, #5938 @@ -27,6 +32,8 @@ maven/mavencentral/com.zaxxer/HikariCP/5.0.1, Apache-2.0, approved, clearlydefin maven/mavencentral/commons-fileupload/commons-fileupload/1.5, Apache-2.0, approved, #7109 maven/mavencentral/commons-io/commons-io/2.11.0, Apache-2.0, approved, CQ23745 maven/mavencentral/commons-logging/commons-logging/1.2, Apache-2.0, approved, CQ10162 +maven/mavencentral/dev.failsafe/failsafe-okhttp/3.3.1, Apache-2.0, approved, #9178 +maven/mavencentral/dev.failsafe/failsafe/3.3.1, Apache-2.0, approved, #9268 maven/mavencentral/io.github.classgraph/classgraph/4.8.149, MIT, approved, CQ22530 maven/mavencentral/io.github.openfeign.form/feign-form-spring/3.8.0, Apache-2.0, approved, clearlydefined maven/mavencentral/io.github.openfeign.form/feign-form/3.8.0, Apache-2.0, approved, clearlydefined @@ -55,6 +62,7 @@ maven/mavencentral/io.swagger.core.v3/swagger-models-jakarta/2.2.8, Apache-2.0, maven/mavencentral/io.swagger/swagger-annotations/1.6.10, Apache-2.0, approved, #3792 maven/mavencentral/jakarta.activation/jakarta.activation-api/2.1.2, EPL-2.0 OR BSD-3-Clause OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jaf maven/mavencentral/jakarta.annotation/jakarta.annotation-api/2.1.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.ca +maven/mavencentral/jakarta.json/jakarta.json-api/2.1.1, EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0, approved, #7907 maven/mavencentral/jakarta.persistence/jakarta.persistence-api/3.0.0, EPL-2.0 OR BSD-3-Clause AND (EPL-2.0 OR BSD-3-Clause AND BSD-3-Clause), approved, #9177 maven/mavencentral/jakarta.persistence/jakarta.persistence-api/3.1.0, EPL-2.0 OR BSD-3-Clause AND (EPL-2.0 OR BSD-3-Clause AND BSD-3-Clause), approved, #7696 maven/mavencentral/jakarta.transaction/jakarta.transaction-api/2.0.0, EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0, approved, #7697 @@ -84,18 +92,60 @@ maven/mavencentral/org.attoparser/attoparser/2.0.6.RELEASE, Apache-2.0, approved maven/mavencentral/org.bouncycastle/bcpkix-jdk15on/1.69, MIT, approved, clearlydefined maven/mavencentral/org.bouncycastle/bcprov-jdk15on/1.69, MIT, approved, clearlydefined maven/mavencentral/org.bouncycastle/bcutil-jdk15on/1.69, MIT, approved, clearlydefined +maven/mavencentral/org.eclipse.edc/aggregate-service-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/asset-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/catalog-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/connector-core/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/contract-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/control-plane-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/core-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-api-configuration/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-catalog-api/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-catalog-http-dispatcher/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-catalog-transform/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-catalog/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-http-core/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-http-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-negotiation-api/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-negotiation-http-dispatcher/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-negotiation-transform/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-negotiation/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-transfer-process-api/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-transfer-process-http-dispatcher/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-transfer-process-transform/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-transfer-process/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-transform/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/http-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/http/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/jersey-core/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/jetty-core/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/json-ld-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/json-ld/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/policy-engine-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/policy-model/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/policy-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transaction-datasource-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transaction-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transfer-data-plane-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transfer-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transform-spi/0.1.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/web-spi/0.1.0, Apache-2.0, approved, technology.edc maven/mavencentral/org.eclipse.tractusx.traceability/tx-backend/0.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx maven/mavencentral/org.eclipse.tractusx.traceability/tx-models/0.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx maven/mavencentral/org.flywaydb/flyway-core/9.5.1, Apache-2.0, approved, #7296 +maven/mavencentral/org.glassfish/jakarta.json/2.0.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jsonp maven/mavencentral/org.hibernate.orm/hibernate-core/6.1.7.Final, LGPL-2.1-or-later AND (Apache-2.0 AND LGPL-2.1-only) AND (CC-PDDC AND LGPL-2.1-only) AND (EPL-2.0 OR BSD-3-Clause), approved, #5939 maven/mavencentral/org.hibernate.validator/hibernate-validator/8.0.0.Final, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jboss.logging/jboss-logging/3.4.3.Final, Apache-2.0, approved, CQ21255 maven/mavencentral/org.jboss.logging/jboss-logging/3.5.0.Final, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.31, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-common/1.7.22, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.31, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.6.10, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.7.22, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.31, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.6.10, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.7.22, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib/1.6.20, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib/1.7.22, Apache-2.0, approved, clearlydefined diff --git a/DEPENDENCIES_FRONTEND b/DEPENDENCIES_FRONTEND index 8b639cff56..10fb5666e4 100644 --- a/DEPENDENCIES_FRONTEND +++ b/DEPENDENCIES_FRONTEND @@ -603,7 +603,7 @@ npm/npmjs/-/license-webpack-plugin/4.0.2, ISC AND MIT AND (BSD-3-Clause AND ISC npm/npmjs/-/lilconfig/2.0.6, MIT, approved, clearlydefined npm/npmjs/-/lilconfig/2.1.0, MIT, approved, #7313 npm/npmjs/-/lines-and-columns/1.2.4, MIT, approved, clearlydefined -npm/npmjs/-/lint-staged/13.2.1, MIT, approved, clearlydefined +npm/npmjs/-/lint-staged/13.2.1, MIT, approved, #9206 npm/npmjs/-/listr2/3.14.0, MIT, approved, clearlydefined npm/npmjs/-/listr2/5.0.8, MIT, approved, clearlydefined npm/npmjs/-/loader-runner/4.3.0, MIT, approved, clearlydefined @@ -742,7 +742,7 @@ npm/npmjs/-/onetime/6.0.0, MIT, approved, clearlydefined npm/npmjs/-/open/8.4.1, MIT, approved, #7102 npm/npmjs/-/open/8.4.2, MIT, approved, #7102 npm/npmjs/-/opener/1.5.2, MIT OR WTFPL OR (MIT AND WTFPL), approved, clearlydefined -npm/npmjs/-/optionator/0.9.1, MIT, approved, clearlydefined +npm/npmjs/-/optionator/0.9.1, MIT, approved, #9208 npm/npmjs/-/ora/5.4.1, MIT, approved, clearlydefined npm/npmjs/-/os-tmpdir/1.0.2, MIT, approved, clearlydefined npm/npmjs/-/ospath/1.2.2, MIT, approved, clearlydefined diff --git a/README.md b/README.md index 5084d98b77..74bb38f89e 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ persistence layer, thus [Docker Engine](https://docs.docker.com/engine/) is requ To run integration tests invoke following command: ```sh -mvn clean verify -PiT +mvn clean verify ``` #### Running all tests @@ -142,7 +142,7 @@ mvn clean verify -PiT To run all tests invoke following command: ```sh -mvn -DskipTests=false clean verify -PiT +mvn -DskipTests=false clean verify ``` *Please note that this task depends on `integrationTest` task, so it's required to have [Docker Engine](https://docs.docker.com/engine/) running.* diff --git a/charts/traceability-foss/Chart.yaml b/charts/traceability-foss/Chart.yaml index cdd68cda4f..6c8975947f 100644 --- a/charts/traceability-foss/Chart.yaml +++ b/charts/traceability-foss/Chart.yaml @@ -39,9 +39,14 @@ dependencies: condition: pgadmin4.enabled - name: irs-helm repository: https://eclipse-tractusx.github.io/item-relationship-service - version: 5.3.0 + version: 6.0.1 condition: irs-helm.enabled - - name: irs-edc-consumer - repository: https://eclipse-tractusx.github.io/item-relationship-service - version: 1.1.2 - condition: irs-edc-consumer.enabled + - condition: tractusx-connector.enabled + name: tractusx-connector + repository: https://eclipse-tractusx.github.io/charts/dev + version: 0.4.1 + - condition: edc-postgresql.enabled + alias: edc-postgresql + name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 12.1.6 diff --git a/charts/traceability-foss/values.yaml b/charts/traceability-foss/values.yaml index 629446ed2e..2ae091c575 100644 --- a/charts/traceability-foss/values.yaml +++ b/charts/traceability-foss/values.yaml @@ -343,8 +343,34 @@ postgresql: irs-helm: enabled: false # +################################### +# EDC Consumer configuration # +################################### +tractusx-connector: + enabled: false + + participant: + id: "BPN" + + ################################## + # EDC Postgres Configuration # + ################################## + postgresql: + enabled: false + auth: + username: "CHANGEME" + password: "CHANGEME" + username: "CHANGEME" + password: "CHANGEME" + jdbcUrl: "CHANGEME" + ################################### # IRS EDC Consumer configuration # ################################### -irs-edc-consumer: - enabled: false # +edc-postgresql: + enabled: false + auth: + postgresPassword: "CHANGEME" + password: "CHANGEME" + database: "trace" + username: "traceuser" diff --git a/frontend/angular.json b/frontend/angular.json index 25bf03c776..b2527f9485 100644 --- a/frontend/angular.json +++ b/frontend/angular.json @@ -80,6 +80,14 @@ } ] }, + "authE2eA": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.authE2eA.ts" + } + ] + }, "authLocal": { "fileReplacements": [ { @@ -161,6 +169,9 @@ "authTest": { "browserTarget": "trace-x:build:dev,authTest" }, + "authE2eA": { + "browserTarget": "trace-x:build:dev,authE2eA" + }, "authLocal": { "browserTarget": "trace-x:build:dev,authLocal" }, diff --git a/frontend/package.json b/frontend/package.json index 190794601a..b5a5a0cabb 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -16,6 +16,7 @@ "start" : "ng serve", "start:auth" : "ng serve --configuration=dev,auth", "start:auth:test": "ng serve --configuration=dev,authTest", + "start:auth:e2ea": "ng serve --configuration=dev,authE2eA", "start:auth:mock" : "ng serve --configuration=authMock", "start:auth:local" : "ng serve --configuration=authLocal", "start:auth:localBe" : "ng serve --configuration=localBackend", diff --git a/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.html b/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.html index 17f6d13d4f..ecc11991c0 100644 --- a/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.html +++ b/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.html @@ -20,7 +20,18 @@ -->
-
+
+ +
+ arrow_back + {{ 'actions.goBack' | i18n }} +
+
+
+
{ + const renderInvestigationDetail = async (id?: string) => { return await renderComponent(InvestigationDetailComponent, { imports: [InvestigationsModule], @@ -41,6 +43,7 @@ describe('InvestigationDetailComponent', () => { get: () => id || 'id-2', }, }, + queryParams: of({ pageNumber: 0, tabIndex: 0 }) }, }, ], @@ -58,6 +61,11 @@ describe('InvestigationDetailComponent', () => { await waitFor(() => expect(screen.getByText('pageInvestigation.subHeadline.supplierParts')).toBeInTheDocument()); }); + it('should render specific text for back button', async () => { + await renderInvestigationDetail('id-1'); + await waitFor(() => expect(screen.getByText('actions.goBack')).toBeInTheDocument()); + }); + it('should render copy data to clipboard', async () => { await renderInvestigationDetail('id-1'); await waitFor(() => expect(screen.getByText('pageInvestigation.subHeadline.supplierParts')).toBeInTheDocument()); diff --git a/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.ts b/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.ts index 918ee23f25..1fc6da59ea 100644 --- a/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.ts +++ b/frontend/src/app/modules/page/investigations/detail/investigation-detail.component.ts @@ -20,7 +20,8 @@ ********************************************************************************/ import { AfterViewInit, Component, OnDestroy, TemplateRef, ViewChild } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; +import { getRoute, INVESTIGATION_BASE_ROUTE } from '@core/known-route'; import { InvestigationDetailFacade } from '@page/investigations/core/investigation-detail.facade'; import { InvestigationHelperService } from '@page/investigations/core/investigation-helper.service'; import { InvestigationsFacade } from '@page/investigations/core/investigations.facade'; @@ -71,16 +72,21 @@ export class InvestigationDetailComponent implements AfterViewInit, OnDestroy { public notificationPartsTableConfig: TableConfig; public supplierPartsTableConfig: TableConfig; public isReceived: boolean; + private originPageNumber: number; + private originTabIndex: number; private subscription: Subscription; private selectedInvestigationTmpStore: Notification; public selectedInvestigation: Notification; + private paramSubscription: Subscription + constructor( public readonly helperService: InvestigationHelperService, + public readonly investigationDetailFacade: InvestigationDetailFacade, private readonly staticIdService: StaticIdService, - private readonly investigationDetailFacade: InvestigationDetailFacade, private readonly investigationsFacade: InvestigationsFacade, + private router: Router, private readonly route: ActivatedRoute, private readonly ctaSnackbarService: CtaSnackbarService, ) { @@ -88,6 +94,12 @@ export class InvestigationDetailComponent implements AfterViewInit, OnDestroy { this.supplierPartsDetailInformation$ = this.investigationDetailFacade.supplierPartsInformation$; this.selected$ = this.investigationDetailFacade.selected$; + + this.paramSubscription = this.route.queryParams.subscribe(params => { + this.originPageNumber = params.pageNumber; + this.originTabIndex = params?.tabIndex; + }) + } public ngAfterViewInit(): void { @@ -109,6 +121,7 @@ export class InvestigationDetailComponent implements AfterViewInit, OnDestroy { public ngOnDestroy(): void { this.subscription?.unsubscribe(); this.investigationDetailFacade.unsubscribeSubscriptions(); + this.paramSubscription?.unsubscribe(); } public onNotificationPartsSort({ sorting }: TableEventConfig): void { @@ -147,6 +160,11 @@ export class InvestigationDetailComponent implements AfterViewInit, OnDestroy { navigator.clipboard.writeText(semanticModelId).then(_ => this.ctaSnackbarService.show(text)); } + public navigateBackToInvestigations(): void { + const { link } = getRoute(INVESTIGATION_BASE_ROUTE); + this.router.navigate([`/${link}`], {queryParams: {tabIndex: this.originTabIndex, pageNumber: this.originPageNumber}}); + } + public handleConfirmActionCompletedEvent(): void { this.investigationDetailFacade.selected = { loader: true }; this.subscription?.unsubscribe(); diff --git a/frontend/src/app/modules/page/investigations/presentation/investigations.component.spec.ts b/frontend/src/app/modules/page/investigations/presentation/investigations.component.spec.ts index 173c11909c..16a313ed93 100644 --- a/frontend/src/app/modules/page/investigations/presentation/investigations.component.spec.ts +++ b/frontend/src/app/modules/page/investigations/presentation/investigations.component.spec.ts @@ -21,6 +21,7 @@ import { InvestigationsModule } from '@page/investigations/investigations.module'; import { InvestigationsComponent } from '@page/investigations/presentation/investigations.component'; +import { NotificationTabInformation } from '@shared/model/notification-tab-information'; import { InvestigationsService } from '@shared/service/investigations.service'; import { fireEvent, screen, waitFor } from '@testing-library/angular'; import { renderComponent } from '@tests/test-render.utils'; @@ -42,7 +43,8 @@ describe('InvestigationsComponent', () => { spy.and.returnValue(new Promise(null)); fireEvent.click(await waitFor(() => screen.getByTestId('table-menu-button--actions.viewDetails'))); - expect(spy).toHaveBeenCalledWith(['/investigations/id-84']); + const tabInformation: NotificationTabInformation = { tabIndex: NaN, pageNumber: undefined} + expect(spy).toHaveBeenCalledWith(['/investigations/id-84'], { queryParams: tabInformation } ); }); it('should call change pagination of received investigations', async () => { diff --git a/frontend/src/app/modules/page/investigations/presentation/investigations.component.ts b/frontend/src/app/modules/page/investigations/presentation/investigations.component.ts index 199bf0f836..bce9a430cf 100644 --- a/frontend/src/app/modules/page/investigations/presentation/investigations.component.ts +++ b/frontend/src/app/modules/page/investigations/presentation/investigations.component.ts @@ -20,11 +20,12 @@ ********************************************************************************/ import { AfterContentInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { getRoute, INVESTIGATION_BASE_ROUTE } from '@core/known-route'; import { InvestigationDetailFacade } from '@page/investigations/core/investigation-detail.facade'; import { InvestigationHelperService } from '@page/investigations/core/investigation-helper.service'; import { MenuActionConfig, TableEventConfig } from '@shared/components/table/table.model'; +import { NotificationTabInformation } from '@shared/model/notification-tab-information'; import { Notification } from '@shared/model/notification.model'; import { TranslationContext } from '@shared/model/translation-context.model'; import { AcceptNotificationModalComponent } from '@shared/modules/notification/modal/accept/accept-notification-modal.component'; @@ -33,6 +34,7 @@ import { ApproveNotificationModalComponent } from '@shared/modules/notification/ import { CancelNotificationModalComponent } from '@shared/modules/notification/modal/cancel/cancel-notification-modal.component'; import { CloseNotificationModalComponent } from '@shared/modules/notification/modal/close/close-notification-modal.component'; import { DeclineNotificationModalComponent } from '@shared/modules/notification/modal/decline/decline-notification-modal.component'; +import { Subscription } from 'rxjs'; import { InvestigationsFacade } from '../core/investigations.facade'; @Component({ @@ -53,6 +55,8 @@ export class InvestigationsComponent implements OnInit, OnDestroy, AfterContentI public menuActionsConfig: MenuActionConfig[]; + private paramSubscription: Subscription; + private pagination: TableEventConfig = { page: 0, pageSize: 50, sorting: ['createdDate' , 'desc'] }; constructor( @@ -60,12 +64,16 @@ export class InvestigationsComponent implements OnInit, OnDestroy, AfterContentI private readonly investigationsFacade: InvestigationsFacade, private readonly investigationDetailFacade: InvestigationDetailFacade, private readonly router: Router, + private readonly route: ActivatedRoute ) { this.investigationsReceived$ = this.investigationsFacade.investigationsReceived$; this.investigationsQueuedAndRequested$ = this.investigationsFacade.investigationsQueuedAndRequested$; } public ngOnInit(): void { + this.paramSubscription = this.route.queryParams.subscribe(params => { + this.pagination.page = params?.pageNumber; + }) this.investigationsFacade.setReceivedInvestigation(this.pagination.page, this.pagination.pageSize, this.pagination.sorting); this.investigationsFacade.setQueuedAndRequestedInvestigations(this.pagination.page, this.pagination.pageSize, this.pagination.sorting); } @@ -113,6 +121,7 @@ export class InvestigationsComponent implements OnInit, OnDestroy, AfterContentI public ngOnDestroy(): void { this.investigationsFacade.stopInvestigations(); + this.paramSubscription?.unsubscribe(); } public onReceivedTableConfigChanged(pagination: TableEventConfig) { @@ -128,7 +137,9 @@ export class InvestigationsComponent implements OnInit, OnDestroy, AfterContentI public openDetailPage(notification: Notification): void { this.investigationDetailFacade.selected = { data: notification }; const { link } = getRoute(INVESTIGATION_BASE_ROUTE); - this.router.navigate([`/${link}/${notification.id}`]).then(); + const tabIndex = this.route.snapshot.queryParamMap.get('tabIndex'); + const tabInformation: NotificationTabInformation = {tabIndex: parseInt(tabIndex), pageNumber: this.pagination.page} + this.router.navigate([`/${link}/${notification.id}`], { queryParams: tabInformation }); } public handleConfirmActionCompletedEvent() { diff --git a/frontend/src/app/modules/shared/model/notification-tab-information.ts b/frontend/src/app/modules/shared/model/notification-tab-information.ts new file mode 100644 index 0000000000..3fb1f8cda0 --- /dev/null +++ b/frontend/src/app/modules/shared/model/notification-tab-information.ts @@ -0,0 +1,23 @@ +/******************************************************************************** + * Copyright (c) 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 + ********************************************************************************/ + +export type NotificationTabInformation = { + tabIndex: number | null, + pageNumber?: number | null +} diff --git a/frontend/src/app/modules/shared/modules/notification/modal/accept/accept-notification-modal.component.html b/frontend/src/app/modules/shared/modules/notification/modal/accept/accept-notification-modal.component.html index b67e97565b..cc20a09582 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/accept/accept-notification-modal.component.html +++ b/frontend/src/app/modules/shared/modules/notification/modal/accept/accept-notification-modal.component.html @@ -20,9 +20,7 @@ --> -

{{ translationContext + '.modal.acceptDescription' | i18n }}

-
{{ translationContext + '.modal.acceptReasonHint' | i18n }} diff --git a/frontend/src/app/modules/shared/modules/notification/modal/accept/accept-notification-modal.component.spec.ts b/frontend/src/app/modules/shared/modules/notification/modal/accept/accept-notification-modal.component.spec.ts index 1a4d9b681f..6c1786c378 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/accept/accept-notification-modal.component.spec.ts +++ b/frontend/src/app/modules/shared/modules/notification/modal/accept/accept-notification-modal.component.spec.ts @@ -29,13 +29,11 @@ describe('AcceptNotificationModalComponent', () => { it('should create accept modal', async () => { await renderAcceptModal(NotificationStatus.ACKNOWLEDGED); const title = await waitFor(() => screen.getByText('commonInvestigation.modal.acceptTitle')); - const hint = await waitFor(() => screen.getByText('commonInvestigation.modal.acceptDescription')); const hint2 = await waitFor(() => screen.getByText('commonInvestigation.modal.acceptReasonHint')); const buttonL = await waitFor(() => screen.getByText('actions.cancel')); const buttonR = await waitFor(() => screen.getByText('actions.accept')); expect(title).toBeInTheDocument(); - expect(hint).toBeInTheDocument(); expect(hint2).toBeInTheDocument(); expect(buttonL).toBeInTheDocument(); expect(buttonR).toBeInTheDocument(); diff --git a/frontend/src/app/modules/shared/modules/notification/modal/acknowledge/acknowledge-notification-modal.component.html b/frontend/src/app/modules/shared/modules/notification/modal/acknowledge/acknowledge-notification-modal.component.html index d711c2ecda..2c315d6465 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/acknowledge/acknowledge-notification-modal.component.html +++ b/frontend/src/app/modules/shared/modules/notification/modal/acknowledge/acknowledge-notification-modal.component.html @@ -20,6 +20,5 @@ --> -

{{ translationContext + '.modal.acknowledgeDescription' | i18n }}

diff --git a/frontend/src/app/modules/shared/modules/notification/modal/acknowledge/acknowledge-notification-modal.component.spec.ts b/frontend/src/app/modules/shared/modules/notification/modal/acknowledge/acknowledge-notification-modal.component.spec.ts index 2a64e07286..25ab6bdc6f 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/acknowledge/acknowledge-notification-modal.component.spec.ts +++ b/frontend/src/app/modules/shared/modules/notification/modal/acknowledge/acknowledge-notification-modal.component.spec.ts @@ -28,12 +28,10 @@ describe('AcknowledgeNotificationModalComponent', () => { it('should create acknowledge modal', async () => { await renderAcknowledgeModal(NotificationStatus.RECEIVED); const title = await waitFor(() => screen.getByText('commonInvestigation.modal.acknowledgeTitle')); - const hint = await waitFor(() => screen.getByText('commonInvestigation.modal.acknowledgeDescription')); const buttonL = await waitFor(() => screen.getByText('actions.cancel')); const buttonR = await waitFor(() => screen.getByText('actions.acknowledge')); expect(title).toBeInTheDocument(); - expect(hint).toBeInTheDocument(); expect(buttonL).toBeInTheDocument(); expect(buttonR).toBeInTheDocument(); }); diff --git a/frontend/src/app/modules/shared/modules/notification/modal/approve/approve-notification-modal.component.html b/frontend/src/app/modules/shared/modules/notification/modal/approve/approve-notification-modal.component.html index a201e94faa..2c315d6465 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/approve/approve-notification-modal.component.html +++ b/frontend/src/app/modules/shared/modules/notification/modal/approve/approve-notification-modal.component.html @@ -20,6 +20,5 @@ --> -

{{ translationContext + '.modal.approvalDescription' | i18n }}

diff --git a/frontend/src/app/modules/shared/modules/notification/modal/approve/approve-notification-modal.component.spec.ts b/frontend/src/app/modules/shared/modules/notification/modal/approve/approve-notification-modal.component.spec.ts index 17634849bf..5cc0d6e3e3 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/approve/approve-notification-modal.component.spec.ts +++ b/frontend/src/app/modules/shared/modules/notification/modal/approve/approve-notification-modal.component.spec.ts @@ -28,12 +28,10 @@ describe('ApproveNotificationModalComponent', () => { it('should create approve modal', async () => { await renderApproveModal(NotificationStatus.CREATED); const title = await waitFor(() => screen.getByText('commonInvestigation.modal.approvalTitle')); - const hint = await waitFor(() => screen.getByText('commonInvestigation.modal.approvalDescription')); const buttonL = await waitFor(() => screen.getByText('actions.cancel')); const buttonR = await waitFor(() => screen.getByText('actions.confirm')); expect(title).toBeInTheDocument(); - expect(hint).toBeInTheDocument(); expect(buttonL).toBeInTheDocument(); expect(buttonR).toBeInTheDocument(); }); diff --git a/frontend/src/app/modules/shared/modules/notification/modal/cancel/cancel-notification-modal.component.html b/frontend/src/app/modules/shared/modules/notification/modal/cancel/cancel-notification-modal.component.html index 2ce788d8b1..7eb45b0aef 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/cancel/cancel-notification-modal.component.html +++ b/frontend/src/app/modules/shared/modules/notification/modal/cancel/cancel-notification-modal.component.html @@ -20,7 +20,6 @@ --> -

{{ translationContext + '.modal.cancellationDescription' | i18n }}

diff --git a/frontend/src/app/modules/shared/modules/notification/modal/cancel/cancel-notification-modal.component.spec.ts b/frontend/src/app/modules/shared/modules/notification/modal/cancel/cancel-notification-modal.component.spec.ts index 6498ad5486..8184440405 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/cancel/cancel-notification-modal.component.spec.ts +++ b/frontend/src/app/modules/shared/modules/notification/modal/cancel/cancel-notification-modal.component.spec.ts @@ -28,13 +28,11 @@ describe('CancelNotificationModalComponent', () => { it('should create cancel modal', async () => { await renderCancelModal(NotificationStatus.CREATED); const title = await waitFor(() => screen.getByText('commonInvestigation.modal.cancellationTitle')); - const hint = await waitFor(() => screen.getByText('commonInvestigation.modal.cancellationDescription')); const hint2 = await waitFor(() => screen.getByText('commonInvestigation.modal.cancellationHint')); const buttonL = await waitFor(() => screen.getByText('actions.cancel')); const buttonR = await waitFor(() => screen.getByText('actions.cancellationConfirm')); expect(title).toBeInTheDocument(); - expect(hint).toBeInTheDocument(); expect(hint2).toBeInTheDocument(); expect(buttonL).toBeInTheDocument(); expect(buttonR).toBeInTheDocument(); diff --git a/frontend/src/app/modules/shared/modules/notification/modal/close/close-notification-modal.component.html b/frontend/src/app/modules/shared/modules/notification/modal/close/close-notification-modal.component.html index ebf91f8bc9..6b53b86df4 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/close/close-notification-modal.component.html +++ b/frontend/src/app/modules/shared/modules/notification/modal/close/close-notification-modal.component.html @@ -20,7 +20,6 @@ --> -

{{ translationContext + '.modal.closeDescription' | i18n }}

diff --git a/frontend/src/app/modules/shared/modules/notification/modal/close/close-notification-modal.component.spec.ts b/frontend/src/app/modules/shared/modules/notification/modal/close/close-notification-modal.component.spec.ts index b64595dc21..8a7af8d4db 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/close/close-notification-modal.component.spec.ts +++ b/frontend/src/app/modules/shared/modules/notification/modal/close/close-notification-modal.component.spec.ts @@ -29,13 +29,11 @@ describe('CloseNotificationModalComponent', () => { it('should create close modal', async () => { await renderCloseModal(NotificationStatus.SENT); const title = await waitFor(() => screen.getByText('commonInvestigation.modal.closeTitle')); - const hint = await waitFor(() => screen.getByText('commonInvestigation.modal.closeDescription')); const hint2 = await waitFor(() => screen.getByText('commonInvestigation.modal.closeReasonHint')); const buttonL = await waitFor(() => screen.getByText('actions.cancel')); const buttonR = await waitFor(() => screen.getByText('actions.close')); expect(title).toBeInTheDocument(); - expect(hint).toBeInTheDocument(); expect(hint2).toBeInTheDocument(); expect(buttonL).toBeInTheDocument(); expect(buttonR).toBeInTheDocument(); diff --git a/frontend/src/app/modules/shared/modules/notification/modal/decline/decline-notification-modal.component.html b/frontend/src/app/modules/shared/modules/notification/modal/decline/decline-notification-modal.component.html index 27e22470e2..64e86996c0 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/decline/decline-notification-modal.component.html +++ b/frontend/src/app/modules/shared/modules/notification/modal/decline/decline-notification-modal.component.html @@ -20,7 +20,6 @@ --> -

{{ translationContext + '.modal.declineDescription' | i18n }}

diff --git a/frontend/src/app/modules/shared/modules/notification/modal/decline/decline-notification-modal.component.spec.ts b/frontend/src/app/modules/shared/modules/notification/modal/decline/decline-notification-modal.component.spec.ts index 489d8b06fd..b3f28ed69c 100644 --- a/frontend/src/app/modules/shared/modules/notification/modal/decline/decline-notification-modal.component.spec.ts +++ b/frontend/src/app/modules/shared/modules/notification/modal/decline/decline-notification-modal.component.spec.ts @@ -28,13 +28,11 @@ describe('DeclineNotificationModalComponent', () => { it('should create close modal', async () => { await renderDeclineModal(NotificationStatus.ACKNOWLEDGED); const title = await waitFor(() => screen.getByText('commonInvestigation.modal.declineTitle')); - const hint = await waitFor(() => screen.getByText('commonInvestigation.modal.declineDescription')); const hint2 = await waitFor(() => screen.getByText('commonInvestigation.modal.declineReasonHint')); const buttonL = await waitFor(() => screen.getByText('actions.cancel')); const buttonR = await waitFor(() => screen.getByText('actions.decline')); expect(title).toBeInTheDocument(); - expect(hint).toBeInTheDocument(); expect(hint2).toBeInTheDocument(); expect(buttonL).toBeInTheDocument(); expect(buttonR).toBeInTheDocument(); diff --git a/frontend/src/assets/locales/de/common.json b/frontend/src/assets/locales/de/common.json index bf024962ac..24b05d682e 100644 --- a/frontend/src/assets/locales/de/common.json +++ b/frontend/src/assets/locales/de/common.json @@ -47,7 +47,8 @@ "save": "Speicher", "remove": "Entfernen", "delete": "Löschen", - "goToQueue": "Zur Warteschlange" + "goToQueue": "Zur Warteschlange", + "goBack": "Zurück" }, "table": { "noResultFound": "KEINE ERGEBNISSE GEFUNDEN.", @@ -174,20 +175,14 @@ }, "modal": { "acceptTitle": "Annehmen der Untersuchung", - "acceptDescription": "Sind Sie sicher, dass Sie diese Untersuchung annehmen wollen?", "acceptReasonHint": "Geben Sie den Grund für die Annahme dieser Untersuchung ein.", "acknowledgeTitle": "Bestätigung der Untersuchung", - "acknowledgeDescription": "Sind Sie sicher, dass Sie diese Untersuchung bestätigen wollen?", "approvalTitle": "Genehmigung der Untersuchung", - "approvalDescription": "Sind Sie sicher, dass Sie diese Untersuchung genehmigen wollen?", "closeTitle": "Schließen der Untersuchung", - "closeDescription": "Sind Sie sicher, dass Sie diese Untersuchung schließen wollen?", "closeReasonHint": "Geben Sie den Grund für das Schließen ein.", "cancellationTitle": "Abbruch der Untersuchung", - "cancellationDescription": "Sind Sie sicher, dass Sie diese Untersuchung abbrechen wollen?", "cancellationHint": "Geben Sie die ID der Untersuchung ein, um Ihre Abbruchanfrage zu bestätigen.", "declineTitle": "Ablehnung der Untersuchung", - "declineDescription": "Sind Sie sicher, dass Sie diese Untersuchung ablehnen wollen?", "declineReasonHint": "Geben Sie den Grund für die Ablehnung dieser Untersuchung ein.", "successfullyAccepted": "Untersuchung wurde erfolgreich angenommen.", "successfullyAcknowledged": "Untersuchung wurde erfolgreich bestätigt", @@ -221,20 +216,14 @@ }, "modal": { "acceptTitle": "Annehmen der Qualitätswarnung", - "acceptDescription": "Sind Sie sicher, dass Sie diese Qualitätswarnung annehmen wollen?", "acceptReasonHint": "Geben Sie den Grund für die Annahme dieser Qualitätswarnung ein.", "acknowledgeTitle": "Bestätigung der Qualitätswarnung", - "acknowledgeDescription": "Sind Sie sicher, dass Sie diese Qualitätswarnung bestätigen wollen?", "approvalTitle": "Genehmigung der Qualitätswarnung", - "approvalDescription": "Sind Sie sicher, dass Sie diese Qualitätswarnung genehmigen wollen?", "closeTitle": "Schließen der Qualitätswarnung", - "closeDescription": "Sind Sie sicher, dass Sie diese Qualitätswarnung schließen wollen?", "closeReasonHint": "Geben Sie den Grund für das Schließen ein.", "cancellationTitle": "Abbruch der Qualitätswarnung", - "cancellationDescription": "Sind Sie sicher, dass Sie diese Qualitätswarnung abbrechen wollen?", "cancellationHint": "Geben Sie die ID der Qualitätswarnung ein, um Ihre Abbruchanfrage zu bestätigen.", "declineTitle": "Ablehnung der Qualitätswarnung", - "declineDescription": "Sind Sie sicher, dass Sie diese Qualitätswarnung ablehnen wollen?", "declineReasonHint": "Geben Sie den Grund für die Ablehnung dieser Qualitätswarnung ein.", "successfullyAccepted": "Qualitätswarnung wurde erfolgreich angenommen.", "successfullyAcknowledged": "Qualitätswarnung wurde erfolgreich bestätigt", diff --git a/frontend/src/assets/locales/en/common.json b/frontend/src/assets/locales/en/common.json index 3aca54c7bc..fc8ed6b3e7 100644 --- a/frontend/src/assets/locales/en/common.json +++ b/frontend/src/assets/locales/en/common.json @@ -47,7 +47,8 @@ "save": "Save", "remove": "Remove", "delete": "Delete", - "goToQueue": "Go to Queue" + "goToQueue": "Go to Queue", + "goBack": "Back" }, "table": { "noResultFound": "NO RESULTS FOUND.", @@ -177,20 +178,14 @@ }, "modal": { "acceptTitle": "Accept of investigation", - "acceptDescription": "Are you sure you want to accept this investigation?", "acceptReasonHint": "Enter the reason for accepting this investigation.", "acknowledgeTitle": "Acknowledgment of investigation", - "acknowledgeDescription": "Are you sure you want to acknowledge this investigation?", "approvalTitle": "Approval of investigation", - "approvalDescription": "Are you sure you want to approve this investigation?", "closeTitle": "Close of investigation", - "closeDescription": "Are you sure you want to close this investigation?", "closeReasonHint": "Enter the reason for close action.", "cancellationTitle": "Cancellation of investigation", - "cancellationDescription": "Are you sure you want to cancel this investigation?", "cancellationHint": "Enter the ID of the investigation to confirm your cancellation.", "declineTitle": "Decline of investigation", - "declineDescription": "Are you sure you want to decline this investigation?", "declineReasonHint": "Enter the reason for declining this investigation.", "successfullyAccepted": "Investigation was accepted successfully.", "successfullyAcknowledged": "Investigation was acknowledged successfully.", @@ -224,20 +219,14 @@ }, "modal": { "acceptTitle": "Accept of alert", - "acceptDescription": "Are you sure you want to accept this alert?", "acceptReasonHint": "Enter the reason for accepting this alert.", "acknowledgeTitle": "Acknowledgment of alert", - "acknowledgeDescription": "Are you sure you want to acknowledge this alert?", "approvalTitle": "Approval of alert", - "approvalDescription": "Are you sure you want to approve this alert?", "closeTitle": "Close of alert", - "closeDescription": "Are you sure you want to close this alert?", "closeReasonHint": "Enter the reason for close action.", "cancellationTitle": "Cancellation of alert", - "cancellationDescription": "Are you sure you want to cancel this alert?", "cancellationHint": "Enter the ID of the alert to confirm your cancellation.", "declineTitle": "Decline of alert", - "declineDescription": "Are you sure you want to decline this alert?", "declineReasonHint": "Enter the reason for declining this alert.", "successfullyAccepted": "Alert was accepted successfully.", "successfullyAcknowledged": "Alert was acknowledged successfully.", diff --git a/frontend/src/environments/environment.authE2eA.ts b/frontend/src/environments/environment.authE2eA.ts new file mode 100644 index 0000000000..9f1d85def9 --- /dev/null +++ b/frontend/src/environments/environment.authE2eA.ts @@ -0,0 +1,30 @@ +/******************************************************************************** + * Copyright (c) 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 + ********************************************************************************/ + +import { _environment } from './_environment.base'; + +export const environment = { + ..._environment, + mockService: false, + authDisabled: false, + apiUrl: 'https://traceability-e2e-a.dev.demo.catena-x.net/api', + keycloakUrl: 'https://centralidp.dev.demo.catena-x.net/auth', + clientId: 'Cl17-CX-Part', + api: '', +}; diff --git a/lombok.config b/lombok.config index df07d6c4cf..f75114f3d1 100644 --- a/lombok.config +++ b/lombok.config @@ -1,2 +1,6 @@ # Add @Generated annotation to generated code, so that it is skipped by JaCoCo lombok.addLombokGeneratedAnnotation = true +# Copy the Qualifier annotation from the instance variables to the constructor +# see https://github.com/rzwitserloot/lombok/issues/745 +lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier +lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Value diff --git a/pom.xml b/pom.xml index e9e53d1c3b..e76b41ad38 100644 --- a/pom.xml +++ b/pom.xml @@ -92,8 +92,10 @@ eclipse-tractusx_traceability-foss-backend https://sonarcloud.io - org/eclipse/tractusx/traceability/TraceabilityApplication.java, - org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/HttpCallService.java, + tx-backend/src/main/java/org/eclipse/tractusx/traceability/TraceabilityApplication.java, + tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/HttpCallService.java, + tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/InvestigationsEDCFacade.java, + tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcService.java diff --git a/tx-backend/pom.xml b/tx-backend/pom.xml index 94f6a95291..c53b795a15 100644 --- a/tx-backend/pom.xml +++ b/tx-backend/pom.xml @@ -47,6 +47,46 @@ 1.5 + + + org.eclipse.edc + connector-core + 0.1.0 + + + runtime-metamodel + org.eclipse.edc + + + + + org.eclipse.edc + dsp + 0.1.0 + + + runtime-metamodel + org.eclipse.edc + + + + + org.eclipse.edc + json-ld + 0.1.0 + + + runtime-metamodel + org.eclipse.edc + + + + + runtime-metamodel + org.eclipse.edc + 0.1.0 + + org.yaml snakeyaml diff --git a/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/assets/EDCReceiverController.java b/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/assets/EDCReceiverController.java deleted file mode 100644 index 5b76ba7a8a..0000000000 --- a/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/assets/EDCReceiverController.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.assets; - -import com.auth0.jwt.JWT; -import com.auth0.jwt.algorithms.Algorithm; -import io.swagger.v3.oas.annotations.Hidden; -import lombok.extern.slf4j.Slf4j; -import org.apache.groovy.util.Maps; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.cache.EndpointDataReference; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.cache.InMemoryEndpointDataReferenceCache; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.catalog.Catalog; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.model.EDCNotification; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.notification.ContractNegotiationDto; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.notification.NegotiationInitiateRequestDto; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.notification.TransferId; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.offer.ContractOffer; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transfer.TransferRequestDto; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.sql.Date; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.List; - -@Slf4j -@RestController -@Hidden -@RequestMapping("/edc/") -public class EDCReceiverController { - - private final TestRestTemplate restTemplate; - - private final InMemoryEndpointDataReferenceCache endpointDataReferenceCache; - - @Value("${server.port}") - private int port; - - public EDCReceiverController(TestRestTemplate restTemplate, InMemoryEndpointDataReferenceCache endpointDataReferenceCache) { - this.restTemplate = restTemplate; - this.endpointDataReferenceCache = endpointDataReferenceCache; - } - - @GetMapping("/api/v1/management/catalog") - public Catalog getDataCatalog(@RequestParam String providerUrl) { - log.info("Returning data catalog for provider {}", providerUrl); - return Catalog.Builder.newInstance() - .id("contract-id") - .contractOffers(List.of(ContractOffer.Builder.newInstance() - .id("contract-id") - .asset(Asset.Builder.newInstance() - .id("asset-id") - .property(Asset.ASSET_KEY_NOTIFICATION_TYPE, Asset.ASSET_VALUE_QUALITY_INVESTIGATION) - .build() - ).policy(Policy.Builder.newInstance() - .build() - ).build()) - ).build(); - } - - @PostMapping("/api/v1/management/contractnegotiations") - public TransferId contractNegotiations(@RequestBody NegotiationInitiateRequestDto request) { - log.info("Initializing contract negotiations"); - return TransferId.Builder.newInstance() - .id("transfer-id-1") - .build(); - } - - @PostMapping("/api/v1/management/transferprocess") - public TransferId transferProcess(@RequestBody TransferRequestDto transferRequest) { - log.info("Processing transfer"); - return TransferId.Builder.newInstance() - .id("transfer-id-2") - .build(); - } - - @PostMapping("/receive-notification") - public void receiveNotification(@RequestBody EDCNotification notification) { - log.info("Notification received"); - } - - @PostMapping("/callback") - public void receiveCallback(@RequestBody EndpointDataReference dataReference) { - log.info("Callback received"); - } - - @GetMapping("/api/v1/management/contractnegotiations/{transferId}") - public ContractNegotiationDto getContractNegotiations(@PathVariable String transferId) { - log.info("Returning contract negotiations"); - String contractAgreementId = "contract-agreement-id"; - - endpointDataReferenceCache.storeAgreementId(contractAgreementId); - - restTemplate.postForEntity("/callback/endpoint-data-reference", - EndpointDataReference.Builder.newInstance() - .authCode(JWT.create() - .withExpiresAt(Date.from(Instant.now().plus(1, ChronoUnit.DAYS))) - .sign(Algorithm.HMAC256("test-token"))) - .authKey("auth-key") - .endpoint("http://localhost:" + port + "/api/edc/receive-notification") - .properties(Maps.of("cid", contractAgreementId)) - .build(), - Void.class - ); - - return ContractNegotiationDto.Builder.newInstance() - .contractAgreementId(contractAgreementId) - .state("CONFIRMED") - .build(); - } - -} diff --git a/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/common/support/EdcSupport.groovy b/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/common/support/EdcSupport.groovy index e07516418d..614bbc4319 100644 --- a/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/common/support/EdcSupport.groovy +++ b/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/common/support/EdcSupport.groovy @@ -27,11 +27,7 @@ import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp import static com.xebialabs.restito.builder.verify.VerifyHttp.verifyHttp import static com.xebialabs.restito.semantics.Action.noContent import static com.xebialabs.restito.semantics.Action.status -import static com.xebialabs.restito.semantics.Condition.composite -import static com.xebialabs.restito.semantics.Condition.method -import static com.xebialabs.restito.semantics.Condition.post -import static com.xebialabs.restito.semantics.Condition.startsWithUri -import static com.xebialabs.restito.semantics.Condition.withHeader +import static com.xebialabs.restito.semantics.Condition.* import static org.glassfish.grizzly.http.Method.DELETE trait EdcSupport implements RestitoProvider { @@ -40,47 +36,47 @@ trait EdcSupport implements RestitoProvider { void edcWillCreateNotificationAsset() { whenHttp(stubServer()).match( - post("/api/v1/management/assets"), - EDC_API_KEY_HEADER - ).then( + post("/management/v2/assets"), + EDC_API_KEY_HEADER + ).then( status(HttpStatus.OK_200) ) } void edcWillRemoveNotificationAsset() { whenHttp(stubServer()).match( - method(DELETE), - startsWithUri("/api/v1/management/assets/"), - EDC_API_KEY_HEADER - ).then( + method(DELETE), + startsWithUri("/management/v2/assets/"), + EDC_API_KEY_HEADER + ).then( noContent() ) } void edcWillFailToCreateNotificationAsset() { whenHttp(stubServer()).match( - post("/api/v1/management/assets"), - EDC_API_KEY_HEADER - ).then( + post("/management/v2/assets"), + EDC_API_KEY_HEADER + ).then( status(HttpStatus.INTERNAL_SERVER_ERROR_500) ) } void edcNotificationAssetAlreadyExist() { whenHttp(stubServer()).match( - post("/api/v1/management/assets"), - EDC_API_KEY_HEADER - ).then( + post("/management/v2/assets"), + EDC_API_KEY_HEADER + ).then( status(HttpStatus.CONFLICT_409), - jsonResponseFromFile("./stubs/edc/post/api/v1/management/assets/response_409.json") + jsonResponseFromFile("./stubs/edc/post/management/v2/assets/response_409.json") ) } void edcWillCreatePolicyDefinition() { whenHttp(stubServer()).match( - post("/api/v1/management/policydefinitions"), - EDC_API_KEY_HEADER - ).then( + post("/management/v2/policydefinitions"), + EDC_API_KEY_HEADER + ).then( status(HttpStatus.OK_200) ) } @@ -89,7 +85,7 @@ trait EdcSupport implements RestitoProvider { whenHttp(stubServer()).match( composite( method(DELETE), - startsWithUri("/api/v1/management/policydefinitions/") + startsWithUri("/management/v2/policydefinitions/") ), EDC_API_KEY_HEADER ).then( @@ -99,67 +95,67 @@ trait EdcSupport implements RestitoProvider { void edcWillFailToCreatePolicyDefinition() { whenHttp(stubServer()).match( - post("/api/v1/management/policydefinitions"), - EDC_API_KEY_HEADER - ).then( + post("/management/v2/policydefinitions"), + EDC_API_KEY_HEADER + ).then( status(HttpStatus.INTERNAL_SERVER_ERROR_500) ) } void edcWillCreateContractDefinition() { whenHttp(stubServer()).match( - post("/api/v1/management/contractdefinitions"), - EDC_API_KEY_HEADER - ).then( + post("/management/v2/contractdefinitions"), + EDC_API_KEY_HEADER + ).then( status(HttpStatus.OK_200) ) } void edcWillFailToCreateContractDefinition() { whenHttp(stubServer()).match( - post("/api/v1/management/contractdefinitions"), - EDC_API_KEY_HEADER - ).then( + post("/management/v2/contractdefinitions"), + EDC_API_KEY_HEADER + ).then( status(HttpStatus.INTERNAL_SERVER_ERROR_500) ) } void verifyCreateNotificationAssetEndpointCalledTimes(int times) { verifyHttp(stubServer()).times(times, - post("/api/v1/management/assets") + post("/management/v2/assets") ) } void verifyDeleteNotificationAssetEndpointCalledTimes(int times) { verifyHttp(stubServer()).times(times, method(DELETE), - startsWithUri("/api/v1/management/assets") + startsWithUri("/management/v2/assets") ) } void verifyCreatePolicyDefinitionEndpointCalledTimes(int times) { verifyHttp(stubServer()).times(times, - post("/api/v1/management/policydefinitions") + post("/management/v2/policydefinitions") ) } void verifyDeletePolicyDefinitionEndpointCalledTimes(int times) { verifyHttp(stubServer()).times(times, method(DELETE), - startsWithUri("/api/v1/management/policydefinitions") + startsWithUri("/management/v2/policydefinitions") ) } void verifyCreateContractDefinitionEndpointCalledTimes(int times) { verifyHttp(stubServer()).times(times, - post("/api/v1/management/contractdefinitions") + post("/management/v2/contractdefinitions") ) } void verifyDeleteContractDefinitionEndpointCalledTimes(int times) { verifyHttp(stubServer()).times(times, method(DELETE), - startsWithUri("/api/v1/management/contractdefinitions") + startsWithUri("/management/v2/contractdefinitions") ) } } diff --git a/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcCallbackControllerIT.groovy b/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcCallbackControllerIT.groovy index f3beaaa377..c1fda6a42e 100644 --- a/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcCallbackControllerIT.groovy +++ b/tx-backend/src/integration/groovy/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcCallbackControllerIT.groovy @@ -53,14 +53,14 @@ class EdcCallbackControllerIT extends IntegrationSpecification { .body( asJson( [ - id: "urn:uuid:d387fa8e-603c-42bd-98c3-4d87fef8d2bb", - endpoint: "endpoint", - authKey: "authKey", - authCode: "authCode", - properties: [ - "cid": contractAgreementId - ] - ] + id : "urn:uuid:d387fa8e-603c-42bd-98c3-4d87fef8d2bb", + endpoint : "endpoint", + authKey : "authKey", + authCode : "authCode", + properties: [ + "https://w3id.org/edc/v0.0.1/ns/cid": contractAgreementId + ] + ] ) ) .header(jwtAuthorization(ADMIN)) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/request/PartChainIdentificationKey.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/request/PartChainIdentificationKey.java new file mode 100644 index 0000000000..0a2cc112c2 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/request/PartChainIdentificationKey.java @@ -0,0 +1,22 @@ +/******************************************************************************** + * Copyright (c) 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.traceability.assets.infrastructure.base.irs.model.request; + +public record PartChainIdentificationKey(String globalAssetId, String bpn) { +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/request/RegisterJobRequest.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/request/RegisterJobRequest.java index b76d849ccc..168e71d515 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/request/RegisterJobRequest.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/request/RegisterJobRequest.java @@ -27,7 +27,7 @@ public record RegisterJobRequest( List aspects, - String globalAssetId, + PartChainIdentificationKey key, boolean collectAspects, BomLifecycle bomLifecycle, boolean lookupBPNs, @@ -35,7 +35,7 @@ public record RegisterJobRequest( Direction direction ) { public static RegisterJobRequest buildJobRequest(String globalAssetId, Direction direction, List aspects, BomLifecycle bomLifecycle) { - return new RegisterJobRequest(aspects, globalAssetId, true, bomLifecycle, true, DEFAULT_DEPTH, direction); + return new RegisterJobRequest(aspects, new PartChainIdentificationKey(globalAssetId, null), true, bomLifecycle, true, DEFAULT_DEPTH, direction); } public static final int DEFAULT_DEPTH = 2; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationProfiles.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationProfiles.java index e152198d49..ec84ba53c9 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationProfiles.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationProfiles.java @@ -31,6 +31,7 @@ public class ApplicationProfiles { public static final String TESTS = "integration"; public static final String NOT_TESTS = "!" + TESTS; public static final String DEV = "dev"; + public static final String TEST = "test"; public static final String INT = "int"; public static final String INT_A = "int-a"; public static final String INT_B = "int-b"; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/FeatureFlags.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/FeatureFlags.java index 10bfa3076f..679016f532 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/FeatureFlags.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/FeatureFlags.java @@ -25,6 +25,7 @@ public class FeatureFlags { public static final String NOTIFICATIONS_ENABLED_PROFILES = ApplicationProfiles.LOCAL + " | " + ApplicationProfiles.TESTS + " | " + ApplicationProfiles.DEV + " | " + + ApplicationProfiles.TEST + " | " + ApplicationProfiles.INT + " | " + ApplicationProfiles.E2E_A + " | " + ApplicationProfiles.E2E_B + " | " + diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcCallbackController.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcCallbackController.java index 82793d1011..c4e3953e03 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcCallbackController.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcCallbackController.java @@ -21,12 +21,12 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox; import io.swagger.v3.oas.annotations.Hidden; +import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.traceability.common.config.FeatureFlags; import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.cache.EndpointDataReference; import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.cache.InMemoryEndpointDataReferenceCache; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.configuration.JsonLdConfiguration; import org.eclipse.tractusx.traceability.infrastructure.edc.properties.EdcProperties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Profile; import org.springframework.http.ResponseEntity; @@ -36,47 +36,46 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; +@Slf4j @Profile(FeatureFlags.NOTIFICATIONS_ENABLED_PROFILES) @RestController @Hidden @RequestMapping("/callback/endpoint-data-reference") public class EdcCallbackController { - private static final Logger log = LoggerFactory.getLogger(EdcCallbackController.class); + private final InMemoryEndpointDataReferenceCache endpointDataReferenceCache; - private final InMemoryEndpointDataReferenceCache endpointDataReferenceCache; + private final RestTemplate restTemplate; - private final RestTemplate restTemplate; + private final EdcProperties edcProperties; - private final EdcProperties edcProperties; + public EdcCallbackController(InMemoryEndpointDataReferenceCache endpointDataReferenceCache, RestTemplateBuilder restTemplateBuilder, EdcProperties edcProperties) { + this.endpointDataReferenceCache = endpointDataReferenceCache; + this.restTemplate = restTemplateBuilder.build(); + this.edcProperties = edcProperties; + } - public EdcCallbackController(InMemoryEndpointDataReferenceCache endpointDataReferenceCache, RestTemplateBuilder restTemplateBuilder, EdcProperties edcProperties) { - this.endpointDataReferenceCache = endpointDataReferenceCache; - this.restTemplate = restTemplateBuilder.build(); - this.edcProperties = edcProperties; - } + @PostMapping + public void receiveEdcCallback(@RequestBody EndpointDataReference dataReference) { + final var contractAgreementId = dataReference.getProperties().get(JsonLdConfiguration.NAMESPACE_EDC_CID); + log.info("Received EDC callback for contract: {}", contractAgreementId); - @PostMapping - public void receiveEdcCallback(@RequestBody EndpointDataReference dataReference) { - String contractAgreementId = dataReference.getProperties().get("cid"); - log.info("Received EDC callback for contract: {}", contractAgreementId); + if (endpointDataReferenceCache.containsAgreementId(contractAgreementId)) { + log.info("Contract {} found! Processing...", contractAgreementId); + endpointDataReferenceCache.put(contractAgreementId, dataReference); + } else { + log.info("Contract {} not found, forwarding message...", contractAgreementId); + callOtherServices(dataReference); + } + } - if (endpointDataReferenceCache.containsAgreementId(contractAgreementId)) { - log.info("Contract {} found! Processing...", contractAgreementId); - endpointDataReferenceCache.put(contractAgreementId, dataReference); - } else { - log.info("Contract {} not found, forwarding message...", contractAgreementId); - callOtherServices(dataReference); - } - } + private void callOtherServices(EndpointDataReference dataReference) { + edcProperties.getCallbackUrls().forEach(callbackUrl -> { + log.info("Calling callback endpoint: {}", callbackUrl); + ResponseEntity response = restTemplate.postForEntity(callbackUrl, dataReference, String.class); - private void callOtherServices(EndpointDataReference dataReference) { - edcProperties.getCallbackUrls().forEach(callbackUrl -> { - log.info("Calling callback endpoint: {}", callbackUrl); - ResponseEntity response = restTemplate.postForEntity(callbackUrl, dataReference, String.class); - - log.info("Callback response: HTTP {}", response.getStatusCode()); - log.debug("Body: {}", response.getBody()); - }); - } + log.info("Callback response: HTTP {}", response.getStatusCode()); + log.debug("Body: {}", response.getBody()); + }); + } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcService.java index bfc5e3db7a..6d51f7eeae 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcService.java @@ -20,94 +20,87 @@ ********************************************************************************/ package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import okhttp3.MediaType; import okhttp3.Request; import okhttp3.RequestBody; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.catalog.Catalog; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.notification.ContractNegotiationDto; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.notification.ContractOfferDescription; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.notification.NegotiationInitiateRequestDto; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.notification.TransferId; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.offer.ContractOffer; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transfer.DataAddress; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transfer.TransferRequestDto; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transfer.TransferType; +import org.eclipse.edc.catalog.spi.Catalog; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.catalog.CatalogItem; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.jsontransformer.EdcTransformer; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractOfferDescription; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.NegotiationRequest; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.NegotiationResponse; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.Response; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transferprocess.TransferProcessRequest; import org.eclipse.tractusx.traceability.infrastructure.edc.properties.EdcProperties; -import org.eclipse.tractusx.traceability.qualitynotification.domain.model.QualityNotificationMessage; import org.springframework.stereotype.Component; import java.io.IOException; import java.util.Map; -import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transferprocess.TransferProcessRequest.DEFAULT_PROTOCOL; + @Slf4j @Component @RequiredArgsConstructor public class EdcService { public static final MediaType JSON = MediaType.get("application/json"); + private static final String FINALIZED_STATUS = "FINALIZED"; private final HttpCallService httpCallService; - private final ObjectMapper objectMapper; private final EdcProperties edcProperties; + private final EdcTransformer edcTransformer; /** * Rest call to get all contract offer and filter notification type contract */ - public Optional findNotificationContractOffer( + public Catalog getCatalog( String consumerEdcDataManagementUrl, String providerConnectorControlPlaneIDSUrl, - Map header, - QualityNotificationMessage qualityNotificationMessage + Map header ) throws IOException { - Catalog catalog = httpCallService.getCatalogFromProvider(consumerEdcDataManagementUrl, providerConnectorControlPlaneIDSUrl, header); - if (catalog.getContractOffers().isEmpty()) { + Catalog catalog = httpCallService.getCatalogForNotification(consumerEdcDataManagementUrl, providerConnectorControlPlaneIDSUrl, header); + + if (catalog.getDatasets().isEmpty()) { log.error("No contract found"); throw new BadRequestException("Provider has no contract offers for us. Catalog is empty."); } - log.info(":::: Find Notification contract method[findNotificationContractOffer] total catalog ::{}", catalog.getContractOffers().size()); - return catalog.getContractOffers().stream() - .filter(it -> it.getAsset().isQualityNotificationOffer(qualityNotificationMessage)) - .filter(this::hasTracePolicy) - .findAny(); + return catalog; } - private boolean hasTracePolicy(ContractOffer contractOffer) { - return contractOffer.getPolicy() != null && contractOffer.getPolicy().hasTracePolicy(); - } /** * Prepare for contract negotiation. it will wait for while till API return agreementId */ - public String initializeContractNegotiation(String providerConnectorUrl, String assetId, String offerId, Policy policy, String consumerEdcUrl, + public String initializeContractNegotiation(String providerConnectorUrl, CatalogItem catalogItem, String consumerEdcUrl, Map header) throws InterruptedException, IOException { - // Initiate negotiation - ContractOfferDescription contractOfferDescription = new ContractOfferDescription(offerId, assetId, null, policy); - NegotiationInitiateRequestDto contractNegotiationRequest = NegotiationInitiateRequestDto.Builder.newInstance() - .offerId(contractOfferDescription).connectorId("provider").connectorAddress(providerConnectorUrl + edcProperties.getIdsPath()) - .protocol("ids-multipart").build(); - log.info(":::: Start Contract Negotiation method[initializeContractNegotiation] offerId :{}, assetId:{}", offerId, assetId); + final NegotiationRequest negotiationRequest = createNegotiationRequestFromCatalogItem(providerConnectorUrl + edcProperties.getIdsPath(), + catalogItem); + + log.info(":::: Start Contract Negotiation method[initializeContractNegotiation] offerId :{}, assetId:{}", negotiationRequest.getOffer().getOfferId(), negotiationRequest.getOffer().getAssetId()); - String negotiationId = initiateNegotiation(contractNegotiationRequest, consumerEdcUrl, header); - ContractNegotiationDto negotiation = null; + String negotiationId = initiateNegotiation(negotiationRequest, consumerEdcUrl, header); + NegotiationResponse negotiation = null; // Check negotiation state - while (negotiation == null || !negotiation.getState().equals("CONFIRMED")) { + while (negotiation == null || negotiation.getState() == null || !negotiation.getState().equals(FINALIZED_STATUS)) { log.info(":::: waiting for contract to get confirmed"); + if (negotiation != null) { + log.info("Negotation state {}", negotiation.getState()); + } + ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - ScheduledFuture scheduledFuture = + ScheduledFuture scheduledFuture = scheduler.schedule(() -> { var url = consumerEdcUrl + edcProperties.getNegotiationPath() + "/" + negotiationId; var request = new Request.Builder().url(url); @@ -115,7 +108,7 @@ public String initializeContractNegotiation(String providerConnectorUrl, String log.info(":::: Start call for contract agreement method [initializeContractNegotiation] URL :{}", url); - return (ContractNegotiationDto) httpCallService.sendRequest(request.build(), ContractNegotiationDto.class); + return httpCallService.sendNegotiationRequest(request.build()); }, 1000, TimeUnit.MILLISECONDS); try { negotiation = scheduledFuture.get(); @@ -132,40 +125,57 @@ public String initializeContractNegotiation(String providerConnectorUrl, String } + private NegotiationRequest createNegotiationRequestFromCatalogItem(final String providerConnectorUrl, + final CatalogItem catalogItem) { + final var contractOfferDescription = ContractOfferDescription.builder() + .offerId(catalogItem.getOfferId()) + .assetId(catalogItem.getPolicy().getTarget()) + .policy(catalogItem.getPolicy()) + .build(); + return NegotiationRequest.builder() + .connectorId(catalogItem.getConnectorId()) + .connectorAddress(providerConnectorUrl) + .protocol(DEFAULT_PROTOCOL) + .offer(contractOfferDescription) + .build(); + } + /** * Rest call for Contract negotiation and return agreementId. */ - private String initiateNegotiation(NegotiationInitiateRequestDto contractOfferRequest, String consumerEdcDataManagementUrl, + private String initiateNegotiation(NegotiationRequest negotiationRequest, String consumerEdcDataManagementUrl, Map headers) throws IOException { var url = consumerEdcDataManagementUrl + edcProperties.getNegotiationPath(); - var requestBody = RequestBody.create(objectMapper.writeValueAsString(contractOfferRequest), JSON); + + final String jsonObject = edcTransformer.transformNegotiationRequestToJson(negotiationRequest).toString(); + var requestBody = RequestBody.create(jsonObject, JSON); var request = new Request.Builder().url(url).post(requestBody); headers.forEach(request::addHeader); - TransferId negotiationId = (TransferId) httpCallService.sendRequest(request.build(), TransferId.class); - log.info(":::: Method [initiateNegotiation] Negotiation Id :{}", negotiationId.getId()); - return negotiationId.getId(); + Response negotiationIdResponse = (Response) httpCallService.sendRequest(request.build(), Response.class); + log.info(":::: Method [initiateNegotiation] Negotiation Id :{}", negotiationIdResponse.getResponseId()); + return negotiationIdResponse.getResponseId(); } /** * Rest call for Transfer Data with HttpProxy */ - public TransferId initiateHttpProxyTransferProcess(String agreementId, String assetId, String consumerEdcDataManagementUrl, String providerConnectorControlPlaneIDSUrl, Map headers) throws IOException { + public void initiateHttpProxyTransferProcess(String consumerEdcDataManagementUrl, + String providerConnectorControlPlaneIDSUrl, + TransferProcessRequest transferProcessRequest, + Map headers) throws IOException { var url = consumerEdcDataManagementUrl + edcProperties.getTransferPath(); - DataAddress dataDestination = DataAddress.Builder.newInstance().type("HttpProxy").build(); - TransferType transferType = TransferType.Builder.transferType().contentType("application/octet-stream").isFinite(true).build(); - TransferRequestDto transferRequest = TransferRequestDto.Builder.newInstance() - .assetId(assetId).contractId(agreementId).connectorId("provider").connectorAddress(providerConnectorControlPlaneIDSUrl) - .protocol("ids-multipart").dataDestination(dataDestination).managedResources(false).transferType(transferType) - .build(); - var requestBody = RequestBody.create(objectMapper.writeValueAsString(transferRequest), JSON); + final String jsonObject = edcTransformer.transformTransferProcessRequestToJson(transferProcessRequest).toString(); + + var requestBody = RequestBody.create(jsonObject, JSON); var request = new Request.Builder().url(url).post(requestBody); headers.forEach(request::addHeader); - log.info(":::: call Transfer process with http Proxy method[initiateHttpProxyTransferProcess] agreementId:{} ,assetId :{},consumerEdcDataManagementUrl :{}, providerConnectorControlPlaneIDSUrl:{}", agreementId, assetId, consumerEdcDataManagementUrl, providerConnectorControlPlaneIDSUrl); - return (TransferId) httpCallService.sendRequest(request.build(), TransferId.class); + log.info(":::: call Transfer process with http Proxy method[initiateHttpProxyTransferProcess] agreementId:{} ,assetId :{},consumerEdcDataManagementUrl :{}, providerConnectorControlPlaneIDSUrl:{}", transferProcessRequest.getContractId(), transferProcessRequest.getAssetId(), consumerEdcDataManagementUrl, providerConnectorControlPlaneIDSUrl); + httpCallService.sendRequest(request.build(), Response.class); } + } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/HttpCallService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/HttpCallService.java index 4918d71596..eabb73be87 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/HttpCallService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/HttpCallService.java @@ -28,20 +28,24 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.catalog.Catalog; +import org.eclipse.edc.catalog.spi.Catalog; +import org.eclipse.edc.catalog.spi.CatalogRequest; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.jsontransformer.EdcTransformer; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.NegotiationResponse; import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.AtomicConstraint; import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.LiteralExpression; -import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.contract.model.CatalogRequestDTO; import org.eclipse.tractusx.traceability.infrastructure.edc.properties.EdcProperties; import org.springframework.stereotype.Component; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.TimeUnit; import static java.lang.String.format; +import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transferprocess.TransferProcessRequest.DEFAULT_PROTOCOL; @Slf4j @Component @@ -50,11 +54,13 @@ public class HttpCallService { private final OkHttpClient httpClient; private final ObjectMapper objectMapper; private final EdcProperties edcProperties; + private final EdcTransformer edcTransformer; - public HttpCallService(OkHttpClient httpClient, ObjectMapper objectMapper, EdcProperties edcProperties) { + public HttpCallService(OkHttpClient httpClient, ObjectMapper objectMapper, EdcProperties edcProperties, EdcTransformer edcTransformer) { this.httpClient = withIncreasedTimeout(httpClient); this.objectMapper = objectMapper; this.edcProperties = edcProperties; + this.edcTransformer = edcTransformer; objectMapper.registerSubtypes(AtomicConstraint.class, LiteralExpression.class); } @@ -66,21 +72,57 @@ private static OkHttpClient withIncreasedTimeout(OkHttpClient httpClient) { .build(); } - - public Catalog getCatalogFromProvider( + public Catalog getCatalogForNotification( String consumerEdcDataManagementUrl, String providerConnectorControlPlaneIDSUrl, Map headers ) throws IOException { var url = consumerEdcDataManagementUrl + edcProperties.getCatalogPath(); MediaType mediaType = MediaType.parse("application/json"); - CatalogRequestDTO catalogRequestDTO = new CatalogRequestDTO(providerConnectorControlPlaneIDSUrl); - var request = new Request.Builder().url(url).post(RequestBody.create(mediaType, objectMapper.writeValueAsString(catalogRequestDTO))); + + // TODO instead of filtering with java logic after the call of this method we could add a filter to the .querySpec within CatalogRequest object. Max W. + CatalogRequest catalogRequestDTO = CatalogRequest.Builder.newInstance() + .protocol(DEFAULT_PROTOCOL) + .providerUrl(providerConnectorControlPlaneIDSUrl) + .build(); + + final String requestJson = edcTransformer.transformCatalogRequestToJson(catalogRequestDTO).toString(); + var request = new Request.Builder().url(url).post(RequestBody.create(mediaType, requestJson)); headers.forEach(request::addHeader); + return sendCatalogRequest(request.build()); + } - return (Catalog) sendRequest(request.build(), Catalog.class); + public Catalog sendCatalogRequest(Request request) throws IOException { + log.info("Requesting {} {}...", request.method(), request.url()); + try (var response = httpClient.newCall(request).execute()) { + var body = response.body(); + + if (!response.isSuccessful() || body == null) { + throw new BadRequestException(format("Control plane responded with: %s %s", response.code(), body != null ? body.string() : "")); + } + + String res = body.string(); + return edcTransformer.transformCatalog(res, StandardCharsets.UTF_8); + } catch (Exception e) { + throw e; + } } + public NegotiationResponse sendNegotiationRequest(Request request) throws IOException { + log.info("Requesting {} {}...", request.method(), request.url()); + try (var response = httpClient.newCall(request).execute()) { + var body = response.body(); + + if (!response.isSuccessful() || body == null) { + throw new BadRequestException(format("Control plane responded with: %s %s", response.code(), body != null ? body.string() : "")); + } + + String res = body.string(); + return edcTransformer.transformJsonToNegotiationResponse(res, StandardCharsets.UTF_8); + } catch (Exception e) { + throw e; + } + } public Object sendRequest(Request request, Class responseObject) throws IOException { log.info("Requesting {} {}...", request.method(), request.url()); diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/InvestigationsEDCFacade.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/InvestigationsEDCFacade.java index fe06dd4d38..75f74f56ff 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/InvestigationsEDCFacade.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/InvestigationsEDCFacade.java @@ -29,18 +29,34 @@ import okhttp3.MediaType; import okhttp3.Request; import okhttp3.RequestBody; +import org.eclipse.edc.catalog.spi.Catalog; +import org.eclipse.edc.catalog.spi.Dataset; +import org.eclipse.edc.policy.model.AtomicConstraint; +import org.eclipse.edc.policy.model.Constraint; +import org.eclipse.edc.policy.model.Operator; +import org.eclipse.edc.policy.model.OrConstraint; +import org.eclipse.edc.policy.model.Permission; +import org.eclipse.edc.policy.model.Policy; +import org.eclipse.edc.spi.types.domain.DataAddress; import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.cache.EndpointDataReference; import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.cache.InMemoryEndpointDataReferenceCache; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.catalog.CatalogItem; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.configuration.JsonLdConfiguration; import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.model.EDCNotification; import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.model.EDCNotificationFactory; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.offer.ContractOffer; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.PolicyDefinition; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transferprocess.TransferProcessDataDestination; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transferprocess.TransferProcessRequest; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.validators.AtomicConstraintValidator; import org.eclipse.tractusx.traceability.infrastructure.edc.properties.EdcProperties; import org.eclipse.tractusx.traceability.qualitynotification.domain.model.QualityNotificationMessage; +import org.eclipse.tractusx.traceability.qualitynotification.domain.model.QualityNotificationType; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import java.io.IOException; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutionException; @@ -49,6 +65,9 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.configuration.JsonLdConfiguration.NAMESPACE_EDC; +import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.configuration.JsonLdConfiguration.NAMESPACE_EDC_ID; + @Slf4j @Component @RequiredArgsConstructor @@ -66,6 +85,11 @@ public class InvestigationsEDCFacade { private final EdcProperties edcProperties; + public static final String ASSET_VALUE_QUALITY_INVESTIGATION = "qualityinvestigation"; + public static final String ASSET_VALUE_QUALITY_ALERT = "qualityalert"; + private static final String ASSET_VALUE_NOTIFICATION_METHOD_UPDATE = "update"; + private static final String ASSET_VALUE_NOTIFICATION_METHOD_RECEIVE = "receive"; + public void startEDCTransfer(QualityNotificationMessage notification, String receiverEdcUrl, String senderEdcUrl) { Map header = new HashMap<>(); header.put("x-api-key", edcProperties.getApiAuthKey()); @@ -73,51 +97,82 @@ public void startEDCTransfer(QualityNotificationMessage notification, String rec notification.setEdcUrl(receiverEdcUrl); log.info(":::: Find Notification contract method[startEDCTransfer] senderEdcUrl :{}, receiverEdcUrl:{}", senderEdcUrl, receiverEdcUrl); - Optional contractOffer = edcService.findNotificationContractOffer( + Catalog catalog = edcService.getCatalog( senderEdcUrl, receiverEdcUrl + edcProperties.getIdsPath(), - header, - notification + header ); - if (contractOffer.isEmpty()) { - log.info("No Notification contractOffer found"); - throw new BadRequestException("No notification contract offer found."); + if (catalog.getDatasets().isEmpty()) { + log.info("No Dataset in catalog found"); + throw new BadRequestException("Notication method and type not found."); } + Optional filteredDataset = catalog.getDatasets().stream() + .filter(dataset -> isQualityNotificationOffer(notification, dataset)) + .findFirst() + .filter(this::hasTracePolicy); + + log.info(":::: Initialize Contract Negotiation method[startEDCTransfer] senderEdcUrl :{}, receiverEdcUrl:{}", senderEdcUrl, receiverEdcUrl); - String agreementId = edcService.initializeContractNegotiation( - receiverEdcUrl, - contractOffer.get().getAsset().getId(), - contractOffer.get().getId(), - contractOffer.get().getPolicy(), - senderEdcUrl, - header - ); + final List items = filteredDataset.stream().map(dataSet -> { + final Map.Entry offer = dataSet.getOffers() + .entrySet() + .stream() + .findFirst() + .orElseThrow(); + final var catalogItem = CatalogItem.builder() + .itemId(dataSet.getId()) + .assetPropId(dataSet.getProperty(NAMESPACE_EDC_ID).toString()) + .connectorId(catalog.getId()) + .offerId(offer.getKey()) + .policy(offer.getValue()); + if (catalog.getProperties().containsKey(JsonLdConfiguration.NAMESPACE_EDC_PARTICIPANT_ID)) { + catalogItem.connectorId( + catalog.getProperties().get(JsonLdConfiguration.NAMESPACE_EDC_PARTICIPANT_ID).toString()); + } - endpointDataReferenceCache.storeAgreementId(agreementId); - log.info(":::: Contract Agreed method[startEDCTransfer] agreementId :{}", agreementId); + return catalogItem.build(); + }).toList(); - if (StringUtils.hasLength(agreementId)) { - notification.setContractAgreementId(agreementId); + Optional catalogItem = items.stream().findFirst(); + + if (catalogItem.isEmpty()) { + log.info("No Catalog Item in catalog found"); + throw new BadRequestException("No Catalog Item in catalog found"); } - EndpointDataReference dataReference = endpointDataReferenceCache.get(agreementId); + final String negotiationId = edcService.initializeContractNegotiation(receiverEdcUrl, catalogItem.get(), senderEdcUrl, header); + + log.info(":::: Contract Agreed method[startEDCTransfer] agreementId :{}", negotiationId); + + endpointDataReferenceCache.storeAgreementId(negotiationId); + + if (StringUtils.hasLength(negotiationId)) { + notification.setContractAgreementId(negotiationId); + } + + EndpointDataReference dataReference = endpointDataReferenceCache.get(negotiationId); boolean validDataReference = dataReference != null && InMemoryEndpointDataReferenceCache.endpointDataRefTokenExpired(dataReference); if (!validDataReference) { log.info(":::: Invalid Data Reference :::::"); if (dataReference != null) { - endpointDataReferenceCache.remove(agreementId); + endpointDataReferenceCache.remove(negotiationId); } + final TransferProcessRequest transferProcessRequest = createTransferProcessRequest( + receiverEdcUrl + edcProperties.getIdsPath(), + catalogItem.get(), + negotiationId); + log.info(":::: initialize Transfer process with http Proxy :::::"); // Initiate transfer process - edcService.initiateHttpProxyTransferProcess(agreementId, contractOffer.get().getAsset().getId(), - senderEdcUrl, + edcService.initiateHttpProxyTransferProcess(senderEdcUrl, receiverEdcUrl + edcProperties.getIdsPath(), + transferProcessRequest, header ); - dataReference = getDataReference(agreementId); + dataReference = getDataReference(negotiationId); } Request notificationRequest = buildNotificationRequest(notification, senderEdcUrl, dataReference); @@ -135,6 +190,26 @@ public void startEDCTransfer(QualityNotificationMessage notification, String rec } } + private TransferProcessRequest createTransferProcessRequest(final String providerConnectorUrl, + final CatalogItem catalogItem, + final String negotiationId) { + final var destination = DataAddress.Builder.newInstance() + .type(TransferProcessDataDestination.DEFAULT_TYPE) + .build(); + final var transferProcessRequestBuilder = TransferProcessRequest.builder() + .protocol( + TransferProcessRequest.DEFAULT_PROTOCOL) + .managedResources( + TransferProcessRequest.DEFAULT_MANAGED_RESOURCES) + .connectorId(catalogItem.getConnectorId()) + .connectorAddress(providerConnectorUrl) + .contractId(negotiationId) + .assetId(catalogItem.getAssetPropId()) + .dataDestination(destination); + + return transferProcessRequestBuilder.build(); + } + private Request buildNotificationRequest(QualityNotificationMessage notification, String senderEdcUrl, EndpointDataReference dataReference) throws JsonProcessingException { EDCNotification edcNotification = EDCNotificationFactory.createEdcNotification(senderEdcUrl, notification); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); @@ -174,5 +249,80 @@ private EndpointDataReference getDataReference(String agreementId) throws Interr return dataReference; } + public boolean isQualityNotificationOffer(QualityNotificationMessage qualityNotificationMessage, Dataset dataset) { + Object notificationTypeObj = dataset.getProperty(NAMESPACE_EDC + "notificationtype"); + String notificationType = null; + if (notificationTypeObj != null) { + notificationType = notificationTypeObj.toString(); + } + Object notificationMethodObj = dataset.getProperty(NAMESPACE_EDC + "notificationmethod"); + String notificationMethod = null; + if (notificationMethodObj != null) { + notificationMethod = notificationMethodObj.toString(); + } + + final String propertyNotificationTypeValue = QualityNotificationType.ALERT.equals(qualityNotificationMessage.getType()) ? ASSET_VALUE_QUALITY_ALERT : ASSET_VALUE_QUALITY_INVESTIGATION; + final String propertyMethodValue = qualityNotificationMessage.getIsInitial() ? ASSET_VALUE_NOTIFICATION_METHOD_RECEIVE : ASSET_VALUE_NOTIFICATION_METHOD_UPDATE; + return propertyNotificationTypeValue.equals(notificationType) && propertyMethodValue.equals(notificationMethod); + } + + + private boolean hasTracePolicy(Dataset dataset) { + boolean foundPolicy = false; + for (Policy policy : dataset.getOffers().values()) { + log.info("Policy Check {} ", policy.toString()); + if (!foundPolicy) { + foundPolicy = isValid(policy); + } + } + log.info("Found policy: {} ", foundPolicy); + return foundPolicy; + } + + + private List allowedPolicies() { + final PolicyDefinition allowedTracePolicy = PolicyDefinition.builder() + .constraintOperator("EQ") + .permissionActionType("USE") + .constraintType("AtomicConstraint") + .leftExpressionValue("idsc:PURPOSE") + .rightExpressionValue("ID 3.0 Trace") + .build(); + return List.of(allowedTracePolicy); + } + + + public boolean isValid(final Policy policy) { + final List policyList = this.allowedPolicies(); + return policy.getPermissions() + .stream() + .anyMatch(permission -> policyList.stream() + .anyMatch(allowedPolicy -> isValid(permission, allowedPolicy))); + } + + private boolean isValid(final Permission permission, final PolicyDefinition policyDefinition) { + return permission.getAction().getType().equals(policyDefinition.getPermissionActionType()) + && permission.getConstraints() + .stream() + .anyMatch(constraint -> isValid(constraint, policyDefinition)); + } + + private boolean isValid(final Constraint constraint, final PolicyDefinition policyDefinition) { + if (constraint instanceof AtomicConstraint atomicConstraint) { + return AtomicConstraintValidator.builder() + .atomicConstraint(atomicConstraint) + .leftExpressionValue(policyDefinition.getLeftExpressionValue()) + .rightExpressionValue(policyDefinition.getRightExpressionValue()) + .expectedOperator( + Operator.valueOf(policyDefinition.getConstraintOperator())) + .build() + .isValid(); + } else if (constraint instanceof OrConstraint orConstraint) { + return orConstraint.getConstraints() + .stream() + .anyMatch(constraint1 -> isValid(constraint1, policyDefinition)); + } + return false; + } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/agreement/ContractAgreement.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/agreement/ContractAgreement.java deleted file mode 100644 index ebee964b5a..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/agreement/ContractAgreement.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.agreement; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import lombok.EqualsAndHashCode; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; - -/** - * {@link ContractAgreement} to regulate data transfer between two parties. - */ -@EqualsAndHashCode -@JsonDeserialize(builder = ContractAgreement.Builder.class) -public class ContractAgreement { - - private final String id; - private final String providerAgentId; - private final String consumerAgentId; - private final long contractSigningDate; - private final long contractStartDate; - private final long contractEndDate; - private final String assetId; - private final Policy policy; - - private ContractAgreement(@NotNull String id, - @NotNull String providerAgentId, - @NotNull String consumerAgentId, - long contractSigningDate, - long contractStartDate, - long contractEndDate, - @NotNull Policy policy, - @NotNull String assetId) { - this.id = Objects.requireNonNull(id); - this.providerAgentId = Objects.requireNonNull(providerAgentId); - this.consumerAgentId = Objects.requireNonNull(consumerAgentId); - this.contractSigningDate = contractSigningDate; - this.contractStartDate = contractStartDate; - this.contractEndDate = contractEndDate; - this.assetId = Objects.requireNonNull(assetId); - this.policy = Objects.requireNonNull(policy); - } - - /** - * Unique identifier of the {@link ContractAgreement}. - * - * @return contract id - */ - @NotNull - public String getId() { - return id; - } - - /** - * The id of the data providing agent. - * Please note that id should be taken from the corresponding data ecosystem. - * For example: In IDS the connector uses a URI from the IDS Information Model as ID. If the contract was - * negotiated inside the IDS ecosystem, this URI should be used here. - * - * @return provider id - */ - @NotNull - public String getProviderAgentId() { - return providerAgentId; - } - - /** - * The id of the data consuming agent. - * Please note that id should be taken from the corresponding contract ecosystem. - * For example: In IDS the connector uses a URI from the IDS Information Model as ID. If the contract was - * negotiated inside the IDS ecosystem, this URI should be used here. - * - * @return consumer id - */ - @NotNull - public String getConsumerAgentId() { - return consumerAgentId; - } - - /** - * The date when the {@link ContractAgreement} has been signed.
- * Numeric value representing the number of seconds from - * 1970-01-01T00:00:00Z UTC until the specified UTC date/time. - * - * @return contract signing date - */ - public long getContractSigningDate() { - return contractSigningDate; - } - - /** - * The date from when the {@link ContractAgreement} is valid.
- * Numeric value representing the number of seconds from - * 1970-01-01T00:00:00Z UTC until the specified UTC date/time. - * - * @return contract start date - */ - public long getContractStartDate() { - return contractStartDate; - } - - /** - * The date until the {@link ContractAgreement} remains valid.
- * Numeric value representing the number of seconds from - * 1970-01-01T00:00:00Z UTC until the specified UTC date/time. - * - * @return contract end date - */ - public long getContractEndDate() { - return contractEndDate; - } - - /** - * The ID of the Asset that is covered by the {@link ContractAgreement}. - * - * @return assetId - */ - @NotNull - public String getAssetId() { - return assetId; - } - - /** - * The id of the policy that describes how the {@link org.eclipse.tractusx.traceability.assets.domain.model.Asset} of this contract may be used by the consumer. - * - * @return policy - */ - public Policy getPolicy() { - return policy; - } - - @JsonPOJOBuilder(withPrefix = "") - public static class Builder { - - private String id; - private String providerAgentId; - private String consumerAgentId; - private long contractSigningDate; - private long contractStartDate; - private long contractEndDate; - private String assetId; - private Policy policy; - - private Builder() { - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - this.id = id; - return this; - } - - public Builder providerAgentId(String providerAgentId) { - this.providerAgentId = providerAgentId; - return this; - } - - public Builder consumerAgentId(String consumerAgentId) { - this.consumerAgentId = consumerAgentId; - return this; - } - - public Builder contractSigningDate(long contractSigningDate) { - this.contractSigningDate = contractSigningDate; - return this; - } - - public Builder contractStartDate(long contractStartDate) { - this.contractStartDate = contractStartDate; - return this; - } - - public Builder contractEndDate(long contractEndDate) { - this.contractEndDate = contractEndDate; - return this; - } - - public Builder assetId(String assetId) { - this.assetId = assetId; - return this; - } - - public Builder policy(Policy policy) { - this.policy = policy; - return this; - } - - public ContractAgreement build() { - return new ContractAgreement(id, providerAgentId, consumerAgentId, contractSigningDate, contractStartDate, contractEndDate, policy, assetId); - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/asset/Asset.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/asset/Asset.java deleted file mode 100644 index 0b38f79a40..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/asset/Asset.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.asset; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import lombok.ToString; -import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.traceability.qualitynotification.domain.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.model.QualityNotificationType; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.UUID; - - -/** - * The {@link Asset} contains the metadata and describes the data itself or a collection of data. - */ -@Slf4j -@ToString -@JsonDeserialize(builder = Asset.Builder.class) -public class Asset { - - private static final String ASSET_VALUE_NOTIFICATION_METHOD_UPDATE = "update"; - private static final String ASSET_VALUE_NOTIFICATION_METHOD_RECEIVE = "receive"; - public static final String ASSET_KEY_NOTIFICATION_TYPE = "asset:prop:notificationtype"; - public static final String ASSET_VALUE_QUALITY_INVESTIGATION = "qualityinvestigation"; - public static final String ASSET_VALUE_QUALITY_ALERT = "qualityalert"; - public static final String PROPERTY_ID = "asset:prop:id"; - public static final String PROPERTY_NAME = "asset:prop:name"; - public static final String PROPERTY_DESCRIPTION = "asset:prop:description"; - public static final String PROPERTY_VERSION = "asset:prop:version"; - public static final String PROPERTY_CONTENT_TYPE = "asset:prop:contenttype"; - public static final String PROPERTY_NOTIFICATION_METHOD = "asset:prop:notificationmethod"; - public static final String PROPERTY_NOTIFICATION_TYPE = "asset:prop:notificationtype"; - - private Map properties; - - protected Asset() { - properties = new HashMap<>(); - } - - @JsonIgnore - public String getId() { - return getPropertyAsString(PROPERTY_ID); - } - - @JsonIgnore - public String getName() { - return getPropertyAsString(PROPERTY_NAME); - } - - @JsonIgnore - public String getDescription() { - return getPropertyAsString(PROPERTY_DESCRIPTION); - } - - @JsonIgnore - public String getVersion() { - return getPropertyAsString(PROPERTY_VERSION); - } - - @JsonIgnore - public String getContentType() { - return getPropertyAsString(PROPERTY_CONTENT_TYPE); - } - - @JsonIgnore - public String getPropertyNotificationMethod() { - return getPropertyAsString(PROPERTY_NOTIFICATION_METHOD); - } - - @JsonIgnore - public String getPropertyNotificationType() { - return getPropertyAsString(PROPERTY_NOTIFICATION_TYPE); - } - - @JsonIgnore - public boolean isQualityNotificationOffer(QualityNotificationMessage qualityNotificationMessage) { - final String propertyNotificationTypeValue = QualityNotificationType.ALERT.equals(qualityNotificationMessage.getType()) ? ASSET_VALUE_QUALITY_ALERT : ASSET_VALUE_QUALITY_INVESTIGATION; - final String propertyMethodValue = qualityNotificationMessage.getIsInitial() ? ASSET_VALUE_NOTIFICATION_METHOD_RECEIVE : ASSET_VALUE_NOTIFICATION_METHOD_UPDATE; - return propertyNotificationTypeValue.equals(this.getPropertyNotificationType()) && propertyMethodValue.equals(this.getPropertyNotificationMethod()); - } - - public Map getProperties() { - return properties; - } - - @JsonIgnore - public Object getProperty(String key) { - return properties.get(key); - } - - private String getPropertyAsString(String key) { - var val = getProperty(key); - return val != null ? val.toString() : null; - } - - @JsonPOJOBuilder(withPrefix = "") - public static class Builder> { - protected final Asset asset; - - protected Builder(Asset asset) { - this.asset = asset; - asset.properties.put(PROPERTY_ID, UUID.randomUUID().toString()); //must always have an ID - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(new Asset()); - } - - public B id(String id) { - asset.properties.put(PROPERTY_ID, id); - return (B) this; - } - - public B name(String title) { - asset.properties.put(PROPERTY_NAME, title); - return (B) this; - } - - public B description(String description) { - asset.properties.put(PROPERTY_DESCRIPTION, description); - return (B) this; - } - - public B version(String version) { - asset.properties.put(PROPERTY_VERSION, version); - return (B) this; - } - - public B contentType(String contentType) { - asset.properties.put(PROPERTY_CONTENT_TYPE, contentType); - return (B) this; - } - - public B properties(Map properties) { - asset.properties = Objects.requireNonNull(properties); - return (B) this; - } - - public B property(String key, Object value) { - asset.properties.put(key, value); - return (B) this; - } - - public Asset build() { - return asset; - } - } - -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/asset/AssetSelectorExpression.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/asset/AssetSelectorExpression.java deleted file mode 100644 index 93e85e07b0..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/asset/AssetSelectorExpression.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.asset; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.query.Criterion; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * Selects a group of assets based on the given criteria. - *

- * If an AssetSelectorExpression does not contain any criteria, no assets are selected. If all Assets are to be selected, the {@link AssetSelectorExpression#SELECT_ALL} constant - * must be used. - */ -@JsonDeserialize(builder = AssetSelectorExpression.Builder.class) -public final class AssetSelectorExpression { - - - public static final AssetSelectorExpression SELECT_ALL = new AssetSelectorExpression(); - private List criteria; - - private AssetSelectorExpression() { - criteria = new ArrayList<>(); - } - - public List getCriteria() { - return criteria; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AssetSelectorExpression that = (AssetSelectorExpression) o; - return criteria == that.criteria || criteria.equals(that.criteria); - } - - @Override - public int hashCode() { - return Objects.hash(criteria); - } - - @JsonPOJOBuilder(withPrefix = "") - public static final class Builder { - private final AssetSelectorExpression expression; - - private Builder() { - expression = new AssetSelectorExpression(); - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder criteria(List criteria) { - expression.criteria = criteria; - return this; - } - - @JsonIgnore - public Builder constraint(String left, String op, Object right) { - expression.criteria.add(new Criterion(left, op, right)); - return this; - } - - /** - * Convenience method to express equality checks. Is equivalent to {@code Builder.withConstraint(key, "=", value)} - * - * @param key left-hand operand - * @param value right-hand operand - */ - @JsonIgnore - public Builder whenEquals(String key, String value) { - expression.criteria.add(new Criterion(key, "=", value)); - return this; - } - - public AssetSelectorExpression build() { - return expression; - } - } - -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/cache/EndpointDataReference.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/cache/EndpointDataReference.java index 7410766da8..35684899a0 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/cache/EndpointDataReference.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/cache/EndpointDataReference.java @@ -25,6 +25,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import lombok.ToString; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,6 +37,7 @@ /** * Describes an endpoint serving data. */ +@ToString @JsonDeserialize(builder = EndpointDataReference.Builder.class) @JsonIgnoreProperties(ignoreUnknown = true) public class EndpointDataReference { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/Catalog.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/Catalog.java deleted file mode 100644 index 910177cc30..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/Catalog.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.catalog; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.offer.ContractOffer; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Objects; - -/** - * DTO representing catalog containing {@link ContractOffer}s. - */ -@JsonDeserialize( - builder = Catalog.Builder.class -) -public class Catalog { - private final String id; - private final List contractOffers; - - private Catalog(@NotNull String id, @NotNull List contractOffers) { - this.id = Objects.requireNonNull(id); - this.contractOffers = Objects.requireNonNull(contractOffers); - } - - public String getId() { - return id; - } - - public List getContractOffers() { - return contractOffers; - } - - @JsonPOJOBuilder(withPrefix = "") - public static class Builder { - private String id; - private List contractOffers; - - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - this.id = id; - return this; - } - - public Builder contractOffers(List contractOffers) { - this.contractOffers = contractOffers; - return this; - } - - public Catalog build() { - return new Catalog(id, contractOffers); - } - - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogItem.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogItem.java new file mode 100644 index 0000000000..dd593704dd --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogItem.java @@ -0,0 +1,44 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.catalog; + +import lombok.Builder; +import lombok.Data; +import org.eclipse.edc.policy.model.Policy; + +import java.time.Instant; + +/** + * Catalog Item as it is stored in the cache and used by {@link org.eclipse.edc.connector.spi.contractnegotiation.ContractNegotiationService}. + */ +@Builder +@Data +public class CatalogItem { + private String assetPropId; + private String itemId; + private Policy policy; + private String connectorId; + private String offerId; + private Instant validUntil; + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogRequest.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogRequest.java deleted file mode 100644 index d4aa47cd84..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogRequest.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.catalog; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.message.RemoteMessage; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; - -/** - * A request for a participant's {@link Catalog}. - */ -@JsonDeserialize(builder = CatalogRequest.Builder.class) -public class CatalogRequest implements RemoteMessage { - - private final String protocol; - private final String connectorId; - private final String connectorAddress; - - private CatalogRequest(@NotNull String protocol, @NotNull String connectorId, @NotNull String connectorAddress) { - this.protocol = protocol; - this.connectorId = connectorId; - this.connectorAddress = connectorAddress; - } - - @Override - @NotNull - public String getProtocol() { - return protocol; - } - - @NotNull - public String getConnectorId() { - return connectorId; - } - - @NotNull - public String getConnectorAddress() { - return connectorAddress; - } - - public static class Builder { - private String protocol; - private String connectorId; - private String connectorAddress; - - private Builder() { - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder protocol(String protocol) { - this.protocol = protocol; - return this; - } - - public Builder connectorId(String connectorId) { - this.connectorId = connectorId; - return this; - } - - public Builder connectorAddress(String connectorAddress) { - this.connectorAddress = connectorAddress; - return this; - } - - public CatalogRequest build() { - Objects.requireNonNull(protocol, "protocol"); - Objects.requireNonNull(connectorId, "connectorId"); - Objects.requireNonNull(connectorAddress, "connectorAddress"); - - return new CatalogRequest(protocol, connectorId, connectorAddress); - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/configuration/JsonLdConfiguration.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/configuration/JsonLdConfiguration.java new file mode 100644 index 0000000000..342b0ef322 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/configuration/JsonLdConfiguration.java @@ -0,0 +1,80 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.configuration; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsonp.JSONPModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.eclipse.edc.jsonld.TitaniumJsonLd; +import org.eclipse.edc.policy.model.AtomicConstraint; +import org.eclipse.edc.policy.model.LiteralExpression; +import org.eclipse.edc.spi.monitor.ConsoleMonitor; +import org.eclipse.edc.spi.monitor.Monitor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * JsonLD configuration and namespace constants. + */ +@Configuration +public class JsonLdConfiguration { + + public static final String NAMESPACE_ODRL = "http://www.w3.org/ns/odrl/2/"; + public static final String NAMESPACE_DSPACE = "https://w3id.org/dspace/v0.8/"; + public static final String NAMESPACE_DCAT = "https://www.w3.org/ns/dcat/"; + public static final String NAMESPACE_EDC = "https://w3id.org/edc/v0.0.1/ns/"; + public static final String NAMESPACE_EDC_CID = NAMESPACE_EDC + "cid"; + public static final String NAMESPACE_EDC_PARTICIPANT_ID = NAMESPACE_EDC + "participantId"; + public static final String NAMESPACE_EDC_ID = NAMESPACE_EDC + "id"; + public static final String NAMESPACE_TRACTUSX = "https://w3id.org/tractusx/v0.0.1/ns/"; + public static final String NAMESPACE_DCT = "https://purl.org/dc/terms/"; + + @Bean /* package */ TitaniumJsonLd titaniumJsonLd(final Monitor monitor) { + final TitaniumJsonLd titaniumJsonLd = new TitaniumJsonLd(monitor); + titaniumJsonLd.registerNamespace("odrl", JsonLdConfiguration.NAMESPACE_ODRL); + titaniumJsonLd.registerNamespace("dct", NAMESPACE_DCT); + titaniumJsonLd.registerNamespace("tx", NAMESPACE_TRACTUSX); + titaniumJsonLd.registerNamespace("edc", NAMESPACE_EDC); + titaniumJsonLd.registerNamespace("dcat", JsonLdConfiguration.NAMESPACE_DCAT); + titaniumJsonLd.registerNamespace("dspace", NAMESPACE_DSPACE); + return titaniumJsonLd; + } + + @Bean /* package */ Monitor monitor() { + return new ConsoleMonitor(); + } + + @Bean /* package */ ObjectMapper objectMapperJsonLd() { + final ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JavaTimeModule()); + objectMapper.registerModule(new Jdk8Module()); + objectMapper.registerModule(new JSONPModule()); + objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + objectMapper.registerSubtypes(AtomicConstraint.class, LiteralExpression.class); + return objectMapper; + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/EdcTransformer.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/EdcTransformer.java new file mode 100644 index 0000000000..99734e6e88 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/EdcTransformer.java @@ -0,0 +1,190 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.jsontransformer; + +import com.apicatalog.jsonld.document.JsonDocument; +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.json.Json; +import jakarta.json.JsonBuilderFactory; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; +import org.eclipse.edc.catalog.spi.Catalog; +import org.eclipse.edc.catalog.spi.CatalogRequest; +import org.eclipse.edc.connector.core.transform.TransformerContextImpl; +import org.eclipse.edc.connector.core.transform.TypeTransformerRegistryImpl; +import org.eclipse.edc.jsonld.TitaniumJsonLd; +import org.eclipse.edc.jsonld.transformer.from.JsonObjectFromAssetTransformer; +import org.eclipse.edc.jsonld.transformer.from.JsonObjectFromCatalogTransformer; +import org.eclipse.edc.jsonld.transformer.from.JsonObjectFromCriterionTransformer; +import org.eclipse.edc.jsonld.transformer.from.JsonObjectFromDataServiceTransformer; +import org.eclipse.edc.jsonld.transformer.from.JsonObjectFromDatasetTransformer; +import org.eclipse.edc.jsonld.transformer.from.JsonObjectFromDistributionTransformer; +import org.eclipse.edc.jsonld.transformer.from.JsonObjectFromPolicyTransformer; +import org.eclipse.edc.jsonld.transformer.from.JsonObjectFromQuerySpecTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToActionTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToAssetTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToCatalogTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToConstraintTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToCriterionTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToDataServiceTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToDatasetTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToDistributionTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToDutyTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToPermissionTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToPolicyTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToProhibitionTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonObjectToQuerySpecTransformer; +import org.eclipse.edc.jsonld.transformer.to.JsonValueToGenericTypeTransformer; +import org.eclipse.edc.protocol.dsp.transferprocess.transformer.type.from.JsonObjectFromDataAddressTransformer; +import org.eclipse.edc.spi.result.Result; +import org.eclipse.edc.transform.spi.TypeTransformerRegistry; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractOfferDescription; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.NegotiationRequest; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.NegotiationResponse; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.NegotiationState; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transferprocess.TransferProcessRequest; +import org.springframework.stereotype.Component; + +import java.io.ByteArrayInputStream; +import java.nio.charset.Charset; +import java.util.Map; + +/** + * Transformer to convert between EDC models and JSON-LD. + */ +@Component +@SuppressWarnings("PMD.ExcessiveImports") +public class EdcTransformer { + private final JsonObjectToCatalogTransformer jsonObjectToCatalogTransformer; + private final JsonObjectFromNegotiationInitiateDtoTransformer jsonObjectFromNegotiationInitiateDtoTransformer; + private final JsonObjectFromTransferProcessRequestTransformer jsonObjectFromTransferProcessRequestTransformer; + private final JsonObjectFromContractOfferDescriptionTransformer jsonObjectFromContractOfferDescriptionTransformer; + private final JsonObjectFromCatalogRequestTransformer jsonObjectFromCatalogRequestTransformer; + private final TitaniumJsonLd titaniumJsonLd; + private final TransformerContextImpl transformerContext; + private final JsonObjectToNegotiationResponseTransformer jsonObjectToNegotiationResponseTransformer; + private final JsonObjectToNegotiationStateTransformer jsonObjectToNegotiationStateTransformer; + + public EdcTransformer(final ObjectMapper objectMapper, final TitaniumJsonLd titaniumJsonLd) { + this.titaniumJsonLd = titaniumJsonLd; + final JsonBuilderFactory jsonBuilderFactory = Json.createBuilderFactory(Map.of()); + + jsonObjectFromNegotiationInitiateDtoTransformer = new JsonObjectFromNegotiationInitiateDtoTransformer( + jsonBuilderFactory); + jsonObjectToCatalogTransformer = new JsonObjectToCatalogTransformer(); + jsonObjectFromTransferProcessRequestTransformer = new JsonObjectFromTransferProcessRequestTransformer( + jsonBuilderFactory); + jsonObjectFromContractOfferDescriptionTransformer = new JsonObjectFromContractOfferDescriptionTransformer( + jsonBuilderFactory); + jsonObjectFromCatalogRequestTransformer = new JsonObjectFromCatalogRequestTransformer(jsonBuilderFactory); + jsonObjectToNegotiationResponseTransformer = new JsonObjectToNegotiationResponseTransformer(); + jsonObjectToNegotiationStateTransformer = new JsonObjectToNegotiationStateTransformer(); + + final TypeTransformerRegistry typeTransformerRegistry = new TypeTransformerRegistryImpl(); + transformerContext = new TransformerContextImpl(typeTransformerRegistry); + + // JSON to Object + typeTransformerRegistry.register(jsonObjectToCatalogTransformer); + typeTransformerRegistry.register(new JsonValueToGenericTypeTransformer(objectMapper)); + typeTransformerRegistry.register(new JsonObjectToDataServiceTransformer()); + typeTransformerRegistry.register(new JsonObjectToConstraintTransformer()); + typeTransformerRegistry.register(new JsonObjectToDatasetTransformer()); + typeTransformerRegistry.register(new JsonObjectToPolicyTransformer()); + typeTransformerRegistry.register(new JsonObjectToPermissionTransformer()); + typeTransformerRegistry.register(new JsonObjectToActionTransformer()); + typeTransformerRegistry.register(new JsonObjectToDistributionTransformer()); + typeTransformerRegistry.register(new JsonObjectToProhibitionTransformer()); + typeTransformerRegistry.register(new JsonObjectToDutyTransformer()); + typeTransformerRegistry.register(new JsonObjectToAssetTransformer()); + typeTransformerRegistry.register(new JsonObjectToQuerySpecTransformer()); + typeTransformerRegistry.register(new JsonObjectToCriterionTransformer()); + typeTransformerRegistry.register(jsonObjectToNegotiationResponseTransformer); + // JSON from Object + typeTransformerRegistry.register(jsonObjectFromNegotiationInitiateDtoTransformer); + typeTransformerRegistry.register(jsonObjectFromCatalogRequestTransformer); + typeTransformerRegistry.register(jsonObjectFromTransferProcessRequestTransformer); + typeTransformerRegistry.register(jsonObjectFromContractOfferDescriptionTransformer); + typeTransformerRegistry.register(new JsonObjectFromQuerySpecTransformer(jsonBuilderFactory)); + typeTransformerRegistry.register(new JsonObjectFromCatalogTransformer(jsonBuilderFactory, objectMapper)); + typeTransformerRegistry.register(new JsonObjectFromDatasetTransformer(jsonBuilderFactory, objectMapper)); + typeTransformerRegistry.register(new JsonObjectFromPolicyTransformer(jsonBuilderFactory)); + typeTransformerRegistry.register(new JsonObjectFromDistributionTransformer(jsonBuilderFactory)); + typeTransformerRegistry.register(new JsonObjectFromDataServiceTransformer(jsonBuilderFactory)); + typeTransformerRegistry.register(new JsonObjectFromAssetTransformer(jsonBuilderFactory, objectMapper)); + typeTransformerRegistry.register(new JsonObjectFromCriterionTransformer(jsonBuilderFactory, objectMapper)); + typeTransformerRegistry.register(new JsonObjectFromDataAddressTransformer(jsonBuilderFactory)); + } + + public Catalog transformCatalog(final String jsonString, final Charset charset) { + final Result expand; + try (JsonReader reader = Json.createReader(new ByteArrayInputStream(jsonString.getBytes(charset)))) { + + expand = titaniumJsonLd.expand( + JsonDocument.of(reader.read()).getJsonContent().orElseThrow().asJsonObject()); + } + return jsonObjectToCatalogTransformer.transform(expand.getContent(), transformerContext); + } + + public NegotiationResponse transformJsonToNegotiationResponse(final String jsonString, final Charset charset) { + final Result expand; + try (JsonReader reader = Json.createReader(new ByteArrayInputStream(jsonString.getBytes(charset)))) { + expand = titaniumJsonLd.expand( + JsonDocument.of(reader.read()).getJsonContent().orElseThrow().asJsonObject()); + } + return jsonObjectToNegotiationResponseTransformer.transform(expand.getContent(), transformerContext); + } + + public NegotiationState transformJsonToNegotiationState(final String jsonString, final Charset charset) { + final Result expand; + try (JsonReader reader = Json.createReader(new ByteArrayInputStream(jsonString.getBytes(charset)))) { + expand = titaniumJsonLd.expand( + JsonDocument.of(reader.read()).getJsonContent().orElseThrow().asJsonObject()); + } + return jsonObjectToNegotiationStateTransformer.transform(expand.getContent(), transformerContext); + } + + public JsonObject transformNegotiationRequestToJson(final NegotiationRequest negotiationRequest) { + final JsonObject transform = jsonObjectFromNegotiationInitiateDtoTransformer.transform(negotiationRequest, + transformerContext); + return titaniumJsonLd.compact(transform).asOptional().orElseThrow(); + } + + public JsonObject transformTransferProcessRequestToJson(final TransferProcessRequest transferProcessRequest) { + final JsonObject transform = jsonObjectFromTransferProcessRequestTransformer.transform(transferProcessRequest, + transformerContext); + return titaniumJsonLd.compact(transform).asOptional().orElseThrow(); + } + + public JsonObject transformContractOfferDescriptionToJson(final ContractOfferDescription contractOfferDescription) { + + final JsonObject transform = jsonObjectFromContractOfferDescriptionTransformer.transform( + contractOfferDescription, transformerContext); + return titaniumJsonLd.compact(transform).asOptional().orElseThrow(); + } + + public JsonObject transformCatalogRequestToJson(final CatalogRequest catalogRequest) { + final JsonObject transform = jsonObjectFromCatalogRequestTransformer.transform(catalogRequest, + transformerContext); + return titaniumJsonLd.compact(transform).asOptional().orElseThrow(); + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromCatalogRequestTransformer.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromCatalogRequestTransformer.java new file mode 100644 index 0000000000..811b3f2eba --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromCatalogRequestTransformer.java @@ -0,0 +1,61 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.jsontransformer; + +import jakarta.json.JsonBuilderFactory; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import org.eclipse.edc.catalog.spi.CatalogRequest; +import org.eclipse.edc.jsonld.spi.JsonLdKeywords; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; + +/** + * Transformer to convert CatalogRequest to JSON-LD. + */ +public class JsonObjectFromCatalogRequestTransformer extends AbstractJsonLdTransformer { + private final JsonBuilderFactory jsonFactory; + + public JsonObjectFromCatalogRequestTransformer(final JsonBuilderFactory jsonFactory) { + super(CatalogRequest.class, JsonObject.class); + this.jsonFactory = jsonFactory; + } + + @Override + public @Nullable JsonObject transform(@NotNull final CatalogRequest dto, + @NotNull final TransformerContext context) { + final JsonObjectBuilder builder = this.jsonFactory.createObjectBuilder(); + builder.add(JsonLdKeywords.TYPE, CatalogRequest.EDC_CATALOG_REQUEST_TYPE) + .add(CatalogRequest.EDC_CATALOG_REQUEST_PROVIDER_URL, dto.getProviderUrl()) + .add(CatalogRequest.EDC_CATALOG_REQUEST_PROTOCOL, dto.getProtocol()); + Optional.ofNullable(dto.getQuerySpec()) + .ifPresent(s -> builder.add(CatalogRequest.EDC_CATALOG_REQUEST_QUERY_SPEC, + context.transform(dto.getQuerySpec(), JsonObject.class))); + + return builder.build(); + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromContractOfferDescriptionTransformer.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromContractOfferDescriptionTransformer.java new file mode 100644 index 0000000000..d1dcfbbef4 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromContractOfferDescriptionTransformer.java @@ -0,0 +1,59 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.jsontransformer; + +import jakarta.json.JsonBuilderFactory; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import org.eclipse.edc.jsonld.spi.JsonLdKeywords; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractOfferDescription; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Transformer to convert ContractOfferDescription to JSON-LD. + */ +public class JsonObjectFromContractOfferDescriptionTransformer + extends AbstractJsonLdTransformer { + private final JsonBuilderFactory jsonFactory; + + public JsonObjectFromContractOfferDescriptionTransformer(final JsonBuilderFactory jsonFactory) { + super(ContractOfferDescription.class, JsonObject.class); + this.jsonFactory = jsonFactory; + } + + @Override + public @Nullable JsonObject transform(@NotNull final ContractOfferDescription dto, + final @NotNull TransformerContext context) { + final JsonObjectBuilder builder = this.jsonFactory.createObjectBuilder(); + builder.add(JsonLdKeywords.TYPE, ContractOfferDescription.CONTRACT_OFFER_TYPE) + .add(ContractOfferDescription.CONTRACT_OFFER_OFFER_ID, dto.getOfferId()) + .add(ContractOfferDescription.CONTRACT_OFFER_ASSET_ID, dto.getAssetId()) + .add("validity", dto.getValidity()) + .add(ContractOfferDescription.CONTRACT_OFFER_POLICY, context.transform(dto.getPolicy(), JsonObject.class)); + + return builder.build(); + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromNegotiationInitiateDtoTransformer.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromNegotiationInitiateDtoTransformer.java new file mode 100644 index 0000000000..301aa8fac4 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromNegotiationInitiateDtoTransformer.java @@ -0,0 +1,77 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.jsontransformer; + +import jakarta.json.JsonArrayBuilder; +import jakarta.json.JsonBuilderFactory; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.NegotiationRequest; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * Transformer to convert NegotiationRequest to JSON-LD. + */ +public class JsonObjectFromNegotiationInitiateDtoTransformer + extends AbstractJsonLdTransformer { + private final JsonBuilderFactory jsonFactory; + + public JsonObjectFromNegotiationInitiateDtoTransformer(final JsonBuilderFactory jsonFactory) { + super(NegotiationRequest.class, JsonObject.class); + this.jsonFactory = jsonFactory; + } + + @Override + public @Nullable JsonObject transform(@NotNull final NegotiationRequest dto, + @NotNull final TransformerContext context) { + final JsonObjectBuilder builder = this.jsonFactory.createObjectBuilder(); + builder.add(NegotiationRequest.NEGOTIATION_CONNECTOR_ADDRESS, dto.getConnectorAddress()) + .add(NegotiationRequest.NEGOTIATION_CONNECTOR_ID, dto.getConnectorId()) + .add(NegotiationRequest.NEGOTIATION_OFFER, context.transform(dto.getOffer(), JsonObject.class)) + .add(NegotiationRequest.NEGOTIATION_PROTOCOL, dto.getProtocol()); + Optional.ofNullable(dto.getProviderId()) + .ifPresent(s -> builder.add(NegotiationRequest.NEGOTIATION_PROVIDER_ID, dto.getProviderId())); + Optional.ofNullable(dto.getCallbackAddresses()) + .ifPresent(s -> builder.add(NegotiationRequest.NEGOTIATION_CALLBACK_ADDRESSES, + asArray(dto.getCallbackAddresses(), context))); + Optional.ofNullable(dto.getConsumerId()) + .ifPresent(s -> builder.add(NegotiationRequest.NEGOTIATION_CONSUMER_ID, dto.getConsumerId())); + return builder.build(); + } + + private JsonArrayBuilder asArray(final List callbackAddresses, final TransformerContext context) { + final JsonArrayBuilder builder = Objects.requireNonNull(this.jsonFactory.createArrayBuilder()); + callbackAddresses.stream() + .map(callbackAddress -> context.transform(callbackAddress, JsonObject.class)) + .forEach(builder::add); + return builder; + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromTransferProcessRequestTransformer.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromTransferProcessRequestTransformer.java new file mode 100644 index 0000000000..8608822d53 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectFromTransferProcessRequestTransformer.java @@ -0,0 +1,93 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.jsontransformer; + +import jakarta.json.JsonArrayBuilder; +import jakarta.json.JsonBuilderFactory; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transferprocess.TransferProcessRequest; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.configuration.JsonLdConfiguration.NAMESPACE_EDC; + +/** + * Transformer to convert TransferProcessRequest to JSON-LD. + */ +public class JsonObjectFromTransferProcessRequestTransformer + extends AbstractJsonLdTransformer { + private final JsonBuilderFactory jsonFactory; + + public JsonObjectFromTransferProcessRequestTransformer(final JsonBuilderFactory jsonFactory) { + super(TransferProcessRequest.class, JsonObject.class); + this.jsonFactory = jsonFactory; + } + + @Override + public @Nullable JsonObject transform(@NotNull final TransferProcessRequest dto, @NotNull final TransformerContext context) { + final JsonObjectBuilder builder = this.jsonFactory.createObjectBuilder(); + builder.add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_ASSET_ID, dto.getAssetId()) + .add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ADDRESS, dto.getConnectorAddress()) + .add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_CONTRACT_ID, dto.getContractId()) + .add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_DATA_DESTINATION, + context.transform(dto.getDataDestination(), JsonObject.class)) + .add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_PROTOCOL, dto.getProtocol()) + .add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_MANAGED_RESOURCES, dto.isManagedResources()); + + Optional.ofNullable(dto.getConnectorId()) + .ifPresent(s -> builder.add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ID, + dto.getConnectorId())); + Optional.ofNullable(dto.getCallbackAddresses()) + .ifPresent(s -> builder.add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_CALLBACK_ADDRESSES, + asArray(dto.getCallbackAddresses(), context))); + + if (dto.getProperties() != null && !dto.getProperties().isEmpty()) { + final JsonObjectBuilder objectBuilder = jsonFactory.createObjectBuilder(); + dto.getProperties().forEach((s, s1) -> objectBuilder.add(NAMESPACE_EDC + s, s1)); + builder.add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_PROPERTIES, objectBuilder); + } + + if (dto.getPrivateProperties() != null && !dto.getPrivateProperties().isEmpty()) { + final JsonObjectBuilder objectBuilder = jsonFactory.createObjectBuilder(); + dto.getPrivateProperties().forEach((s, s1) -> objectBuilder.add(NAMESPACE_EDC + s, s1)); + builder.add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_PRIVATE_PROPERTIES, objectBuilder); + } + return builder.build(); + } + + private JsonArrayBuilder asArray(final List callbackAddresses, final TransformerContext context) { + final JsonArrayBuilder arrayBuilder = Objects.requireNonNull(this.jsonFactory.createArrayBuilder()); + callbackAddresses.stream() + .map(callbackAddress -> context.transform(callbackAddress, JsonObject.class)) + .forEach(arrayBuilder::add); + return arrayBuilder; + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectToNegotiationResponseTransformer.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectToNegotiationResponseTransformer.java new file mode 100644 index 0000000000..1dcea5cb17 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectToNegotiationResponseTransformer.java @@ -0,0 +1,75 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.jsontransformer; + +import jakarta.json.JsonObject; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.NegotiationResponse; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Transformer to convert JSON-LD to NegotiationResponse. + */ +public class JsonObjectToNegotiationResponseTransformer + extends AbstractJsonLdTransformer { + + public static final String CONTRACT_NEGOTIATION_AGREEMENT_ID = "https://w3id.org/edc/v0.0.1/ns/contractAgreementId"; + public static final String CONTRACT_NEGOTIATION_COUNTERPARTY_ADDR = "https://w3id.org/edc/v0.0.1/ns/counterPartyAddress"; + public static final String CONTRACT_NEGOTIATION_ERRORDETAIL = "https://w3id.org/edc/v0.0.1/ns/errorDetail"; + public static final String CONTRACT_NEGOTIATION_PROTOCOL = "https://w3id.org/edc/v0.0.1/ns/protocol"; + public static final String CONTRACT_NEGOTIATION_STATE = "https://w3id.org/edc/v0.0.1/ns/state"; + public static final String CONTRACT_NEGOTIATION_NEG_TYPE = "https://w3id.org/edc/v0.0.1/ns/type"; + public static final String CONTRACT_NEGOTIATION_CALLBACK_ADDR = "https://w3id.org/edc/v0.0.1/ns/callbackAddresses"; + public static final String CONTRACT_NEGOTIATION_ID = "@id"; + + public JsonObjectToNegotiationResponseTransformer() { + super(JsonObject.class, NegotiationResponse.class); + } + + @Override + public @Nullable NegotiationResponse transform(@NotNull final JsonObject jsonObject, + @NotNull final TransformerContext transformerContext) { + final NegotiationResponse.NegotiationResponseBuilder builder = NegotiationResponse.builder(); + jsonObject.forEach((key, value) -> { + switch (key) { + case CONTRACT_NEGOTIATION_ID -> builder.responseId(this.transformString(value, transformerContext)); + case CONTRACT_NEGOTIATION_NEG_TYPE -> builder.type(this.transformString(value, transformerContext)); + case CONTRACT_NEGOTIATION_PROTOCOL -> builder.protocol(this.transformString(value, transformerContext)); + + case CONTRACT_NEGOTIATION_STATE -> builder.state(this.transformString(value, transformerContext)); + + case CONTRACT_NEGOTIATION_COUNTERPARTY_ADDR -> builder.counterPartyAddress(this.transformString(value, transformerContext)); + + case CONTRACT_NEGOTIATION_AGREEMENT_ID -> builder.contractAgreementId(this.transformString(value, transformerContext)); + case CONTRACT_NEGOTIATION_CALLBACK_ADDR -> builder.callbackAddresses(this.transformArray(value, String.class, transformerContext)); + case CONTRACT_NEGOTIATION_ERRORDETAIL -> builder.errorDetail(this.transformString(value, transformerContext)); + default -> { + // Do nothing in case no key matches + } + } + }); + return builder.build(); + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectToNegotiationStateTransformer.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectToNegotiationStateTransformer.java new file mode 100644 index 0000000000..cbbc2b8162 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/jsontransformer/JsonObjectToNegotiationStateTransformer.java @@ -0,0 +1,53 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.jsontransformer; + +import jakarta.json.JsonObject; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.NegotiationState; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Transformer to convert JSON-LD to NegotiationState. + */ +public class JsonObjectToNegotiationStateTransformer extends AbstractJsonLdTransformer { + public static final String CONTRACT_NEGOTIATION_STATE = "https://w3id.org/edc/v0.0.1/ns/state"; + + protected JsonObjectToNegotiationStateTransformer() { + super(JsonObject.class, NegotiationState.class); + } + + @Override + public @Nullable NegotiationState transform(@NotNull final JsonObject jsonObject, + @NotNull final TransformerContext transformerContext) { + final NegotiationState.NegotiationStateBuilder builder = NegotiationState.builder(); + jsonObject.forEach((key, value) -> { + if (CONTRACT_NEGOTIATION_STATE.equals(key)) { + builder.state(this.transformString(value, transformerContext)); + } + }); + return builder.build(); + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiation.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiation.java deleted file mode 100644 index 9852d86d1f..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiation.java +++ /dev/null @@ -1,319 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.negotiation; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.agreement.ContractAgreement; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.offer.ContractOffer; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.UNSAVED; - -/** - * Represents a contract negotiation. - *

- * Note: This class implements the negotiation process that is started by a consumer. For some use - * cases, it may be interesting to initiate the contract negotiation as a provider. - * - *

- * TODO: This is only placeholder - * TODO: Implement state transitions - * TODO: Add error details - */ -@JsonTypeName("dataspaceconnector:contractnegotiation") -@JsonDeserialize(builder = ContractNegotiation.Builder.class) -public class ContractNegotiation implements TraceCarrier { - private String id; - private String correlationId; - private String counterPartyId; - private String counterPartyAddress; - private String protocol; - private Type type = Type.CONSUMER; - private int state = UNSAVED.code(); - private int stateCount; - private long stateTimestamp; - private String errorDetail; - private ContractAgreement contractAgreement; - private List contractOffers = new ArrayList<>(); - private Map traceContext = new HashMap<>(); - - public Type getType() { - return type; - } - - public String getId() { - return id; - } - - public String getCounterPartyId() { - return counterPartyId; - } - - public String getCounterPartyAddress() { - return counterPartyAddress; - } - - /** - * Returns the correlation id sent by the client or null if this is a client-side negotiation. - */ - public String getCorrelationId() { - return correlationId; - } - - /** - * Returns the data protocol used for this negotiation. - * - * @return The protocol. - */ - @NotNull - public String getProtocol() { - return protocol; - } - - @Override - public Map getTraceContext() { - return Collections.unmodifiableMap(traceContext); - } - - /** - * Returns the current negotiation state. - * - * @return The current state code. - */ - public int getState() { - return state; - } - - /** - * Returns the current state count. - * - * @return The current state count. - */ - public int getStateCount() { - return stateCount; - } - - /** - * Returns the state timestamp. - * - * @return The state timestamp. - */ - public long getStateTimestamp() { - return stateTimestamp; - } - - /** - * Returns all contract offers which have been part of the negotiation process. - * - * @return The contract offers. - */ - public List getContractOffers() { - return contractOffers; - } - - /** - * Adds a new contract offer to this negotiation. - * - * @param offer The offer to add. - */ - public void addContractOffer(ContractOffer offer) { - contractOffers.add(offer); - } - - /** - * Returns the error detail. - * - * @return The error detail - */ - public String getErrorDetail() { - return errorDetail; - } - - /** - * Sets the error detail. - * - * @param errorDetail The error detail. - */ - public void setErrorDetail(String errorDetail) { - this.errorDetail = errorDetail; - } - - /** - * Returns the last offer in the list of contract offers. - */ - public ContractOffer getLastContractOffer() { - var size = contractOffers.size(); - if (size == 0) { - return null; - } - return contractOffers.get(size - 1); - } - - /** - * Returns the finalized agreement or null if the negotiation has not been confirmed. - */ - public ContractAgreement getContractAgreement() { - return contractAgreement; - } - - /** - * Sets the agreement for this negotiation. - * - * @param agreement the agreement. - */ - public void setContractAgreement(ContractAgreement agreement) { - contractAgreement = agreement; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ContractNegotiation that = (ContractNegotiation) o; - return state == that.state && stateCount == that.stateCount && stateTimestamp == that.stateTimestamp && Objects.equals(id, that.id) && - Objects.equals(correlationId, that.correlationId) && Objects.equals(counterPartyId, that.counterPartyId) && - Objects.equals(protocol, that.protocol) && Objects.equals(traceContext, that.traceContext) && - type == that.type && Objects.equals(contractAgreement, that.contractAgreement) && Objects.equals(contractOffers, that.contractOffers); - } - - @Override - public int hashCode() { - return Objects.hash(id, correlationId, counterPartyId, protocol, traceContext, type, state, stateCount, stateTimestamp, contractAgreement, contractOffers); - } - - public enum Type { - CONSUMER, PROVIDER - } - - /** - * Builder for ContractNegotiation. - */ - @JsonPOJOBuilder(withPrefix = "") - public static class Builder { - private final ContractNegotiation negotiation; - - private Builder() { - negotiation = new ContractNegotiation(); - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - negotiation.id = id; - return this; - } - - public Builder protocol(String protocol) { - negotiation.protocol = protocol; - return this; - } - - public Builder state(int state) { - negotiation.state = state; - return this; - } - - public Builder stateCount(int stateCount) { - negotiation.stateCount = stateCount; - return this; - } - - public Builder stateTimestamp(long stateTimestamp) { - negotiation.stateTimestamp = stateTimestamp; - return this; - } - - public Builder counterPartyId(String id) { - negotiation.counterPartyId = id; - return this; - } - - public Builder counterPartyAddress(String address) { - negotiation.counterPartyAddress = address; - return this; - } - - public Builder correlationId(String id) { - negotiation.correlationId = id; - return this; - } - - public Builder contractAgreement(ContractAgreement agreement) { - negotiation.contractAgreement = agreement; - return this; - } - - //used mainly for JSON deserialization - public Builder contractOffers(List contractOffers) { - negotiation.contractOffers = contractOffers; - return this; - } - - public Builder contractOffer(ContractOffer contractOffer) { - negotiation.contractOffers.add(contractOffer); - return this; - } - - public Builder type(Type type) { - negotiation.type = type; - return this; - } - - public Builder errorDetail(String errorDetail) { - negotiation.errorDetail = errorDetail; - return this; - } - - public Builder traceContext(Map traceContext) { - negotiation.traceContext = traceContext; - return this; - } - - public ContractNegotiation build() { - Objects.requireNonNull(negotiation.id); - Objects.requireNonNull(negotiation.counterPartyId); - Objects.requireNonNull(negotiation.counterPartyAddress); - Objects.requireNonNull(negotiation.protocol); - if (Type.PROVIDER == negotiation.type) { - Objects.requireNonNull(negotiation.correlationId); - } - return negotiation; - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiationStates.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiationStates.java deleted file mode 100644 index 66c0434bef..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiationStates.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.negotiation; - -import java.util.Arrays; - -/** - * Defines the states a contract negotiation can be in. - */ -public enum ContractNegotiationStates { - - UNSAVED(0), - INITIAL(50), - REQUESTING(100), - REQUESTED(200), - PROVIDER_OFFERING(300), - PROVIDER_OFFERED(400), - CONSUMER_OFFERING(500), - CONSUMER_OFFERED(600), - CONSUMER_APPROVING(700), - CONSUMER_APPROVED(800), - DECLINING(900), - DECLINED(1000), - CONFIRMING(1100), - CONFIRMED(1200), - ERROR(-1); - - private final int code; - - ContractNegotiationStates(int code) { - this.code = code; - } - - public static ContractNegotiationStates from(int code) { - return Arrays.stream(values()).filter(tps -> tps.code == code).findFirst().orElse(null); - } - - public int code() { - return code; - } - -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractOfferDescription.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractOfferDescription.java new file mode 100644 index 0000000000..b25d3e7f04 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractOfferDescription.java @@ -0,0 +1,48 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.negotiation; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Positive; +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; +import org.eclipse.edc.policy.model.Policy; + +/** + * EDC Contract Offer Description. + */ +@Value +@Builder(toBuilder = true) +@Jacksonized +public class ContractOfferDescription { + public static final String CONTRACT_OFFER_TYPE = "https://w3id.org/edc/v0.0.1/ns/ContractOfferDescription"; + public static final String CONTRACT_OFFER_OFFER_ID = "https://w3id.org/edc/v0.0.1/ns/offerId"; + public static final String CONTRACT_OFFER_ASSET_ID = "https://w3id.org/edc/v0.0.1/ns/assetId"; + public static final String CONTRACT_OFFER_POLICY = "https://w3id.org/edc/v0.0.1/ns/policy"; + @NotBlank(message = "offerId is mandatory") String offerId; + @NotBlank(message = "assetId is mandatory") String assetId; + @NotNull(message = "policy cannot be null") Policy policy; + @Positive(message = "validity must be positive") long validity; +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractRejection.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractRejection.java deleted file mode 100644 index b11b772ece..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractRejection.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.negotiation; - - -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.message.RemoteMessage; - -import java.util.Objects; - -public class ContractRejection implements RemoteMessage { - - private String protocol; - private String connectorId; - private String connectorAddress; - private String correlationId; // TODO hand over the contract offer/agreement - not an id? - private String rejectionReason; // TODO pre-define a set of enums (+ mapping to IDS) ? - - @Override - public String getProtocol() { - return protocol; - } - - - public String getConnectorAddress() { - return connectorAddress; - } - - public String getConnectorId() { - return connectorId; - } - - public String getCorrelationId() { - return correlationId; - } - - public String getRejectionReason() { - return rejectionReason; - } - - public static class Builder { - private final ContractRejection contractRejection; - - private Builder() { - this.contractRejection = new ContractRejection(); - } - - public static Builder newInstance() { - return new Builder(); - } - - public Builder protocol(String protocol) { - this.contractRejection.protocol = protocol; - return this; - } - - public Builder connectorId(String connectorId) { - this.contractRejection.connectorId = connectorId; - return this; - } - - public Builder connectorAddress(String connectorAddress) { - this.contractRejection.connectorAddress = connectorAddress; - return this; - } - - public Builder correlationId(String correlationId) { - this.contractRejection.correlationId = correlationId; - return this; - } - - public Builder rejectionReason(String rejectionReason) { - this.contractRejection.rejectionReason = rejectionReason; - return this; - } - - public ContractRejection build() { - Objects.requireNonNull(contractRejection.protocol, "protocol"); - Objects.requireNonNull(contractRejection.connectorId, "connectorId"); - Objects.requireNonNull(contractRejection.connectorAddress, "connectorAddress"); - Objects.requireNonNull(contractRejection.correlationId, "correlationId"); - Objects.requireNonNull(contractRejection.rejectionReason, "rejectionReason"); - return contractRejection; - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/NegotiationRequest.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/NegotiationRequest.java new file mode 100644 index 0000000000..c761498129 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/NegotiationRequest.java @@ -0,0 +1,65 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.negotiation; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; + +import java.util.ArrayList; +import java.util.List; + +/** + * EDC negotiation request. + */ +@Value +@Builder(toBuilder = true) +@Jacksonized +public class NegotiationRequest { + public static final String NEGOTIATION_CONNECTOR_ADDRESS = "https://w3id.org/edc/v0.0.1/ns/connectorAddress"; + public static final String NEGOTIATION_PROTOCOL = "https://w3id.org/edc/v0.0.1/ns/protocol"; + public static final String NEGOTIATION_CONNECTOR_ID = "https://w3id.org/edc/v0.0.1/ns/connectorId"; + public static final String NEGOTIATION_PROVIDER_ID = "https://w3id.org/edc/v0.0.1/ns/providerId"; + public static final String NEGOTIATION_CONSUMER_ID = "https://w3id.org/edc/v0.0.1/ns/consumerId"; + public static final String NEGOTIATION_OFFER = "https://w3id.org/edc/v0.0.1/ns/offer"; + public static final String NEGOTIATION_CALLBACK_ADDRESSES = "https://w3id.org/edc/v0.0.1/ns/callbackAddresses"; + public static final String NEGOTIATION_OFFER_ID = "https://w3id.org/edc/v0.0.1/ns/offerId"; + public static final String NEGOTIATION_ASSET_ID = "https://w3id.org/edc/v0.0.1/ns/assetId"; + public static final String NEGOTIATION_POLICY = "https://w3id.org/edc/v0.0.1/ns/policy"; + + @NotBlank(message = "connectorAddress is mandatory") + String connectorAddress; + @NotBlank(message = "protocol is mandatory") + String protocol; + @NotBlank(message = "connectorId is mandatory") + String connectorId; + @NotNull(message = "offer cannot be null") + ContractOfferDescription offer; + String providerId; + String consumerId; + List callbackAddresses = new ArrayList<>(); +} + diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/NegotiationResponse.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/NegotiationResponse.java new file mode 100644 index 0000000000..b083c72904 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/NegotiationResponse.java @@ -0,0 +1,52 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.negotiation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.ToString; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +import java.util.List; + +/** + * EDC negotiation response. + */ +@ToString +@Value +@Builder(toBuilder = true) +@Jacksonized +public class NegotiationResponse { + + @JsonProperty("id") + String responseId; + String contractAgreementId; + String counterPartyAddress; + String errorDetail; + String protocol; + String state; + String type; + List callbackAddresses; + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/TraceCarrier.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/NegotiationState.java similarity index 61% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/TraceCarrier.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/NegotiationState.java index e0ae376d17..d26fcc9c47 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/TraceCarrier.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/NegotiationState.java @@ -1,15 +1,17 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * 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. - * + * 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 @@ -18,18 +20,18 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ - package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation; -import java.util.Map; +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; /** - * Interface for trace context carrier entities. - *

- * Use in combination with the various overloads of {@link TraceCarrier} to propagate the tracing context stored in the entity to the current thread. + * EDC negotiation state response. */ -public interface TraceCarrier { - - Map getTraceContext(); - +@Value +@Builder(toBuilder = true) +@Jacksonized +public class NegotiationState { + String state; } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/Response.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/Response.java new file mode 100644 index 0000000000..695009a159 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/Response.java @@ -0,0 +1,39 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.negotiation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +/** + * Contains an EDC contract negotiation ID. + */ +@Value +@Builder(toBuilder = true) +@Jacksonized +public class Response { + @JsonProperty("@id") + String responseId; +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractNegotiationDto.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractNegotiationDto.java deleted file mode 100644 index bf31d0ca81..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractNegotiationDto.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.notification; - - import com.fasterxml.jackson.annotation.JsonCreator; - import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; - import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiation; - - @JsonDeserialize(builder = ContractNegotiationDto.Builder.class) - public class ContractNegotiationDto { - private String contractAgreementId; // is null until state == CONFIRMED - private String counterPartyAddress; - private String errorDetail; - private String id; - private String protocol = "ids-multipart"; - private String state; - private ContractNegotiation.Type type = ContractNegotiation.Type.CONSUMER; - - private ContractNegotiationDto() { - } - - public String getId() { - return id; - } - - public String getCounterPartyAddress() { - return counterPartyAddress; - } - - public String getProtocol() { - return protocol; - } - - public ContractNegotiation.Type getType() { - return type; - } - - public String getState() { - return state; - } - - public String getErrorDetail() { - return errorDetail; - } - - public String getContractAgreementId() { - return contractAgreementId; - } - - @JsonPOJOBuilder(withPrefix = "") - public static final class Builder { - private final ContractNegotiationDto dto; - - private Builder() { - dto = new ContractNegotiationDto(); - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - dto.id = id; - return this; - } - - public Builder counterPartyAddress(String counterPartyAddress) { - dto.counterPartyAddress = counterPartyAddress; - return this; - } - - public Builder protocol(String protocol) { - dto.protocol = protocol; - return this; - } - - public Builder state(String state) { - dto.state = state; - return this; - } - - public Builder errorDetail(String errorDetail) { - dto.errorDetail = errorDetail; - return this; - } - - public Builder contractAgreementId(String contractAgreementId) { - dto.contractAgreementId = contractAgreementId; - return this; - } - - public Builder type(ContractNegotiation.Type type) { - dto.type = type; - return this; - } - - public ContractNegotiationDto build() { - return dto; - } - } - } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractOfferDescription.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractOfferDescription.java deleted file mode 100644 index 0f4b87a6a4..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractOfferDescription.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.notification; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; - -public class ContractOfferDescription { - private final String offerId; - private final String assetId; - private final String policyId; - private final Policy policy; - - @JsonCreator - public ContractOfferDescription(@JsonProperty("offerId") String offerId, @JsonProperty("assetId") String assetId, @JsonProperty("policyId") String policyId, @JsonProperty("policy") Policy policy) { - this.offerId = offerId; - this.assetId = assetId; - this.policyId = policyId; - this.policy = policy; - } - - public String getOfferId() { - return this.offerId; - } - - public String getAssetId() { - return this.assetId; - } - - public String getPolicyId() { - return this.policyId; - } - - public Policy getPolicy() { - return this.policy; - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/EdcNotification.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/EdcNotification.java new file mode 100644 index 0000000000..748494b643 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/EdcNotification.java @@ -0,0 +1,52 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.notification; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * A notification to send over EDC. + */ +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Data +public class EdcNotification { + + @Valid + @NotNull + @Schema(description = "Header of the EDC notification", implementation = EdcNotificationHeader.class) + private EdcNotificationHeader header; + + @NotNull + private Map content; + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/EdcNotificationHeader.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/EdcNotificationHeader.java new file mode 100644 index 0000000000..e412423bbf --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/EdcNotificationHeader.java @@ -0,0 +1,58 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.notification; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * EDC notification header + */ +@Schema(description = "EDC notification header information") +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Data +public class EdcNotificationHeader { + + @NotBlank + private String notificationId; + @NotBlank + private String senderBpn; + @NotBlank + private String recipientBpn; + + private String senderEdc; + + private String replyAssetId; + private String replyAssetSubPath; + + private String originalNotificationId; + @NotBlank + private String notificationType; + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/Polymorphic.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/EdcNotificationResponse.java similarity index 63% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/Polymorphic.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/EdcNotificationResponse.java index 3a2e8ae86e..ceb41eaa5b 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/Polymorphic.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/EdcNotificationResponse.java @@ -1,15 +1,17 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * 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. - * + * 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 @@ -18,14 +20,11 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ - -package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transfer; - -import com.fasterxml.jackson.annotation.JsonTypeInfo; +package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.notification; /** - * Types implement this interface for polymorphic de/serialization support. + * Contains the result of a sent notification. */ -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "edctype") -public interface Polymorphic { +public interface EdcNotificationResponse { + boolean deliveredSuccessfully(); } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationId.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationId.java deleted file mode 100644 index c868bac14f..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationId.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.notification; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; - - -@JsonDeserialize(builder = NegotiationId.Builder.class) -public class NegotiationId { - private String id; - - private NegotiationId() { - } - - public String getId() { - return id; - } - - @JsonPOJOBuilder(withPrefix = "") - public static final class Builder { - private final NegotiationId dto; - - private Builder() { - dto = new NegotiationId(); - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - dto.id = id; - return this; - } - - public NegotiationId build() { - return dto; - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationInitiateRequestDto.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationInitiateRequestDto.java deleted file mode 100644 index 54dbab0e4d..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationInitiateRequestDto.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.notification; - -import org.jetbrains.annotations.NotNull; - -public class NegotiationInitiateRequestDto { - - private String connectorAddress; - private String protocol = "ids-multipart"; - private String connectorId; - private ContractOfferDescription offer; - - private NegotiationInitiateRequestDto() { - - } - - public String getConnectorAddress() { - return connectorAddress; - } - - public String getProtocol() { - return protocol; - } - - public String getConnectorId() { - return connectorId; - } - - public @NotNull ContractOfferDescription getOffer() { - return offer; - } - - public static final class Builder { - private final NegotiationInitiateRequestDto dto; - - private Builder() { - dto = new NegotiationInitiateRequestDto(); - } - - public static Builder newInstance() { - return new Builder(); - } - - public Builder connectorAddress(String connectorAddress) { - dto.connectorAddress = connectorAddress; - return this; - } - - public Builder protocol(String protocol) { - dto.protocol = protocol; - return this; - } - - public Builder connectorId(String connectorId) { - dto.connectorId = connectorId; - return this; - } - - public Builder offerId(ContractOfferDescription offerId) { - dto.offer = offerId; - return this; - } - - public NegotiationInitiateRequestDto build() { - return dto; - } - } -} - diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/TransferId.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/TransferId.java deleted file mode 100644 index 2198c423f8..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/TransferId.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.notification; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; - - -@JsonDeserialize(builder = TransferId.Builder.class) -public class TransferId { - private String id; - - private TransferId() { - } - - public String getId() { - return id; - } - - @JsonPOJOBuilder(withPrefix = "") - public static final class Builder { - private final TransferId dto; - - private Builder() { - dto = new TransferId(); - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - dto.id = id; - return this; - } - - public TransferId build() { - return dto; - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/offer/ContractDefinition.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/offer/ContractDefinition.java deleted file mode 100644 index 95b76908d7..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/offer/ContractDefinition.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.offer; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.AssetSelectorExpression; -import org.jetbrains.annotations.NotNull; - -import java.util.Objects; - -@JsonDeserialize(builder = ContractDefinition.Builder.class) -public class ContractDefinition { - private String id; - private String accessPolicyId; - private String contractPolicyId; - private AssetSelectorExpression selectorExpression; - - private ContractDefinition() { - } - - public String getId() { - return id; - } - - @NotNull - public String getAccessPolicyId() { - return accessPolicyId; - } - - @NotNull - public String getContractPolicyId() { - return contractPolicyId; - } - - @NotNull - public AssetSelectorExpression getSelectorExpression() { - return selectorExpression; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ContractDefinition that = (ContractDefinition) o; - return Objects.equals(id, that.id) && Objects.equals(accessPolicyId, that.accessPolicyId) && Objects.equals(contractPolicyId, that.contractPolicyId) && Objects.equals(selectorExpression, that.selectorExpression); - } - - @Override - public int hashCode() { - return Objects.hash(id, accessPolicyId, contractPolicyId, selectorExpression); - } - - @JsonPOJOBuilder(withPrefix = "") - public static class Builder { - private final ContractDefinition definition; - - private Builder() { - definition = new ContractDefinition(); - } - - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - definition.id = id; - return this; - } - - public Builder accessPolicyId(String policyId) { - definition.accessPolicyId = policyId; - return this; - } - - public Builder contractPolicyId(String policyId) { - definition.contractPolicyId = policyId; - return this; - } - - public Builder selectorExpression(AssetSelectorExpression expression) { - definition.selectorExpression = expression; - return this; - } - - public ContractDefinition build() { - Objects.requireNonNull(definition.id); - Objects.requireNonNull(definition.accessPolicyId); - Objects.requireNonNull(definition.contractPolicyId); - Objects.requireNonNull(definition.selectorExpression); - return definition; - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/offer/ContractOffer.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/offer/ContractOffer.java deleted file mode 100644 index 51ba963633..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/offer/ContractOffer.java +++ /dev/null @@ -1,253 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.offer; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.net.URI; -import java.time.ZonedDateTime; -import java.util.Objects; - -/** - * A contract offer is exchanged between two participant agents. It describes the which assets the consumer may use, and - * the rules and policies that apply to each asset. - */ -@JsonDeserialize(builder = ContractOffer.Builder.class) -public class ContractOffer { - private String id; - - /** - * The policy that describes the usage conditions of the assets - */ - private Policy policy; - - /** - * The offered asset - * Must be mutually exclusive with {@link ContractOffer#getAssetId()} ()} - */ - private Asset asset; - /** - * Refers to the asset that is offered. Note that this is only to be used during the actual negotiation and cannot - * be - * used in the initial offer from the provider to the consumer. - * Must be mutually exclusive with {@link ContractOffer#getAsset()} - */ - private String assetId; - /** - * The participant who provides the offered data - */ - private URI provider; - /** - * The participant consuming the offered data - */ - private URI consumer; - /** - * Timestamp defining the start time when the offer becomes effective - */ - private ZonedDateTime offerStart; - /** - * Timestamp defining the end date when the offer becomes ineffective - */ - private ZonedDateTime offerEnd; - /** - * Timestamp defining the start date when the contract becomes effective - */ - private ZonedDateTime contractStart; - /** - * Timestamp defining the end date when the contract becomes terminated - */ - private ZonedDateTime contractEnd; - - @Nullable - public String getAssetId() { - return assetId; - } - - @NotNull - public String getId() { - return id; - } - - @Nullable - public URI getProvider() { - return provider; - } - - @Nullable - public URI getConsumer() { - return consumer; - } - - @Nullable - public ZonedDateTime getOfferStart() { - return offerStart; - } - - @Nullable - public ZonedDateTime getOfferEnd() { - return offerEnd; - } - - @Nullable - public ZonedDateTime getContractStart() { - return contractStart; - } - - @Nullable - public ZonedDateTime getContractEnd() { - return contractEnd; - } - - @NotNull - public Asset getAsset() { - return asset; - } - - @Nullable - public Policy getPolicy() { - return policy; - } - - - @Override - public int hashCode() { - return Objects.hash(id, policy, asset, provider, consumer, offerStart, offerEnd, contractStart, contractEnd); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ContractOffer that = (ContractOffer) o; - return Objects.equals(id, that.id) && Objects.equals(policy, that.policy) && Objects.equals(asset, that.asset) && Objects.equals(provider, that.provider) && - Objects.equals(consumer, that.consumer) && Objects.equals(offerStart, that.offerStart) && Objects.equals(offerEnd, that.offerEnd) && - Objects.equals(contractStart, that.contractStart) && Objects.equals(contractEnd, that.contractEnd); - } - - @JsonPOJOBuilder(withPrefix = "") - public static final class Builder { - private Asset asset; - private Policy policy; - private String id; - private URI provider; - private URI consumer; - private ZonedDateTime offerStart; - private ZonedDateTime offerEnd; - private ZonedDateTime contractStart; - private ZonedDateTime contractEnd; - private String assetId; - - private Builder() { - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - this.id = id; - return this; - } - - public Builder provider(URI provider) { - this.provider = provider; - return this; - } - - public Builder consumer(URI consumer) { - this.consumer = consumer; - return this; - } - - public Builder asset(Asset asset) { - this.asset = asset; - return this; - } - - public Builder offerStart(ZonedDateTime date) { - offerStart = date; - return this; - } - - public Builder offerEnd(ZonedDateTime date) { - offerEnd = date; - return this; - } - - public Builder contractStart(ZonedDateTime date) { - contractStart = date; - return this; - } - - public Builder contractEnd(ZonedDateTime date) { - contractEnd = date; - return this; - } - - public Builder policy(Policy policy) { - this.policy = policy; - return this; - } - - - public Builder assetId(String assetId) { - this.assetId = assetId; - return this; - } - - public ContractOffer build() { - Objects.requireNonNull(id); - - if (assetId != null && asset != null) { - throw new IllegalArgumentException("Asset and AssetId are mutually exclusive"); - } - - if (policy == null) { - throw new IllegalArgumentException("Policy must not be null!"); - } - - ContractOffer offer = new ContractOffer(); - offer.id = id; - offer.policy = policy; - offer.asset = asset; - offer.provider = provider; - offer.consumer = consumer; - offer.offerStart = offerStart; - offer.offerEnd = offerEnd; - offer.contractStart = contractStart; - offer.contractEnd = contractEnd; - offer.assetId = assetId; - return offer; - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/policy/PolicyDefinition.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/policy/PolicyDefinition.java new file mode 100644 index 0000000000..d680945bc4 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/policy/PolicyDefinition.java @@ -0,0 +1,42 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.policy; + +import lombok.Builder; +import lombok.Data; + +/** + * Policy Definition that is accepted by IRS. + */ +@Builder +@Data +public class PolicyDefinition { + + private String permissionActionType; + private String constraintType; + private String leftExpressionValue; + private String rightExpressionValue; + private String constraintOperator; + + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/query/Criterion.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/query/Criterion.java deleted file mode 100644 index d3e315e6b4..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/query/Criterion.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.query; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -import java.util.function.Function; - -import static java.lang.String.format; - -/** - * This class can be used to form select expressions e.g. in SQL statements. It is a way to express - * those statements in a generic way. - * For example: - *

- * "operandLeft" = "name",
- * "operator" = "=",
- * "operandRight" = "someone"
- * 
- *

- * can be translated to {@code [select * where name = someone]} - */ -public class Criterion { - @JsonProperty("left") - private Object operandLeft; - @JsonProperty("op") - private String operator; - @JsonProperty("right") - private Object operandRight; - - private Criterion() { - //for json serialization - } - - public Criterion(Object left, String op, Object right) { - operandLeft = Objects.requireNonNull(left); - operator = Objects.requireNonNull(op); - operandRight = right; // null may be allowed, for example when the operator is unary, like NOT_NULL - } - - public Object getOperandLeft() { - return operandLeft; - } - - public String getOperator() { - return operator; - } - - public Object getOperandRight() { - return operandRight; - } - - public Criterion withLeftOperand(Function function) { - return new Criterion(function.apply(this.operandLeft), this.operator, this.getOperandRight()); - } - - @Override - public int hashCode() { - return Objects.hash(operandLeft, operator, operandRight); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Criterion criterion = (Criterion) o; - return Objects.equals(operandLeft, criterion.operandLeft) && Objects.equals(operator, criterion.operator) && Objects.equals(operandRight, criterion.operandRight); - } - - @Override - public String toString() { - return format("%s %s %s", getOperandLeft(), getOperator(), getOperandRight()); - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataAddress.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataAddress.java deleted file mode 100644 index a0f54d4e46..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataAddress.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.transfer; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import org.jetbrains.annotations.NotNull; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * An address that can be used resolve a data location. Data addresses are used throughout the system. For example, an asset has a data address used to resolve its contents, - * which may be in an external store. A data address can also be used as a destination to send data during a transfer. - *

- * This type is extensible as different properties may be required to resolve data. For example, an HTTP data address will require a URL. Data addresses may also contain - * references to information required to access the address, for example, the name of a shared token. Note, however, secrets should never be stored as properties as they may be - * compromised if the data address is serialized. - */ -@JsonDeserialize(builder = DataAddress.Builder.class) -public class DataAddress { - public static final String TYPE = "type"; - private static final String KEYNAME = "keyName"; - private final Map properties = new HashMap<>(); - - private DataAddress() { - } - - @NotNull - public String getType() { - return properties.get(TYPE); - } - - @JsonIgnore - public void setType(String type) { - Objects.requireNonNull(type); - properties.put(TYPE, type); - } - - public String getProperty(String key) { - return properties.get(key); - } - - public Map getProperties() { - return properties; - } - - public String getKeyName() { - return properties.get(KEYNAME); - } - - @JsonIgnore - public void setKeyName(String keyName) { - Objects.requireNonNull(keyName); - properties.put(KEYNAME, keyName); - } - - @JsonPOJOBuilder(withPrefix = "") - public static class Builder { - private final DataAddress address; - - private Builder() { - address = new DataAddress(); - } - - @JsonCreator() - public static Builder newInstance() { - return new Builder(); - } - - public Builder type(String type) { - address.properties.put(TYPE, Objects.requireNonNull(type)); - return this; - } - - public Builder property(String key, String value) { - Objects.requireNonNull(key, "Property key null."); - address.properties.put(key, value); - return this; - } - - public Builder properties(Map properties) { - properties.forEach(this::property); - return this; - } - - public Builder keyName(String keyName) { - address.getProperties().put(KEYNAME, Objects.requireNonNull(keyName)); - return this; - } - - public DataAddress build() { - Objects.requireNonNull(address.getType(), "DataAddress builder missing Type property."); - return address; - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataFlowRequest.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataFlowRequest.java deleted file mode 100644 index deba9d084a..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataFlowRequest.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.transfer; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.TraceCarrier; - -import java.util.Map; -import java.util.Objects; - -/** - * A request to transfer data from a source to destination. - */ -@JsonTypeName("dataspaceconnector:dataflowrequest") -@JsonDeserialize(builder = DataFlowRequest.Builder.class) -public class DataFlowRequest implements Polymorphic, TraceCarrier { - private String id; - private String processId; - - private DataAddress sourceDataAddress; - private DataAddress destinationDataAddress; - - private boolean trackable; - - private Map properties = Map.of(); - private Map traceContext = Map.of(); - - private DataFlowRequest() { - } - - /** - * The unique request id. Request ids are provided by the originating consumer and must be unique. - */ - public String getId() { - return id; - } - - /** - * Returns the process id this request is associated with. - */ - public String getProcessId() { - return processId; - } - - /** - * The source address of the data. - */ - public DataAddress getSourceDataAddress() { - return sourceDataAddress; - } - - /** - * The target address the data is to be sent to. - */ - public DataAddress getDestinationDataAddress() { - return destinationDataAddress; - } - - /** - * Returns true if the request must be tracked for delivery guarantees. - */ - public boolean isTrackable() { - return trackable; - } - - /** - * Custom properties that are passed to the provider connector. - */ - public Map getProperties() { - return properties; - } - - /** - * Trace context for this request - */ - @Override - public Map getTraceContext() { - return traceContext; - } - - /** - * A builder initialized with the current DataFlowRequest - */ - public Builder toBuilder() { - return new Builder(this); - } - - @JsonPOJOBuilder(withPrefix = "") - public static class Builder { - private final DataFlowRequest request; - - private Builder() { - this(new DataFlowRequest()); - } - - private Builder(DataFlowRequest request) { - this.request = request; - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - request.id = id; - return this; - } - - public Builder processId(String id) { - request.processId = id; - return this; - } - - public Builder destinationType(String type) { - if (request.destinationDataAddress == null) { - request.destinationDataAddress = DataAddress.Builder.newInstance().type(type).build(); - } else { - request.destinationDataAddress.setType(type); - } - return this; - } - - public Builder sourceDataAddress(DataAddress destination) { - request.sourceDataAddress = destination; - return this; - } - - public Builder destinationDataAddress(DataAddress destination) { - request.destinationDataAddress = destination; - return this; - } - - public Builder trackable(boolean value) { - request.trackable = value; - return this; - } - - public Builder properties(Map value) { - request.properties = value == null ? null : Map.copyOf(value); - return this; - } - - public Builder traceContext(Map value) { - request.traceContext = value; - return this; - } - - public DataFlowRequest build() { - Objects.requireNonNull(request.processId, "processId"); - Objects.requireNonNull(request.sourceDataAddress, "sourceDataAddress"); - Objects.requireNonNull(request.destinationDataAddress, "destinationDataAddress"); - Objects.requireNonNull(request.traceContext, "traceContext"); - return request; - } - - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferRequestDto.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferRequestDto.java deleted file mode 100644 index 77e28581f5..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferRequestDto.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.transfer; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; - -import jakarta.validation.constraints.NotNull; -import java.util.HashMap; -import java.util.Map; - -@JsonDeserialize(builder = TransferRequestDto.Builder.class) -public class TransferRequestDto { - - @NotNull - private String connectorAddress; - @NotNull - private String id; - @NotNull - private String contractId; - @NotNull - private DataAddress dataDestination; - private boolean managedResources = true; - private Map properties = new HashMap<>(); - @NotNull - private TransferType transferType = new TransferType(); - @NotNull - private String protocol = "ids-multipart"; - @NotNull - private String connectorId; - @NotNull - private String assetId; - - public String getConnectorAddress() { - return connectorAddress; - } - - public String getId() { - return id; - } - - public String getContractId() { - return contractId; - } - - public DataAddress getDataDestination() { - return dataDestination; - } - - public boolean isManagedResources() { - return managedResources; - } - - public Map getProperties() { - return properties; - } - - public TransferType getTransferType() { - return transferType; - } - - public String getProtocol() { - return protocol; - } - - public String getConnectorId() { - return connectorId; - } - - public String getAssetId() { - return assetId; - } - - @JsonPOJOBuilder(withPrefix = "") - public static final class Builder { - private final TransferRequestDto request; - - private Builder() { - request = new TransferRequestDto(); - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder connectorAddress(String connectorAddress) { - request.connectorAddress = connectorAddress; - return this; - } - - public Builder id(String id) { - request.id = id; - return this; - } - - public Builder contractId(String contractId) { - request.contractId = contractId; - return this; - } - - public Builder dataDestination(DataAddress dataDestination) { - request.dataDestination = dataDestination; - return this; - } - - public Builder managedResources(boolean managedResources) { - request.managedResources = managedResources; - return this; - } - - public Builder properties(Map properties) { - request.properties = properties; - return this; - } - - public Builder transferType(TransferType transferType) { - request.transferType = transferType; - return this; - } - - public Builder protocol(String protocol) { - request.protocol = protocol; - return this; - } - - public Builder connectorId(String connectorId) { - request.connectorId = connectorId; - return this; - } - - public Builder assetId(String assetId) { - request.assetId = assetId; - return this; - } - - public TransferRequestDto build() { - return request; - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferType.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferType.java deleted file mode 100644 index d424fb6a50..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferType.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.transfer; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; - -import java.util.Objects; - -@JsonDeserialize(builder = TransferType.Builder.class) -public class TransferType { - private static final String DEFAULT_CONTENT_TYPE = "application/octet-stream"; - private String contentType = DEFAULT_CONTENT_TYPE; - private boolean isFinite = true; - - @JsonProperty("contentType") - public String getContentType() { - return contentType; - } - - @JsonProperty("isFinite") - public boolean isFinite() { - return isFinite; - } - - @JsonPOJOBuilder(withPrefix = "") - public static final class Builder { - private String contentType = DEFAULT_CONTENT_TYPE; - private boolean isFinite = true; - - private Builder() { - } - - @JsonCreator - public static Builder transferType() { - return new Builder(); - } - - public Builder contentType(String contentType) { - this.contentType = contentType; - return this; - } - - public Builder isFinite(boolean isFinite) { - this.isFinite = isFinite; - return this; - } - - public TransferType build() { - TransferType transferType = new TransferType(); - transferType.contentType = Objects.requireNonNull(contentType, "Content type cannot be null!"); - transferType.isFinite = isFinite; - return transferType; - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transferprocess/TransferProcessDataDestination.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transferprocess/TransferProcessDataDestination.java new file mode 100644 index 0000000000..d7b13965a1 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transferprocess/TransferProcessDataDestination.java @@ -0,0 +1,40 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.transferprocess; + +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +/** + * Contains the data destination type for a transfer process. + */ +@Value +@Builder(toBuilder = true) +@Jacksonized +public class TransferProcessDataDestination { + + public static final String DEFAULT_TYPE = "HttpProxy"; + String type; + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transferprocess/TransferProcessId.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transferprocess/TransferProcessId.java new file mode 100644 index 0000000000..38bce93f44 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transferprocess/TransferProcessId.java @@ -0,0 +1,41 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.transferprocess; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +/** + * Contains an ID for a transfer process. + */ +@Value +@Builder(toBuilder = true) +@Jacksonized +public class TransferProcessId { + + @JsonProperty("id") + String value; + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transferprocess/TransferProcessRequest.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transferprocess/TransferProcessRequest.java new file mode 100644 index 0000000000..d909a9a89a --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transferprocess/TransferProcessRequest.java @@ -0,0 +1,67 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.transferprocess; + +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; +import org.eclipse.edc.spi.types.domain.DataAddress; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; + +import java.util.List; +import java.util.Map; + +/** + * EDC transfer process request. + */ +@Value +@Builder(toBuilder = true) +@Jacksonized +public class TransferProcessRequest { + + public static final String EDC_TRANSFER_REQUEST_DTO_ASSET_ID = "https://w3id.org/edc/v0.0.1/ns/assetId"; + public static final String EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ADDRESS = "https://w3id.org/edc/v0.0.1/ns/connectorAddress"; + public static final String EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ID = "https://w3id.org/edc/v0.0.1/ns/connectorId"; + public static final String EDC_TRANSFER_REQUEST_DTO_CONTRACT_ID = "https://w3id.org/edc/v0.0.1/ns/contractId"; + public static final String EDC_TRANSFER_REQUEST_DTO_DATA_DESTINATION = "https://w3id.org/edc/v0.0.1/ns/dataDestination"; + public static final String EDC_TRANSFER_REQUEST_DTO_PROTOCOL = "https://w3id.org/edc/v0.0.1/ns/protocol"; + public static final String EDC_TRANSFER_REQUEST_DTO_MANAGED_RESOURCES = "https://w3id.org/edc/v0.0.1/ns/managedResources"; + public static final String EDC_TRANSFER_REQUEST_DTO_CALLBACK_ADDRESSES = "https://w3id.org/edc/v0.0.1/ns/callbackAddresses"; + public static final String EDC_TRANSFER_REQUEST_DTO_PROPERTIES = "https://w3id.org/edc/v0.0.1/ns/properties"; + public static final String EDC_TRANSFER_REQUEST_DTO_PRIVATE_PROPERTIES = "https://w3id.org/edc/v0.0.1/ns/privateProperties"; + + public static final String DEFAULT_PROTOCOL = "dataspace-protocol-http"; + public static final boolean DEFAULT_MANAGED_RESOURCES = false; + + String assetId; + String connectorAddress; + String connectorId; + String contractId; + DataAddress dataDestination; + String protocol; + boolean managedResources; + List callbackAddresses; + Map properties; + Map privateProperties; + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/validators/AtomicConstraintValidator.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/validators/AtomicConstraintValidator.java new file mode 100644 index 0000000000..8ed4fe3847 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/validators/AtomicConstraintValidator.java @@ -0,0 +1,57 @@ +/******************************************************************************** + * 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.traceability.infrastructure.edc.blackbox.validators; + +import lombok.Builder; +import org.eclipse.edc.policy.model.AtomicConstraint; +import org.eclipse.edc.policy.model.Expression; +import org.eclipse.edc.policy.model.LiteralExpression; +import org.eclipse.edc.policy.model.Operator; + +/** + * Check and validate AtomicConstraint as a part of Policy in Catalog fetch from EDC providers. + */ +@Builder +public class AtomicConstraintValidator { + + private AtomicConstraint atomicConstraint; + private String leftExpressionValue; + private String rightExpressionValue; + private Operator expectedOperator; + + public boolean isValid() { + return isExpressionValid(atomicConstraint.getLeftExpression(), + leftExpressionValue) && isExpressionValid( + atomicConstraint.getRightExpression(), rightExpressionValue) + && expectedOperator.equals(atomicConstraint.getOperator()); + } + + private boolean isExpressionValid(final Expression expression, final String value) { + if (expression instanceof LiteralExpression literalExpression) { + return literalExpression.asString().equals(value); + } + return false; + } + + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractService.java index fb3ea83fab..d16a8d0f66 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractService.java @@ -20,6 +20,9 @@ ********************************************************************************/ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service; +import com.fasterxml.jackson.core.JsonProcessingException; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.CreateNotificationContractException; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.CreateNotificationContractRequest; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.CreateNotificationContractResponse; @@ -30,77 +33,73 @@ import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.contract.service.EdcContractDefinitionService; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model.CreateEdcPolicyDefinitionException; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.service.EdcPolicyDefinitionService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +@Slf4j @Component +@AllArgsConstructor public class EdcNotificationContractService { - private static final Logger logger = LoggerFactory.getLogger(EdcNotificationContractService.class); + private final EdcNotitifcationAssetService edcNotitifcationAssetService; + private final EdcPolicyDefinitionService edcPolicyDefinitionService; + private final EdcContractDefinitionService edcContractDefinitionService; - private final EdcNotitifcationAssetService edcNotitifcationAssetService; - private final EdcPolicyDefinitionService edcPolicyDefinitionService; - private final EdcContractDefinitionService edcContractDefinitionService; + public CreateNotificationContractResponse handle(CreateNotificationContractRequest request) { - public EdcNotificationContractService(EdcNotitifcationAssetService edcNotitifcationAssetService, - EdcPolicyDefinitionService edcPolicyDefinitionService, - EdcContractDefinitionService edcContractDefinitionService) { - this.edcNotitifcationAssetService = edcNotitifcationAssetService; - this.edcPolicyDefinitionService = edcPolicyDefinitionService; - this.edcContractDefinitionService = edcContractDefinitionService; - } + NotificationMethod notificationMethod = request.notificationMethod(); - public CreateNotificationContractResponse handle(CreateNotificationContractRequest request) { + log.info("Creating EDC asset notification contract for {} method and {} notification type", notificationMethod.getValue(), request.notificationType().getValue()); - NotificationMethod notificationMethod = request.notificationMethod(); + String notificationAssetId = ""; + try { + notificationAssetId = edcNotitifcationAssetService.createNotificationAsset(notificationMethod, request.notificationType()); + } catch (CreateEdcAssetException e) { + throw new CreateNotificationContractException(e); + } catch (JsonProcessingException e2) { + log.error(e2.toString()); + } - logger.info("Creating EDC asset notification contract for {} method and {} notification type", notificationMethod.getValue(), request.notificationType().getValue()); - final String notificationAssetId; - try { - notificationAssetId = edcNotitifcationAssetService.createNotificationAsset(notificationMethod, request.notificationType()); - } catch (CreateEdcAssetException e) { - throw new CreateNotificationContractException(e); - } + String accessPolicyId = ""; + try { + accessPolicyId = edcPolicyDefinitionService.createAccessPolicy(); + } catch (CreateEdcPolicyDefinitionException e) { + revertNotificationAsset(notificationAssetId); + throw new CreateNotificationContractException(e); + } catch (JsonProcessingException e2) { + log.error(e2.toString()); + } - final String accessPolicyId; - try { - accessPolicyId = edcPolicyDefinitionService.createAccessPolicy(notificationAssetId); - } catch (CreateEdcPolicyDefinitionException e) { - revertNotificationAsset(notificationAssetId); + String contractDefinitionId = ""; + try { + contractDefinitionId = edcContractDefinitionService.createContractDefinition(notificationAssetId, accessPolicyId); + } catch (CreateEdcContractDefinitionException e) { + revertAccessPolicy(accessPolicyId); + revertNotificationAsset(notificationAssetId); - throw new CreateNotificationContractException(e); - } + throw new CreateNotificationContractException(e); + } catch (JsonProcessingException e2) { + log.error(e2.toString()); + } - final String contractDefinitionId; - try { - contractDefinitionId = edcContractDefinitionService.createContractDefinition(notificationAssetId, accessPolicyId); - } catch (CreateEdcContractDefinitionException e) { - revertAccessPolicy(accessPolicyId); - revertNotificationAsset(notificationAssetId); + log.info("Created notification contract for {} notification asset id, access policy id {} and contract definition id {}", notificationAssetId, accessPolicyId, contractDefinitionId); - throw new CreateNotificationContractException(e); - } + return new CreateNotificationContractResponse( + notificationAssetId, + accessPolicyId, + contractDefinitionId + ); + } - logger.info("Created notification contract for {} notification asset id, access policy id {} and contract definition id {}", notificationAssetId, accessPolicyId, contractDefinitionId); + private void revertAccessPolicy(String accessPolicyId) { + log.info("Removing {} access policy", accessPolicyId); - return new CreateNotificationContractResponse( - notificationAssetId, - accessPolicyId, - contractDefinitionId - ); - } + edcPolicyDefinitionService.deleteAccessPolicy(accessPolicyId); + } - private void revertAccessPolicy(String accessPolicyId) { - logger.info("Removing {} access policy", accessPolicyId); + private void revertNotificationAsset(String notificationAssetId) { + log.info("Removing {} notification asset", notificationAssetId); - edcPolicyDefinitionService.deleteAccessPolicy(accessPolicyId); - } - - private void revertNotificationAsset(String notificationAssetId) { - logger.info("Removing {} notification asset", notificationAssetId); - - edcNotitifcationAssetService.deleteNotificationAsset(notificationAssetId); - } + edcNotitifcationAssetService.deleteNotificationAsset(notificationAssetId); + } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcAsset.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcAsset.java index a0a1af5be9..e2c67ba8cf 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcAsset.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcAsset.java @@ -21,17 +21,20 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.ToString; +@ToString +@Builder public class EdcAsset { - @JsonProperty("properties") - private final EdcAssetProperties edcAssetProperties; + @JsonProperty("@id") + private String assetId; - public EdcAsset(EdcAssetProperties edcAssetProperties) { - this.edcAssetProperties = edcAssetProperties; - } + @JsonProperty("@type") + private String type; + + @JsonProperty("properties") + private EdcAssetProperties edcAssetProperties; - public EdcAssetProperties getEdcAssetProperties() { - return edcAssetProperties; - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcAssetProperties.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcAssetProperties.java index 6943e59e8a..8f1220a8f5 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcAssetProperties.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcAssetProperties.java @@ -22,42 +22,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; -public class EdcAssetProperties { - - @JsonProperty("asset:prop:id") - private final String assetId; - - @JsonProperty("asset:prop:name") - private final String assetName; - - @JsonProperty("asset:prop:contenttype") - private final String contentType; - - @JsonProperty("asset:prop:policy-id") - private final String policyId; - - @JsonProperty("asset:prop:type") - private final String type; - - @JsonProperty("asset:prop:notificationtype") - private final String notiifcationType; - - @JsonProperty("asset:prop:notificationmethod") - private final String notificationMethod; - - public EdcAssetProperties(String assetId, - String assetName, - String contentType, - String policyId, - String type, - String notiifcationType, - String notificationMethod) { - this.assetId = assetId; - this.assetName = assetName; - this.contentType = contentType; - this.policyId = policyId; - this.type = type; - this.notiifcationType = notiifcationType; - this.notificationMethod = notificationMethod; - } +public record EdcAssetProperties(@JsonProperty("description") String assetName, + @JsonProperty("contenttype") String contentType, + @JsonProperty("policy-id") String policyId, + @JsonProperty("type") String type, + @JsonProperty("notificationtype") String notificationType, + @JsonProperty("notificationmethod") String notificationMethod) { } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/message/RemoteMessage.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcContext.java similarity index 58% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/message/RemoteMessage.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcContext.java index 9807bc3530..c1ad6c88b5 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/message/RemoteMessage.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcContext.java @@ -1,7 +1,5 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -19,16 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.message; - -/** - * A remote message that is to be sent to another system. Dispatchers are responsible for binding the remote message to the specific transport protocol specified by the message. - */ -public interface RemoteMessage { - - /** - * Returns the transport protocol this message must be sent over. - */ - String getProtocol(); +package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model; +public record EdcContext(String edc) { } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcCreateDataAssetRequest.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcCreateDataAssetRequest.java index be218dae5c..20ae0dff9e 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcCreateDataAssetRequest.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcCreateDataAssetRequest.java @@ -21,25 +21,19 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.ToString; +@ToString +@Builder public class EdcCreateDataAssetRequest { - @JsonProperty("asset") - private final EdcAsset edcAsset; + @JsonProperty("@context") + private EdcContext context; - @JsonProperty("dataAddress") - private final EdcDataAddress edcDataAddress; + @JsonProperty("asset") + private EdcAsset asset; - public EdcCreateDataAssetRequest(EdcAsset edcAsset, EdcDataAddress edcDataAddress) { - this.edcAsset = edcAsset; - this.edcDataAddress = edcDataAddress; - } - - public EdcAsset getEdcAsset() { - return edcAsset; - } - - public EdcDataAddress getEdcDataAddress() { - return edcDataAddress; - } + @JsonProperty("dataAddress") + private EdcDataAddress dataAddress; } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcDataAddress.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcDataAddress.java index c19a160176..24ec80189e 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcDataAddress.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcDataAddress.java @@ -21,17 +21,26 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.ToString; +@ToString +@Builder public class EdcDataAddress { - @JsonProperty("properties") - private final EdcDataAddressProperties edcDataAddressProperties; + @JsonProperty("type") + private String type; - public EdcDataAddress(EdcDataAddressProperties edcDataAddressProperties) { - this.edcDataAddressProperties = edcDataAddressProperties; - } + @JsonProperty("baseUrl") + private String baseUrl; + + @JsonProperty("proxyMethod") + private String proxyMethod; + + @JsonProperty("proxyBody") + private String proxyBody; + + @JsonProperty("method") + private String method; - public EdcDataAddressProperties getEdcDataAddressProperties() { - return edcDataAddressProperties; - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcDataAddressProperties.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcDataAddressProperties.java index eae67dcfbd..e40fbe98a0 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcDataAddressProperties.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/EdcDataAddressProperties.java @@ -22,52 +22,33 @@ import com.fasterxml.jackson.annotation.JsonProperty; + public class EdcDataAddressProperties { @JsonProperty("baseUrl") private final String baseUrl; @JsonProperty("proxyMethod") - private final boolean proxyMethod; + private final String proxyMethod; @JsonProperty("method") private final String method; - @JsonProperty("proxyBody") - private final boolean proxyBody; + @JsonProperty("proxyBody") + private final String proxyBody; @JsonProperty("type") private final String type; public EdcDataAddressProperties(String baseUrl, - boolean proxyMethod, - String method, - boolean proxyBody, - String type) { + String proxyMethod, + String method, + String proxyBody, + String type) { this.baseUrl = baseUrl; this.proxyMethod = proxyMethod; this.method = method; this.proxyBody = proxyBody; this.type = type; } - - public String getBaseUrl() { - return baseUrl; - } - - public boolean getProxyMethod() { - return proxyMethod; - } - - public String getMethod() { - return method; - } - - public boolean getProxyBody() { - return proxyBody; - } - - public String getType() { - return type; - } } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/test/support/ContractAgreementMother.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/OdrlContext.java similarity index 50% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/test/support/ContractAgreementMother.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/OdrlContext.java index 18555fb9ca..de04c63cd2 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/test/support/ContractAgreementMother.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/model/OdrlContext.java @@ -17,28 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.infrastructure.test.support; +package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.agreement.ContractAgreement; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; - -public class ContractAgreementMother { - public static ContractAgreement getContractAgreement(final Policy policy) { - return ContractAgreement.Builder - .newInstance() - .id("id") - .providerAgentId("providerAgentId") - .consumerAgentId("consumerAgentId") - .contractSigningDate(1) - .contractStartDate(2) - .contractEndDate(3) - .assetId("assetId") - .policy(policy) - .build(); - } - - public static Policy getPolicy() { - return Policy.Builder.newInstance() - .build(); - } +public record OdrlContext(String odrl) { } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/service/EdcNotitifcationAssetService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/service/EdcNotitifcationAssetService.java index 642e7a57d9..0fbc47c95b 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/service/EdcNotitifcationAssetService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/asset/service/EdcNotitifcationAssetService.java @@ -20,17 +20,19 @@ ********************************************************************************/ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.service; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.NotificationMethod; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.NotificationType; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.CreateEdcAssetException; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.EdcAsset; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.EdcAssetProperties; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.EdcContext; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.EdcCreateDataAssetRequest; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.EdcDataAddress; -import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.EdcDataAddressProperties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.eclipse.tractusx.traceability.infrastructure.edc.properties.EdcProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatusCode; @@ -42,103 +44,116 @@ import java.util.UUID; +import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.configuration.JsonLdConfiguration.NAMESPACE_EDC; import static org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.configuration.EdcRestTemplateConfiguration.EDC_REST_TEMPLATE; +@Slf4j @Component public class EdcNotitifcationAssetService { - private static final Logger logger = LoggerFactory.getLogger(EdcNotitifcationAssetService.class); - private static final String DEFAULT_CONTENT_TYPE = "application/json"; private static final String DEFAULT_POLICY_ID = "use-eu"; private static final String DEFAULT_METHOD = "POST"; private static final String DEFAULT_DATA_ADDRESS_PROPERTY_TYPE = "HttpData"; private static final String TRACE_FOSS_QUALITY_NOTIFICATION_INVESTIGATION_URL_TEMPLATE = "/api/qualitynotifications/%s"; private static final String TRACE_FOSS_QUALITY_NOTIFICATION_ALERT_URL_TEMPLATE = "/api/qualityalerts/%s"; - private static final String EDC_CREATE_ASSET_PATH = "/api/v1/management/assets"; private final TraceabilityProperties traceabilityProperties; private final RestTemplate restTemplate; + private final EdcProperties edcProperties; + private final ObjectMapper objectMapper; @Autowired - public EdcNotitifcationAssetService(TraceabilityProperties traceabilityProperties, @Qualifier(EDC_REST_TEMPLATE) RestTemplate restTemplate) { + public EdcNotitifcationAssetService(TraceabilityProperties traceabilityProperties, @Qualifier(EDC_REST_TEMPLATE) RestTemplate restTemplate, EdcProperties edcProperties, ObjectMapper objectMapper) { this.traceabilityProperties = traceabilityProperties; this.restTemplate = restTemplate; + this.edcProperties = edcProperties; + this.objectMapper = objectMapper; } - public String createNotificationAsset(NotificationMethod notificationMethod, NotificationType notificationType) { - String notificationMethodValue = notificationMethod.getValue(); + public String createNotificationAsset(NotificationMethod notificationMethod, NotificationType notificationType) throws JsonProcessingException { + String notificationMethodValue = notificationMethod.getValue(); final String template = notificationType.equals(NotificationType.QUALITY_ALERT) ? TRACE_FOSS_QUALITY_NOTIFICATION_ALERT_URL_TEMPLATE : TRACE_FOSS_QUALITY_NOTIFICATION_INVESTIGATION_URL_TEMPLATE; + String notificationAssetId = UUID.randomUUID().toString(); - EdcDataAddressProperties edcDataAddressProperties = new EdcDataAddressProperties( - traceabilityProperties.getUrl() + template.formatted(notificationMethodValue), - true, - DEFAULT_METHOD, - true, - DEFAULT_DATA_ADDRESS_PROPERTY_TYPE + EdcDataAddress dataAddress = EdcDataAddress + .builder() + .type(DEFAULT_DATA_ADDRESS_PROPERTY_TYPE) + .baseUrl(traceabilityProperties.getUrl() + template.formatted(notificationMethodValue)) + .method(DEFAULT_METHOD) + .proxyBody("true") + .proxyMethod("true") + .build(); + + String description = "endpoint to %s %s".formatted(notificationMethodValue, notificationType.getValue()); + + EdcAssetProperties assetProperties = new EdcAssetProperties( + description, + DEFAULT_CONTENT_TYPE, + DEFAULT_POLICY_ID, + notificationType.getValue(), + notificationType.getValue(), + notificationMethodValue ); - EdcDataAddress edcDataAddress = new EdcDataAddress(edcDataAddressProperties); - - String description = "endpoint to %s %s".formatted(notificationMethodValue, notificationType.getValue()); - - EdcAssetProperties edcAssetProperties = new EdcAssetProperties( - notificationAssetId, - description, - DEFAULT_CONTENT_TYPE, - DEFAULT_POLICY_ID, - notificationType.getValue(), - notificationType.getValue(), - notificationMethodValue - ); + EdcAsset asset = EdcAsset + .builder() + .assetId(notificationAssetId) + .type("Asset") + .edcAssetProperties(assetProperties) + .build(); - EdcAsset edcAsset = new EdcAsset(edcAssetProperties); + EdcContext edcContext = new EdcContext(NAMESPACE_EDC); - EdcCreateDataAssetRequest createDataAssetRequest = new EdcCreateDataAssetRequest(edcAsset, edcDataAddress); + EdcCreateDataAssetRequest createDataAssetRequest = EdcCreateDataAssetRequest + .builder() + .asset(asset) + .dataAddress(dataAddress) + .context(edcContext) + .build(); - final ResponseEntity createEdcDataAssetResponse; + final ResponseEntity createEdcDataAssetResponse; - try { - createEdcDataAssetResponse = restTemplate.postForEntity( - EDC_CREATE_ASSET_PATH, - createDataAssetRequest, - String.class - ); - } catch (RestClientException e) { - logger.error("Failed to create EDC notification asset for {} method. Reason: ", notificationMethod, e); + try { + createEdcDataAssetResponse = restTemplate.postForEntity( + edcProperties.getAssetsPath(), + createDataAssetRequest, + String.class + ); + } catch (RestClientException e) { + log.error("Failed to create EDC notification asset for {} method. Reason: ", notificationMethod, e); + throw new CreateEdcAssetException(e); + } - throw new CreateEdcAssetException(e); - } + HttpStatusCode responseCode = createEdcDataAssetResponse.getStatusCode(); - HttpStatusCode responseCode = createEdcDataAssetResponse.getStatusCode(); + if (responseCode.value() == 409) { + log.info("{} notification asset already exists in the EDC", notificationAssetId); - if (responseCode.value() == 409) { - logger.info("{} notification asset already exists in the EDC", notificationAssetId); + return notificationAssetId; + } - return notificationAssetId; - } + if (responseCode.value() == 200) { + return notificationAssetId; + } - if (responseCode.value() == 200) { - return notificationAssetId; - } + log.error("Failed to create EDC notification asset for {} method. Body: {}, status: {}", notificationMethodValue, createEdcDataAssetResponse.getBody(), createEdcDataAssetResponse.getStatusCode()); - logger.error("Failed to create EDC notification asset for {} method. Body: {}, status: {}", notificationMethodValue, createEdcDataAssetResponse.getBody(), createEdcDataAssetResponse.getStatusCode()); - - throw new CreateEdcAssetException("Failed to create EEC notification asset for %s method".formatted(notificationMethodValue)); - } - - public void deleteNotificationAsset(String notificationAssetId) { - String deleteUri = UriComponentsBuilder.fromPath(EDC_CREATE_ASSET_PATH) - .pathSegment("{notificationAssetId}") - .buildAndExpand(notificationAssetId) - .toUriString(); + throw new CreateEdcAssetException("Failed to create EEC notification asset for %s method".formatted(notificationMethodValue)); + } - try { - restTemplate.delete(deleteUri); - } catch (RestClientException e) { - logger.error("Failed to delete EDC notification asset {}. Reason: ", notificationAssetId, e); - } - } + public void deleteNotificationAsset(String notificationAssetId) { + String deleteUri = UriComponentsBuilder.fromPath(edcProperties.getAssetsPath()) + .pathSegment("{notificationAssetId}") + .buildAndExpand(notificationAssetId) + .toUriString(); + + try { + restTemplate.delete(deleteUri); + } catch (RestClientException e) { + log.error("Failed to delete EDC notification asset {}. Reason: ", notificationAssetId, e); + } + } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/CatalogRequestDTO.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/CatalogRequestDTO.java index ec27997eb7..d842c005aa 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/CatalogRequestDTO.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/CatalogRequestDTO.java @@ -18,5 +18,10 @@ ********************************************************************************/ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.contract.model; -public record CatalogRequestDTO(String providerUrl) { +import com.fasterxml.jackson.annotation.JsonProperty; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.EdcContext; + +public record CatalogRequestDTO(@JsonProperty("providerUrl") String providerUrl, + @JsonProperty("protocol") String protocol, + @JsonProperty("@context") EdcContext edcContext) { } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcContractDefinitionCriteria.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcContractDefinitionCriteria.java index 549ff64d31..ef939d8d22 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcContractDefinitionCriteria.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcContractDefinitionCriteria.java @@ -21,35 +21,25 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.contract.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.Getter; +import lombok.ToString; +@ToString +@Getter +@Builder public class EdcContractDefinitionCriteria { - @JsonProperty("operandLeft") - private final String operandLeft; + @JsonProperty("@type") + private String type; - @JsonProperty("operator") - private final String operator; + @JsonProperty("operandLeft") + private String operandLeft; - @JsonProperty("operandRight") - private final String operandRight; + @JsonProperty("operator") + private String operator; - public EdcContractDefinitionCriteria(String operandLeft, - String operator, - String operandRight) { - this.operandLeft = operandLeft; - this.operator = operator; - this.operandRight = operandRight; - } + @JsonProperty("operandRight") + private String operandRight; - public String getOperandLeft() { - return operandLeft; - } - - public String getOperator() { - return operator; - } - - public String getOperandRight() { - return operandRight; - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcCreateContractDefinitionRequest.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcCreateContractDefinitionRequest.java index 331cd626ab..98309556a8 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcCreateContractDefinitionRequest.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcCreateContractDefinitionRequest.java @@ -21,46 +21,30 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.contract.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.ToString; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.EdcContext; -import java.util.List; - +@ToString +@Builder public class EdcCreateContractDefinitionRequest { - @JsonProperty("id") - private final String id; - - @JsonProperty("accessPolicyId") - private final String accessPolicyId; - - @JsonProperty("contractPolicyId") - private final String contractPolicyId; + @JsonProperty("@context") + private EdcContext edcContext; - @JsonProperty("criteria") - private final List criteria; + @JsonProperty("@type") + private String type; - public EdcCreateContractDefinitionRequest(String id, - String accessPolicyId, - String contractPolicyId, - List criteria) { - this.id = id; - this.accessPolicyId = accessPolicyId; - this.contractPolicyId = contractPolicyId; - this.criteria = criteria; - } + @JsonProperty("@id") + private String id; - public String getId() { - return id; - } + @JsonProperty("accessPolicyId") + private String accessPolicyId; - public String getAccessPolicyId() { - return accessPolicyId; - } + @JsonProperty("contractPolicyId") + private String contractPolicyId; - public String getContractPolicyId() { - return contractPolicyId; - } + @JsonProperty("assetsSelector") + private EdcContractDefinitionCriteria assetsSelector; - public List getCriteria() { - return criteria; - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/service/EdcContractDefinitionService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/service/EdcContractDefinitionService.java index f61d0fecb2..1ba2762fa5 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/service/EdcContractDefinitionService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/service/EdcContractDefinitionService.java @@ -20,12 +20,15 @@ ********************************************************************************/ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.contract.service; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.CreateEdcAssetException; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.EdcContext; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.contract.model.CreateEdcContractDefinitionException; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.contract.model.EdcContractDefinitionCriteria; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.contract.model.EdcCreateContractDefinitionRequest; -import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.CreateEdcAssetException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.eclipse.tractusx.traceability.infrastructure.edc.properties.EdcProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatusCode; @@ -34,65 +37,73 @@ import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; -import java.util.List; -import java.util.UUID; - +import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.configuration.JsonLdConfiguration.NAMESPACE_EDC; import static org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.configuration.EdcRestTemplateConfiguration.EDC_REST_TEMPLATE; +@Slf4j @Component public class EdcContractDefinitionService { - private static final Logger logger = LoggerFactory.getLogger(EdcContractDefinitionService.class); - - private static final String ASSET_ID_OPERAND = "asset:prop:id"; - private static final String EQUALITY_OPERATOR = "="; - private static final String CONTRACT_DEFINITIONS_PATH = "/api/v1/management/contractdefinitions"; - - private final RestTemplate restTemplate; - - @Autowired - public EdcContractDefinitionService(@Qualifier(EDC_REST_TEMPLATE) RestTemplate restTemplate) { - this.restTemplate = restTemplate; - } - - public String createContractDefinition(String notificationAssetId, String accessPolicyId) { - EdcContractDefinitionCriteria edcContractDefinitionCriteria = new EdcContractDefinitionCriteria(ASSET_ID_OPERAND, EQUALITY_OPERATOR, notificationAssetId); - - String contractPolicyId = UUID.randomUUID().toString(); - - EdcCreateContractDefinitionRequest createContractDefinitionRequest = new EdcCreateContractDefinitionRequest( - contractPolicyId, - accessPolicyId, - accessPolicyId, - List.of( - edcContractDefinitionCriteria - ) - ); - - final ResponseEntity createContractDefinitionResponse; - - try { - createContractDefinitionResponse = restTemplate.postForEntity(CONTRACT_DEFINITIONS_PATH, createContractDefinitionRequest, String.class); - } catch (RestClientException e) { - logger.error("Failed to create edc contract definition for {} notification asset and {} policy definition id. Reason: ", notificationAssetId, accessPolicyId, e); - - throw new CreateEdcContractDefinitionException(e); - } - - HttpStatusCode responseCode = createContractDefinitionResponse.getStatusCode(); - - if (responseCode.value() == 409) { - logger.info("{} asset contract definition already exists in the EDC", notificationAssetId); - - throw new CreateEdcContractDefinitionException("Asset contract definition already exists in the EDC"); - } - - if (responseCode.value() == 200) { - return contractPolicyId; - } - - logger.error("Failed to create EDC contract definition for {} notification asset id. Body: {}, status: {}", notificationAssetId, createContractDefinitionResponse.getBody(), createContractDefinitionResponse.getStatusCode()); - - throw new CreateEdcAssetException("Failed to create EDC contract definition for %s notification asset id".formatted(notificationAssetId)); - } + private static final String ASSET_SELECTOR_ID = "https://w3id.org/edc/v0.0.1/ns/id"; + private static final String ASSET_SELECTOR_EQUALITY_OPERATOR = "="; + private static final String ASSET_SELECTOR_TYPE = "CriterionDto"; + private static final String CONTRACT_DEFINITION_TYPE = "ContractDefinition"; + + private final RestTemplate restTemplate; + private final EdcProperties edcProperties; + private final ObjectMapper objectMapper; + + @Autowired + public EdcContractDefinitionService(@Qualifier(EDC_REST_TEMPLATE) RestTemplate restTemplate, EdcProperties edcProperties, ObjectMapper objectMapper, ObjectMapper objectMapper1) { + this.restTemplate = restTemplate; + this.edcProperties = edcProperties; + this.objectMapper = objectMapper1; + } + + public String createContractDefinition(String notificationAssetId, String accessPolicyId) throws JsonProcessingException { + EdcContractDefinitionCriteria edcContractDefinitionCriteria = EdcContractDefinitionCriteria + .builder() + .type(ASSET_SELECTOR_TYPE) + .operandLeft(ASSET_SELECTOR_ID) + .operandRight(notificationAssetId) + .operator(ASSET_SELECTOR_EQUALITY_OPERATOR) + .build(); + + + EdcContext edcContext = new EdcContext(NAMESPACE_EDC); + EdcCreateContractDefinitionRequest createContractDefinitionRequest = EdcCreateContractDefinitionRequest.builder() + .contractPolicyId(accessPolicyId) + .edcContext(edcContext) + .type(CONTRACT_DEFINITION_TYPE) + .accessPolicyId(accessPolicyId) + .id(accessPolicyId) + .assetsSelector(edcContractDefinitionCriteria) + .build(); + + final ResponseEntity createContractDefinitionResponse; + log.info("EdcCreateContractDefinitionRequest {}", objectMapper.writeValueAsString(createContractDefinitionRequest)); + try { + createContractDefinitionResponse = restTemplate.postForEntity(edcProperties.getContractDefinitionsPath(), createContractDefinitionRequest, String.class); + } catch (RestClientException e) { + log.error("Failed to create edc contract definition for {} notification asset and {} policy definition id. Reason: ", notificationAssetId, accessPolicyId, e); + + throw new CreateEdcContractDefinitionException(e); + } + + HttpStatusCode responseCode = createContractDefinitionResponse.getStatusCode(); + + if (responseCode.value() == 409) { + log.info("{} asset contract definition already exists in the EDC", notificationAssetId); + + throw new CreateEdcContractDefinitionException("Asset contract definition already exists in the EDC"); + } + + if (responseCode.value() == 200) { + return accessPolicyId; + } + + log.error("Failed to create EDC contract definition for {} notification asset id. Body: {}, status: {}", notificationAssetId, createContractDefinitionResponse.getBody(), createContractDefinitionResponse.getStatusCode()); + + throw new CreateEdcAssetException("Failed to create EDC contract definition for %s notification asset id".formatted(notificationAssetId)); + } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcCreatePolicyDefinitionRequest.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcCreatePolicyDefinitionRequest.java index 434d8372c0..a94bfc8ff7 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcCreatePolicyDefinitionRequest.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcCreatePolicyDefinitionRequest.java @@ -21,17 +21,24 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.ToString; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.OdrlContext; +@ToString +@Builder public class EdcCreatePolicyDefinitionRequest { - @JsonProperty("id") - private final String policyDefinitionId; + @JsonProperty("@context") + private OdrlContext odrlContext; - @JsonProperty("policy") - private final EdcPolicy edcPolicy; + @JsonProperty("@id") + private String policyDefinitionId; + + @JsonProperty("@type") + private String type; + + @JsonProperty("policy") + private EdcPolicy policy; - public EdcCreatePolicyDefinitionRequest(String policyDefinitionId, EdcPolicy edcPolicy) { - this.policyDefinitionId = policyDefinitionId; - this.edcPolicy = edcPolicy; - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicy.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicy.java index 9ed22ab868..a62c4b61bf 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicy.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicy.java @@ -21,19 +21,17 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.ToString; import java.util.List; +@ToString +@Builder public class EdcPolicy { + @JsonProperty("@type") + private String type; + @JsonProperty("odrl:permission") + private List odrlPermissions; - @JsonProperty("permissions") - private final List edcPolicyPermissions; - - public EdcPolicy(List edcPolicyPermissions) { - this.edcPolicyPermissions = edcPolicyPermissions; - } - - public List getEdcPolicyPermissions() { - return edcPolicyPermissions; - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermission.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermission.java index b38493a0e9..8cbd7fb0b9 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermission.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermission.java @@ -21,46 +21,17 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.ToString; -import java.util.List; - +@ToString +@Builder public class EdcPolicyPermission { - @JsonProperty("edctype") - private final String edcType; - - @JsonProperty("action") - private final EdcPolicyPermissionAction policyPermissionAction; - - @JsonProperty("target") - private final String target; - - @JsonProperty("constraints") - private final List edcPolicyPermissionConstraints; - - public EdcPolicyPermission(String edcType, - EdcPolicyPermissionAction policyPermissionAction, - String target, - List edcPolicyPermissionConstraints) { - this.edcType = edcType; - this.policyPermissionAction = policyPermissionAction; - this.target = target; - this.edcPolicyPermissionConstraints = edcPolicyPermissionConstraints; - } - - public String getEdcType() { - return edcType; - } - - public EdcPolicyPermissionAction getPolicyPermissionAction() { - return policyPermissionAction; - } + @JsonProperty("odrl:action") + private String action; - public String getTarget() { - return target; - } + @JsonProperty("odrl:constraint") + private EdcPolicyPermissionConstraint edcPolicyPermissionConstraints; - public List getEdcPolicyPermissionConstraints() { - return edcPolicyPermissionConstraints; - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionAction.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionAction.java index 8b6b5cc425..f676c58c14 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionAction.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionAction.java @@ -21,17 +21,12 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +@Builder public class EdcPolicyPermissionAction { - @JsonProperty("type") - private final String type; + @JsonProperty("type") + private String type; - public EdcPolicyPermissionAction(String type) { - this.type = type; - } - - public String getType() { - return type; - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionConstraint.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionConstraint.java index 13b9f8ffd2..e0636ae23f 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionConstraint.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionConstraint.java @@ -20,44 +20,19 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.ToString; -public class EdcPolicyPermissionConstraint { - - @JsonProperty("edctype") - private final String edcType; - - @JsonProperty("leftExpression") - private final EdcPolicyPermissionConstraintExpression leftExpression; - - @JsonProperty("rightExpression") - private final EdcPolicyPermissionConstraintExpression rightExpression; +import java.util.List; - @JsonProperty("operator") - private final String operator; - - public EdcPolicyPermissionConstraint(String edcType, - EdcPolicyPermissionConstraintExpression leftExpression, - EdcPolicyPermissionConstraintExpression rightExpression, - String operator) { - this.edcType = edcType; - this.leftExpression = leftExpression; - this.rightExpression = rightExpression; - this.operator = operator; - } - - public String getEdcType() { - return edcType; - } +@ToString +@Builder +public class EdcPolicyPermissionConstraint { - public EdcPolicyPermissionConstraintExpression getLeftExpression() { - return leftExpression; - } + @JsonProperty("@type") + private String type; - public EdcPolicyPermissionConstraintExpression getRightExpression() { - return rightExpression; - } + @JsonProperty("odrl:or") + private List orExpressions; - public String getOperator() { - return operator; - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionConstraintExpression.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionConstraintExpression.java index 0eaf6a00fa..c2c1501d2e 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionConstraintExpression.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/model/EdcPolicyPermissionConstraintExpression.java @@ -20,25 +20,26 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.Getter; +import lombok.ToString; +@ToString +@Getter +@Builder public class EdcPolicyPermissionConstraintExpression { - @JsonProperty("edctype") - private final String edcType; + // Constraint + @JsonProperty("@type") + private final String type; - @JsonProperty("value") - private final String value; + @JsonProperty("odrl:leftOperand") + private final String leftOperand; - public EdcPolicyPermissionConstraintExpression(String edcType, String value) { - this.edcType = edcType; - this.value = value; - } + @JsonProperty("odrl:rightOperand") + private final String rightOperand; - public String getEdcType() { - return edcType; - } + @JsonProperty("odrl:operator") + private final String operator; - public String getValue() { - return value; - } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/service/EdcPolicyDefinitionService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/service/EdcPolicyDefinitionService.java index b071e7dc16..447268c706 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/service/EdcPolicyDefinitionService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/policy/service/EdcPolicyDefinitionService.java @@ -20,11 +20,18 @@ ********************************************************************************/ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.service; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.CreateEdcAssetException; -import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.service.EdcNotitifcationAssetService; -import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.asset.model.OdrlContext; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model.CreateEdcPolicyDefinitionException; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model.EdcCreatePolicyDefinitionRequest; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model.EdcPolicy; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model.EdcPolicyPermission; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model.EdcPolicyPermissionConstraint; +import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service.policy.model.EdcPolicyPermissionConstraintExpression; +import org.eclipse.tractusx.traceability.infrastructure.edc.properties.EdcProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatusCode; @@ -37,53 +44,70 @@ import java.util.List; import java.util.UUID; +import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.configuration.JsonLdConfiguration.NAMESPACE_ODRL; import static org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.configuration.EdcRestTemplateConfiguration.EDC_REST_TEMPLATE; +@Slf4j @Component public class EdcPolicyDefinitionService { - private static final Logger logger = LoggerFactory.getLogger(EdcNotitifcationAssetService.class); - - private static final String CREATE_POLICY_DEFINION_PATH = "/api/v1/management/policydefinitions"; - private static final String DATA_SPACE_CONNECTOR_PERMISSION = "dataspaceconnector:permission"; - public static final String DATA_SPACE_LITERAL_EXPRESSION = "dataspaceconnector:literalexpression"; private static final String USE_ACTION = "USE"; - - private static final List DEFAULT_EDC_POLICY_PERMISSION_CONSTRAINTS = List.of( - new EdcPolicyPermissionConstraint( - "AtomicConstraint", - new EdcPolicyPermissionConstraintExpression(DATA_SPACE_LITERAL_EXPRESSION, "idsc:PURPOSE"), - new EdcPolicyPermissionConstraintExpression(DATA_SPACE_LITERAL_EXPRESSION, "ID 3.0 Trace"), - "EQ" - ) - ); - + private static final String POLICY_TYPE = "Policy"; + private static final String POLICY_DEFINITION_TYPE = "PolicyDefinitionRequestDto"; + private static final String ATOMIC_CONSTRAINT = "AtomicConstraint"; + private static final String PURPOSE_CONSTRAINT = "idsc:PURPOSE"; + private static final String ID_TRACE_CONSTRAINT = "ID 3.0 Trace"; + private static final String CONSTRAINT = "Constraint"; + + private final ObjectMapper objectMapper; private final RestTemplate restTemplate; + private final EdcProperties edcProperties; @Autowired - public EdcPolicyDefinitionService(@Qualifier(EDC_REST_TEMPLATE) RestTemplate restTemplate) { + public EdcPolicyDefinitionService(ObjectMapper objectMapper, @Qualifier(EDC_REST_TEMPLATE) RestTemplate restTemplate, EdcProperties edcProperties) { + this.objectMapper = objectMapper; this.restTemplate = restTemplate; + this.edcProperties = edcProperties; } - public String createAccessPolicy(String notificationAssetId) { - EdcPolicyPermission edcPolicyPermission = new EdcPolicyPermission( - DATA_SPACE_CONNECTOR_PERMISSION, - new EdcPolicyPermissionAction(USE_ACTION), - notificationAssetId, - DEFAULT_EDC_POLICY_PERMISSION_CONSTRAINTS - ); + public String createAccessPolicy() throws JsonProcessingException { - EdcPolicy edcPolicy = new EdcPolicy(List.of(edcPolicyPermission)); + EdcPolicyPermissionConstraintExpression constraint = EdcPolicyPermissionConstraintExpression.builder() + .leftOperand(PURPOSE_CONSTRAINT) + .rightOperand(ID_TRACE_CONSTRAINT) + .operator("EQ") + .type(CONSTRAINT) + .build(); - String accessPolicyId = UUID.randomUUID().toString(); + EdcPolicyPermissionConstraint edcPolicyPermissionConstraint = EdcPolicyPermissionConstraint.builder() + .orExpressions(List.of(constraint)) + .type(ATOMIC_CONSTRAINT) + .build(); + + EdcPolicyPermission odrlPermissions = EdcPolicyPermission + .builder() + .action(USE_ACTION) + .edcPolicyPermissionConstraints(edcPolicyPermissionConstraint) + .build(); - EdcCreatePolicyDefinitionRequest edcCreatePolicyDefinitionRequest = new EdcCreatePolicyDefinitionRequest(accessPolicyId, edcPolicy); + EdcPolicy edcPolicy = EdcPolicy.builder().odrlPermissions(List.of(odrlPermissions)).type(POLICY_TYPE).build(); + String accessPolicyId = UUID.randomUUID().toString(); + OdrlContext odrlContext = new OdrlContext(NAMESPACE_ODRL); + + EdcCreatePolicyDefinitionRequest edcCreatePolicyDefinitionRequest = EdcCreatePolicyDefinitionRequest + .builder() + .policyDefinitionId(accessPolicyId) + .policy(edcPolicy) + .odrlContext(odrlContext) + .type(POLICY_DEFINITION_TYPE) + .build(); + log.info("EdcCreatePolicyDefinitionRequest {}", objectMapper.writeValueAsString(edcCreatePolicyDefinitionRequest)); final ResponseEntity createPolicyDefinitionResponse; try { - createPolicyDefinitionResponse = restTemplate.postForEntity(CREATE_POLICY_DEFINION_PATH, edcCreatePolicyDefinitionRequest, String.class); + createPolicyDefinitionResponse = restTemplate.postForEntity(edcProperties.getPolicyDefinitionsPath(), edcCreatePolicyDefinitionRequest, String.class); } catch (RestClientException e) { - logger.error("Failed to create EDC notification asset policy {} notification asset id. Reason: ", notificationAssetId, e); + log.error("Failed to create EDC notification asset policy. Reason: ", e); throw new CreateEdcPolicyDefinitionException(e); } @@ -91,7 +115,7 @@ public String createAccessPolicy(String notificationAssetId) { HttpStatusCode responseCode = createPolicyDefinitionResponse.getStatusCode(); if (responseCode.value() == 409) { - logger.info("{} notification asset policy definition already exists in the EDC", notificationAssetId); + log.info("Notification asset policy definition already exists in the EDC"); throw new CreateEdcPolicyDefinitionException("Notification asset policy definition already exists in the EDC"); } @@ -100,13 +124,13 @@ public String createAccessPolicy(String notificationAssetId) { return accessPolicyId; } - logger.error("Failed to create EDC notification policy definition for {} notification asset id. Body: {}, status: {}", notificationAssetId, createPolicyDefinitionResponse.getBody(), createPolicyDefinitionResponse.getStatusCode()); + log.error("Failed to create EDC notification policy definition for notification asset. Body: {}, status: {}", createPolicyDefinitionResponse.getBody(), createPolicyDefinitionResponse.getStatusCode()); - throw new CreateEdcAssetException("Failed to create EDC notification policy definition for %s asset id".formatted(notificationAssetId)); + throw new CreateEdcAssetException("Failed to create EDC notification policy definition for asset"); } public void deleteAccessPolicy(String accessPolicyId) { - String deleteUri = UriComponentsBuilder.fromPath(CREATE_POLICY_DEFINION_PATH) + String deleteUri = UriComponentsBuilder.fromPath(edcProperties.getPolicyDefinitionsPath()) .pathSegment("{accessPolicyId}") .buildAndExpand(accessPolicyId) .toUriString(); @@ -114,7 +138,7 @@ public void deleteAccessPolicy(String accessPolicyId) { try { restTemplate.delete(deleteUri); } catch (RestClientException e) { - logger.error("Failed to delete EDC notification asset policy {}. Reason: ", accessPolicyId, e); + log.error("Failed to delete EDC notification asset policy {}. Reason: ", accessPolicyId, e); } } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/properties/EdcProperties.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/properties/EdcProperties.java index b85cf84f5f..8a3c3b9b17 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/properties/EdcProperties.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/properties/EdcProperties.java @@ -21,88 +21,55 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.properties; import jakarta.validation.constraints.NotBlank; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import java.util.Map; import java.util.Set; +@AllArgsConstructor +@Getter @ConfigurationProperties("edc") public class EdcProperties { - @NotBlank - @Value("${edc.ids}") - private String idsPath; + @NotBlank + @Value("${edc.ids}") + private String idsPath; - @NotBlank - @Value("${edc.negotiation}") - private String negotiationPath; + @NotBlank + @Value("${edc.contractdefinitions}") + private String contractDefinitionsPath; - @NotBlank - @Value("${edc.transfer}") - private String transferPath; + @NotBlank + @Value("${edc.negotiation}") + private String negotiationPath; - @NotBlank - @Value("${edc.catalog}") - private String catalogPath; + @NotBlank + @Value("${edc.transfer}") + private String transferPath; - @NotBlank - private String providerEdcUrl; + @NotBlank + @Value("${edc.catalog}") + private String catalogPath; - @NotBlank - private String apiAuthKey; + @NotBlank + @Value("${edc.policydefinitions}") + private String policyDefinitionsPath; - private Map bpnProviderUrlMappings; + @NotBlank + @Value("${edc.assets}") + private String assetsPath; - private Set callbackUrls; + @NotBlank + private String providerEdcUrl; - public EdcProperties(String idsPath, - String negotiationPath, - String transferPath, - String catalogPath, - String providerEdcUrl, - String apiAuthKey, - Map bpnProviderUrlMappings, - Set callbackUrls) { - this.idsPath = idsPath; - this.negotiationPath = negotiationPath; - this.transferPath = transferPath; - this.catalogPath = catalogPath; - this.providerEdcUrl = providerEdcUrl; - this.apiAuthKey = apiAuthKey; - this.bpnProviderUrlMappings = bpnProviderUrlMappings; - this.callbackUrls = callbackUrls; - } + @NotBlank + private String apiAuthKey; - public String getIdsPath() { - return idsPath; - } + private Map bpnProviderUrlMappings; - public String getNegotiationPath() { - return negotiationPath; - } + private Set callbackUrls; - public String getTransferPath() { - return transferPath; - } - - public String getCatalogPath() { - return catalogPath; - } - - public Map getBpnProviderUrlMappings() { - return bpnProviderUrlMappings; - } - - public Set getCallbackUrls() { - return callbackUrls; - } - - public String getProviderEdcUrl() { - return providerEdcUrl; - } - - public String getApiAuthKey() { - return apiAuthKey; - } } diff --git a/tx-backend/src/main/resources/application.yml b/tx-backend/src/main/resources/application.yml index 45b1704c81..49483caa8d 100644 --- a/tx-backend/src/main/resources/application.yml +++ b/tx-backend/src/main/resources/application.yml @@ -25,13 +25,15 @@ traceability: registry.manufacturerIdKey: manufacturerId edc: - ids: "/api/v1/ids/data" - negotiation: "/api/v1/management/contractnegotiations" - transfer: "/api/v1/management/transferprocess" - catalog: "/api/v1/management/catalog/request" + ids: "/api/v1/dsp" + negotiation: "/management/v2/contractnegotiations" + contractdefinitions: "/management/v2/contractdefinitions" + transfer: "/management/v2/transferprocesses" + catalog: "/management/v2/catalog/request" + policydefinitions: "/management/v2/policydefinitions" + assets: "/management/v2/assets" api-auth-key: ${EDC_API_KEY} - bpn-provider-url-mappings: - {} + bpn-provider-url-mappings: { } provider-edc-url: ${EDC_PROVIDER_URL} server: diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcServiceTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcServiceTest.java index 82a2010a52..043adea773 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcServiceTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcServiceTest.java @@ -18,27 +18,16 @@ ********************************************************************************/ package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox; -import com.fasterxml.jackson.databind.ObjectMapper; -import okhttp3.Request; -import okhttp3.RequestBody; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.catalog.Catalog; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.notification.ContractNegotiationDto; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.notification.TransferId; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.offer.ContractOffer; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.AtomicConstraint; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.LiteralExpression; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Operator; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Permission; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transfer.DataAddress; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transfer.TransferRequestDto; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.transfer.TransferType; +import org.eclipse.edc.catalog.spi.Catalog; +import org.eclipse.edc.catalog.spi.DataService; +import org.eclipse.edc.catalog.spi.Dataset; +import org.eclipse.edc.catalog.spi.Distribution; +import org.eclipse.edc.policy.model.Policy; +import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.jsontransformer.EdcTransformer; import org.eclipse.tractusx.traceability.infrastructure.edc.properties.EdcProperties; -import org.eclipse.tractusx.traceability.qualitynotification.domain.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.model.QualityNotificationType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.runner.Request; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.InjectMocks; @@ -46,27 +35,11 @@ import org.mockito.junit.jupiter.MockitoExtension; import java.io.IOException; -import java.util.HashMap; -import java.util.List; +import java.util.Collections; import java.util.Map; -import java.util.Optional; -import static java.util.Collections.emptyList; -import static java.util.Collections.emptyMap; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.EdcService.JSON; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset.Builder; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset.PROPERTY_CONTENT_TYPE; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset.PROPERTY_DESCRIPTION; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset.PROPERTY_ID; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset.PROPERTY_NAME; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset.PROPERTY_NOTIFICATION_METHOD; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset.PROPERTY_NOTIFICATION_TYPE; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset.PROPERTY_VERSION; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -76,219 +49,45 @@ class EdcServiceTest { @Mock private HttpCallService httpCallService; - @Mock - private ObjectMapper objectMapper; - - @Mock - private EdcProperties edcProperties; - @InjectMocks private EdcService edcService; - private static final String CONSUMER_EDC_DATA_MANAGEMENT_URL = "http://consumer-edc-data-management.com"; - private static final String PROVIDER_CONNECTOR_CONTROL_PLANE_IDS_URL = "http://provider-connector-control-plane-ids.com"; + @Mock + private EdcProperties edcProperties; + @Mock + private EdcTransformer edcTransformer; @Captor private ArgumentCaptor requestCaptor; @Test - void givenEmptyCatalogContractOffers_whenFindNotificationContractOffer_thenThrowBadRequestException() throws IOException { - // given - Catalog catalog = Catalog.Builder.newInstance().id("234").contractOffers(emptyList()).build(); - QualityNotificationMessage qualityNotificationMessage = QualityNotificationMessage.builder().type(QualityNotificationType.INVESTIGATION).isInitial(true).build(); - - Map header = new HashMap<>(); - when(httpCallService.getCatalogFromProvider(CONSUMER_EDC_DATA_MANAGEMENT_URL, PROVIDER_CONNECTOR_CONTROL_PLANE_IDS_URL, header)).thenReturn(catalog); - - // when - assertThrows(BadRequestException.class, () -> edcService.findNotificationContractOffer(CONSUMER_EDC_DATA_MANAGEMENT_URL, - PROVIDER_CONNECTOR_CONTROL_PLANE_IDS_URL, header, qualityNotificationMessage)); - } - - @Test - void testFindNotificationContractOfferForInitialNotification() throws IOException { - // given - Map properties = new HashMap<>(); - properties.put(PROPERTY_ID, 123); - properties.put(PROPERTY_NAME, "My Asset"); - properties.put(PROPERTY_DESCRIPTION, "This is a description of my asset."); - properties.put(PROPERTY_VERSION, 1.0); - properties.put(PROPERTY_CONTENT_TYPE, "image/jpeg"); - properties.put(PROPERTY_NOTIFICATION_TYPE, "qualityinvestigation"); - properties.put(PROPERTY_NOTIFICATION_METHOD, "receive"); - QualityNotificationMessage qualityNotificationMessage = QualityNotificationMessage.builder().type(QualityNotificationType.INVESTIGATION).isInitial(true).build(); - - Permission permission = Permission.Builder.newInstance() - .constraint(AtomicConstraint.Builder.newInstance() - .leftExpression(new LiteralExpression("idsc:PURPOSE")) - .rightExpression(new LiteralExpression("ID 3.0 Trace")) - .operator(Operator.EQ) - .build() - ) - .build(); - Policy policy = Policy.Builder.newInstance().permission(permission).build(); - Asset asset = Builder.newInstance().properties(properties).build(); - ContractOffer expectedContractOffer = ContractOffer.Builder.newInstance().id("123").policy(policy).asset(asset).build(); - Catalog catalog = Catalog.Builder.newInstance().id("234").contractOffers(List.of(expectedContractOffer)).build(); - - - Map header = new HashMap<>(); - when(httpCallService.getCatalogFromProvider(CONSUMER_EDC_DATA_MANAGEMENT_URL, PROVIDER_CONNECTOR_CONTROL_PLANE_IDS_URL, header)).thenReturn(catalog); - - // when - Optional contractOfferResult = edcService.findNotificationContractOffer(CONSUMER_EDC_DATA_MANAGEMENT_URL, - PROVIDER_CONNECTOR_CONTROL_PLANE_IDS_URL, header, qualityNotificationMessage); - - // then - assertTrue(contractOfferResult.isPresent()); - assertEquals(expectedContractOffer, contractOfferResult.get()); - } - - @Test - void testFindNotificationContractOfferForUpdateNotification() throws IOException { - // given - Map properties = new HashMap<>(); - properties.put(PROPERTY_ID, 123); - properties.put(PROPERTY_NAME, "My Asset"); - properties.put(PROPERTY_DESCRIPTION, "This is a description of my asset."); - properties.put(PROPERTY_VERSION, 1.0); - properties.put(PROPERTY_CONTENT_TYPE, "image/jpeg"); - properties.put(PROPERTY_NOTIFICATION_TYPE, "qualityinvestigation"); - properties.put(PROPERTY_NOTIFICATION_METHOD, "update"); - QualityNotificationMessage qualityNotificationMessage = QualityNotificationMessage.builder().type(QualityNotificationType.INVESTIGATION).isInitial(false).build(); - - - Permission permission = Permission.Builder.newInstance() - .constraint(AtomicConstraint.Builder.newInstance() - .leftExpression(new LiteralExpression("idsc:PURPOSE")) - .rightExpression(new LiteralExpression("ID 3.0 Trace")) - .operator(Operator.EQ) - .build() - ) - .build(); - Policy policy = Policy.Builder.newInstance().permission(permission).build(); - Asset asset = Builder.newInstance().properties(properties).build(); - ContractOffer expectedContractOffer = ContractOffer.Builder.newInstance().id("123").policy(policy).asset(asset).build(); - Catalog catalog = Catalog.Builder.newInstance().id("234").contractOffers(List.of(expectedContractOffer)).build(); - - - Map header = new HashMap<>(); - when(httpCallService.getCatalogFromProvider(CONSUMER_EDC_DATA_MANAGEMENT_URL, PROVIDER_CONNECTOR_CONTROL_PLANE_IDS_URL, header)).thenReturn(catalog); - - // when - Optional contractOfferResult = edcService.findNotificationContractOffer(CONSUMER_EDC_DATA_MANAGEMENT_URL, - PROVIDER_CONNECTOR_CONTROL_PLANE_IDS_URL, header, qualityNotificationMessage); - - // then - assertTrue(contractOfferResult.isPresent()); - assertEquals(expectedContractOffer, contractOfferResult.get()); - } - - @Test - void testFindNotificationContractOfferWrongNotificationType() throws IOException { - // given - Map properties = new HashMap<>(); - properties.put(PROPERTY_ID, 123); - properties.put(PROPERTY_NAME, "My Asset"); - properties.put(PROPERTY_DESCRIPTION, "This is a description of my asset."); - properties.put(PROPERTY_VERSION, 1.0); - properties.put(PROPERTY_CONTENT_TYPE, "image/jpeg"); - properties.put(PROPERTY_NOTIFICATION_TYPE, "asfd"); - properties.put(PROPERTY_NOTIFICATION_METHOD, "receive"); - QualityNotificationMessage qualityNotificationMessage = QualityNotificationMessage.builder().type(QualityNotificationType.INVESTIGATION).isInitial(false).build(); + void testGetCatalog() throws IOException { + // Arrange + String consumerEdcDataManagementUrl = "https://example.com/consumer-edc"; + String providerConnectorControlPlaneIDSUrl = "https://example.com/provider-connector"; + Map header = Collections.singletonMap("Authorization", "Bearer token"); Policy policy = Policy.Builder.newInstance().build(); - Asset asset = Builder.newInstance().properties(properties).build(); - ContractOffer expectedContractOffer = ContractOffer.Builder.newInstance().id("123").policy(policy).asset(asset).build(); - Catalog catalog = Catalog.Builder.newInstance().id("234").contractOffers(List.of(expectedContractOffer)).build(); - - - Map header = new HashMap<>(); - when(httpCallService.getCatalogFromProvider(CONSUMER_EDC_DATA_MANAGEMENT_URL, - PROVIDER_CONNECTOR_CONTROL_PLANE_IDS_URL, header)).thenReturn(catalog); - - // when - Optional contractOfferResult = - edcService.findNotificationContractOffer(CONSUMER_EDC_DATA_MANAGEMENT_URL, - PROVIDER_CONNECTOR_CONTROL_PLANE_IDS_URL, header, qualityNotificationMessage); - - // then - assertTrue(contractOfferResult.isEmpty()); - } - - @Test - void givenAssetId_whenInitializeContractNegotiation_thenProcessCorrectly() throws IOException, InterruptedException { - // given - final String providerConnectorUrl = "http://provider"; - final String assetId = "assetId"; - final String offerId = "offerId"; - final Policy policy = null; - final String consumerEdcUrl = "http://consumer"; - final Map headers = emptyMap(); - final ContractNegotiationDto negotiation = ContractNegotiationDto.Builder.newInstance() - .id("negotiationId") - .state("CONFIRMED") - .contractAgreementId("contractAgreementId") - .build(); - final TransferId transferId = TransferId.Builder.newInstance() - .id("transferId") - .build(); - - when(edcProperties.getIdsPath()).thenReturn("/path"); - when(objectMapper.writeValueAsString(any())).thenReturn("requestBody"); - when(httpCallService.sendRequest( - any(), - any())).thenReturn(transferId).thenReturn(negotiation); - - // when - final String result = edcService.initializeContractNegotiation( - providerConnectorUrl, - assetId, - offerId, - policy, - consumerEdcUrl, - headers); - - // then - assertThat(result).isEqualTo("contractAgreementId"); - - } - @Test - void givenData_whenInitiateHttpProxyTransferProcess_thenProperRequestIsSent() throws IOException { - // given - final String agreementId = "agreementId"; - final String assetId = "assetId"; - final String consumerEdcDataManagementUrl = "http://consumerUrl"; - final String providerConnectorControlPlaneIDSUrl = "http://providerUrl"; - final Map headers = emptyMap(); - - var url = consumerEdcDataManagementUrl + edcProperties.getTransferPath(); - - DataAddress dataDestination = DataAddress.Builder.newInstance().type("HttpProxy").build(); - TransferType transferType = TransferType.Builder.transferType().contentType("application/octet-stream").isFinite(true).build(); - - TransferRequestDto transferRequest = TransferRequestDto.Builder.newInstance() - .assetId(assetId).contractId(agreementId).connectorId("provider").connectorAddress(providerConnectorControlPlaneIDSUrl) - .protocol("ids-multipart").dataDestination(dataDestination).managedResources(false).transferType(transferType) + DataService dataService = DataService.Builder.newInstance() .build(); + Distribution distribution = Distribution.Builder.newInstance().format("format") + .dataService(dataService).build(); - when(objectMapper.writeValueAsString(any())).thenReturn("request"); - - var requestBody = RequestBody.create(objectMapper.writeValueAsString(transferRequest), JSON); - var request = new Request.Builder().url(url).post(requestBody); - - headers.forEach(request::addHeader); + Dataset dataset = Dataset.Builder.newInstance().offer("123", policy).distribution(distribution).build(); - // when - edcService.initiateHttpProxyTransferProcess(agreementId, assetId, consumerEdcDataManagementUrl, providerConnectorControlPlaneIDSUrl, headers); + Catalog catalog = Catalog.Builder.newInstance().dataset(dataset).build(); - // then - verify(httpCallService).sendRequest(requestCaptor.capture(), any()); + when(httpCallService.getCatalogForNotification(consumerEdcDataManagementUrl, providerConnectorControlPlaneIDSUrl, header)) + .thenReturn(catalog); - final Request sentRequest = requestCaptor.getValue(); + // Act + Catalog catalogResult = edcService.getCatalog(consumerEdcDataManagementUrl, providerConnectorControlPlaneIDSUrl, header); - assertThat(sentRequest).usingRecursiveComparison().isEqualTo(request.build()); + assertThat(catalogResult).isNotNull(); + // Assert + verify(httpCallService, times(1)) + .getCatalogForNotification(consumerEdcDataManagementUrl, providerConnectorControlPlaneIDSUrl, header); } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/agreement/ContractAgreementTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/agreement/ContractAgreementTest.java deleted file mode 100644 index d6588f5273..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/agreement/ContractAgreementTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.agreement; - -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; -import org.eclipse.tractusx.traceability.infrastructure.test.support.ContractAgreementMother; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -class ContractAgreementTest { - - @Test - void givenContractAgreement_shouldHaveProperValues() { - // given - final Policy policy = ContractAgreementMother.getPolicy(); - final ContractAgreement contractAgreement = ContractAgreementMother.getContractAgreement(policy); - - // then - assertThat(contractAgreement) - .hasFieldOrPropertyWithValue("id", "id") - .hasFieldOrPropertyWithValue("providerAgentId","providerAgentId") - .hasFieldOrPropertyWithValue("consumerAgentId","consumerAgentId") - .hasFieldOrPropertyWithValue("contractSigningDate",1L) - .hasFieldOrPropertyWithValue("contractStartDate", 2L) - .hasFieldOrPropertyWithValue("contractEndDate", 3L) - .hasFieldOrPropertyWithValue("assetId", "assetId") - .hasFieldOrPropertyWithValue("policy", policy); - } -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogRequestTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogRequestTest.java deleted file mode 100644 index e930dcd3f6..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogRequestTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.catalog; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -@ExtendWith(MockitoExtension.class) -class CatalogRequestTest { - - private static final String protocol = "protocol"; - private static final String connectorId = "connectorId"; - private static final String connectorAddress = "connectorAddress"; - - private CatalogRequest catalogRequest; - - @BeforeEach - void setUp() { - catalogRequest = CatalogRequest.Builder.newInstance() - .protocol(protocol) - .connectorId(connectorId) - .connectorAddress(connectorAddress) - .build(); - } - - @Test - void getProtocol() { - assertEquals(protocol, catalogRequest.getProtocol()); - } - - @Test - void getConnectorId() { - assertEquals(connectorId, catalogRequest.getConnectorId()); - } - - @Test - void getConnectorAddress() { - assertEquals(connectorAddress, catalogRequest.getConnectorAddress()); - } -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogTest.java deleted file mode 100644 index b84718a1a9..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/catalog/CatalogTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.catalog; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.offer.ContractOffer; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.Asset.*; -import static org.junit.jupiter.api.Assertions.assertEquals; - -@ExtendWith(MockitoExtension.class) -class CatalogTest { - - private static final String id = "id"; - private static final List contractOffers = new ArrayList<>(); - - private Catalog catalog; - - @BeforeEach - void setUp() { - Map properties = new HashMap<>(); - properties.put(PROPERTY_ID, 123); - properties.put(PROPERTY_NAME, "My Asset"); - properties.put(PROPERTY_DESCRIPTION, "This is a description of my asset."); - properties.put(PROPERTY_VERSION, 1.0); - properties.put(PROPERTY_CONTENT_TYPE, "image/jpeg"); - properties.put(PROPERTY_NOTIFICATION_TYPE, "qualityinvestigation"); - properties.put(PROPERTY_NOTIFICATION_METHOD, "update"); - Policy policy = Policy.Builder.newInstance().build(); - Asset asset = Asset.Builder.newInstance().properties(properties).build(); - ContractOffer contractOffer = ContractOffer.Builder.newInstance() - .policy(policy) - .asset(asset) - .id(id) - .build(); - contractOffers.add(contractOffer); - catalog = Catalog.Builder.newInstance() - .id(id) - .contractOffers(contractOffers) - .build(); - } - - @Test - void getId() { - assertEquals(id, catalog.getId()); - } - - @Test - void getContractOffers() { - assertEquals(contractOffers.size(), catalog.getContractOffers().size()); - } -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiationStatesTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiationStatesTest.java deleted file mode 100644 index 9373a68815..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiationStatesTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************** - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.negotiation; - -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.CONFIRMED; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.CONFIRMING; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.CONSUMER_APPROVED; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.CONSUMER_APPROVING; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.CONSUMER_OFFERED; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.CONSUMER_OFFERING; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.DECLINED; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.DECLINING; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.ERROR; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.INITIAL; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.PROVIDER_OFFERED; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.PROVIDER_OFFERING; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.REQUESTED; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.REQUESTING; -import static org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiationStates.UNSAVED; - -class ContractNegotiationStatesTest { - - private final static int NON_EXISTENT_CODE = 69; - - @ParameterizedTest - @MethodSource("provideContractNegotiationStates") - void givenContractNegotiationState_whenFrom_thenReturnCorrectState( - ContractNegotiationStates expectedResult, - Integer input - ) { - // when - final ContractNegotiationStates result = ContractNegotiationStates.from(input); - - // then - assertThat(result).isEqualTo(expectedResult); - } - - private static Stream provideContractNegotiationStates() { - return Stream.of( - Arguments.of(UNSAVED, 0), - Arguments.of(INITIAL, 50), - Arguments.of(REQUESTING, 100), - Arguments.of(REQUESTED, 200), - Arguments.of(PROVIDER_OFFERING, 300), - Arguments.of(PROVIDER_OFFERED, 400), - Arguments.of(CONSUMER_OFFERING, 500), - Arguments.of(CONSUMER_OFFERED, 600), - Arguments.of(CONSUMER_APPROVING, 700), - Arguments.of(CONSUMER_APPROVED, 800), - Arguments.of(DECLINING, 900), - Arguments.of(DECLINED, 1000), - Arguments.of(CONFIRMING, 1100), - Arguments.of(CONFIRMED, 1200), - Arguments.of(ERROR, -1), - Arguments.of(null, NON_EXISTENT_CODE) - - ); - } - - ; - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiationTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiationTest.java deleted file mode 100644 index f762aed51e..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractNegotiationTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.negotiation; - -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.agreement.ContractAgreement; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.offer.ContractOffer; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; - -@ExtendWith(MockitoExtension.class) -class ContractNegotiationTest { - - private static final ContractNegotiation.Type type = ContractNegotiation.Type.CONSUMER; - private static final String id = "id"; - private static final String counterPartyId = "counterPartyId"; - private static final String counterPartyAddress = "counterPartyAddress"; - private static final String correlationId = "correlationId"; - private static final String protocol = "protocol"; - private static final int state = 9; - private static final int stateCount = 99; - private static final long stateTimestamp = 999L; - private static final String errorDetail = "errorDetail"; - private static final String providerAgentId = "providerAgentId"; - private static final String consumerAgentId = "consumerAgentId"; - private static final String assetId = "assetId"; - - static ContractOffer contractOffer; - static List contractOffers; - static ContractNegotiation contractNegotiation; - static Map traceContext; - static ContractAgreement contractAgreement; - - @BeforeEach - void beforeEach() { - Policy policy = Policy.Builder.newInstance().build(); - contractOffer = ContractOffer.Builder.newInstance() - .id(id) - .policy(policy) - .build(); - contractOffers = new ArrayList<>(); - contractOffers.add(contractOffer); - traceContext = new HashMap<>(); - traceContext.put("key0", "value"); - contractAgreement = ContractAgreement.Builder.newInstance() - .id(id) - .providerAgentId(providerAgentId) - .consumerAgentId(consumerAgentId) - .policy(policy) - .assetId(assetId) - .build(); - contractNegotiation = ContractNegotiation.Builder.newInstance() - .type(type) - .id(id) - .counterPartyId(counterPartyId) - .counterPartyAddress(counterPartyAddress) - .correlationId(correlationId) - .protocol(protocol) - .state(state) - .stateCount(stateCount) - .stateTimestamp(stateTimestamp) - .contractOffers(contractOffers) - .traceContext(traceContext) - .contractAgreement(contractAgreement) - .errorDetail(errorDetail) - .build(); - } - - @Test - void getType() { - assertEquals(type.name(), contractNegotiation.getType().name()); - } - - @Test - void getId() { - assertEquals(id, contractNegotiation.getId()); - } - - @Test - void getCounterPartyId() { - assertEquals(counterPartyId, contractNegotiation.getCounterPartyId()); - } - - @Test - void getCounterPartyAddress() { - assertEquals(counterPartyAddress, contractNegotiation.getCounterPartyAddress()); - } - - @Test - void getCorrelationId() { - assertEquals(correlationId, contractNegotiation.getCorrelationId()); - } - - @Test - void getProtocol() { - assertEquals(protocol, contractNegotiation.getProtocol()); - } - - @Test - void getState() { - assertEquals(state, contractNegotiation.getState()); - } - - @Test - void getStateCount() { - assertEquals(stateCount, contractNegotiation.getStateCount()); - } - - @Test - void getStateTimestamp() { - assertEquals(stateTimestamp, contractNegotiation.getStateTimestamp()); - } - - @Test - void getContractOffers() { - assertEquals(contractOffers.size(), contractNegotiation.getContractOffers().size()); - } - - @Test - void getErrorDetail() { - assertEquals(errorDetail, contractNegotiation.getErrorDetail()); - } - - @Test - void getTraceContext() { - assertEquals(traceContext, contractNegotiation.getTraceContext()); - } - - @Test - void getLastContractOffer() { - assertEquals(contractOffer, contractNegotiation.getLastContractOffer()); - } - - @Test - void getContractAgreement() { - assertEquals(contractAgreement, contractNegotiation.getContractAgreement()); - } - - @Test - void addContractOffer() { - // given - final ContractOffer offer = ContractOffer.Builder - .newInstance() - .id("testId") - .policy(contractAgreement.getPolicy()) - .build(); - assertThat(contractNegotiation.getContractOffers()).hasSize(1); - - - // when - contractNegotiation.addContractOffer(offer); - - // then - assertThat(contractNegotiation.getContractOffers()).hasSize(2); - } - - @Test - void setErrorDetail() { - // given - final String errorDetail = "this is bad"; - assertThat(contractNegotiation.getErrorDetail()).isEqualTo("errorDetail"); - - // when - contractNegotiation.setErrorDetail(errorDetail); - - // then - assertThat(contractNegotiation.getErrorDetail()).isEqualTo(errorDetail); - } - - @Test - void whenNoContractOffers_getLastContractOffer_thenNull() { - // given - contractNegotiation.getContractOffers().clear(); - assertThat(contractNegotiation.getContractOffers()).isEmpty(); - - // when - final ContractOffer result = contractNegotiation.getLastContractOffer(); - - // then - assertThat(result).isNull(); - } - - @Test - void setContractAgreement() { - // given - final ContractAgreement agreement = ContractAgreement.Builder.newInstance() - .id("someId") - .providerAgentId(providerAgentId) - .consumerAgentId(consumerAgentId) - .policy(contractOffer.getPolicy()) - .assetId(assetId) - .build(); - assertThat(contractNegotiation.getContractAgreement()).isNotEqualTo(agreement); - - // when - contractNegotiation.setContractAgreement(agreement); - - // then - assertThat(contractNegotiation.getContractAgreement()).isEqualTo(agreement); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractRejectionTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractRejectionTest.java deleted file mode 100644 index 442d4eb9a7..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/negotiation/ContractRejectionTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.negotiation; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class ContractRejectionTest { - - private static final String protocol = "protocol"; - private static final String connectorId = "connectorId"; - private static final String connectorAddress = "connectorAddress"; - private static final String correlationId = "correlationId"; - private static final String rejectionReason = "rejectionReason"; - - private ContractRejection contractRejection; - - @BeforeEach - void setUp() { - contractRejection = ContractRejection.Builder.newInstance() - .protocol(protocol) - .connectorId(connectorId) - .connectorAddress(connectorAddress) - .correlationId(correlationId) - .rejectionReason(rejectionReason) - .build(); - } - - @Test - void getProtocol() { - assertEquals(protocol, contractRejection.getProtocol()); - } - - @Test - void getConnectorId() { - assertEquals(connectorId, contractRejection.getConnectorId()); - } - - @Test - void getConnectorAddress() { - assertEquals(connectorAddress, contractRejection.getConnectorAddress()); - } - - @Test - void getCorrelationId() { - assertEquals(correlationId, contractRejection.getCorrelationId()); - } - - @Test - void getRejectionReason() { - assertEquals(rejectionReason, contractRejection.getRejectionReason()); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractNegotiationDtoTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractNegotiationDtoTest.java deleted file mode 100644 index a47fe45228..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractNegotiationDtoTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.notification; - -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.negotiation.ContractNegotiation; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class ContractNegotiationDtoTest { - - private static final String contractAgreementId = "contractAgreementId"; - private static final String counterPartyAddress = "counterPartyAddress"; - private static final String errorDetail = "errorDetail"; - private static final String id = "id"; - private static final String protocol = "ids-multipart"; - private static final String state = "state"; - private static final ContractNegotiation.Type type = ContractNegotiation.Type.CONSUMER; - - static ContractNegotiationDto contractNegotiationDto; - - @BeforeAll - static void beforeAll() { - contractNegotiationDto = ContractNegotiationDto.Builder.newInstance() - .contractAgreementId(contractAgreementId) - .counterPartyAddress(counterPartyAddress) - .errorDetail(errorDetail) - .id(id) - .protocol(protocol) - .state(state) - .type(type) - .build(); - } - - @Test - void getId() { - assertEquals(id, contractNegotiationDto.getId()); - } - - @Test - void getCounterPartyAddress() { - assertEquals(counterPartyAddress, contractNegotiationDto.getCounterPartyAddress()); - } - - @Test - void getProtocol() { - assertEquals(protocol, contractNegotiationDto.getProtocol()); - } - - @Test - void getType() { - assertEquals(type, contractNegotiationDto.getType()); - } - - @Test - void getState() { - assertEquals(state, contractNegotiationDto.getState()); - } - - @Test - void getErrorDetail() { - assertEquals(errorDetail, contractNegotiationDto.getErrorDetail()); - } - - @Test - void getContractAgreementId() { - assertEquals(contractAgreementId, contractNegotiationDto.getContractAgreementId()); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractOfferDescriptionTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractOfferDescriptionTest.java deleted file mode 100644 index fffcd5262a..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/ContractOfferDescriptionTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.notification; - -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Prohibition; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -@ExtendWith(MockitoExtension.class) -class ContractOfferDescriptionTest { - - private static final String offerId = "offerId"; - private static final String assetId = "assetId"; - private static final String policyId = "policyId"; - - static ContractOfferDescription contractOfferDescription; - - @BeforeAll - static void beforeAll() { - Prohibition prohibition = Prohibition.Builder.newInstance().assignee("ME").build(); - Policy policy = Policy.Builder.newInstance() - .assignee("ME") - .prohibition(prohibition) - .build(); - contractOfferDescription = new ContractOfferDescription( - offerId, assetId, policyId, policy - ); - } - - @Test - void getOfferId() { - assertEquals("offerId", contractOfferDescription.getOfferId()); - } - - @Test - void getAssetId() { - assertEquals("assetId", contractOfferDescription.getAssetId()); - } - - @Test - void getPolicyId() { - assertEquals("policyId", contractOfferDescription.getPolicyId()); - } - - @Test - void getPolicy() { - assertEquals("ME", contractOfferDescription.getPolicy().getAssignee()); - assertEquals("ME", contractOfferDescription.getPolicy().getProhibitions().get(0).getAssignee()); - } -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationIdTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationIdTest.java deleted file mode 100644 index 4059ee2bec..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationIdTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.notification; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class NegotiationIdTest { - - private static final String id = "negotiationId"; - - static NegotiationId negotiationId; - - @BeforeAll - static void beforeAll() { - negotiationId = NegotiationId.Builder.newInstance() - .id(id) - .build(); - } - - @Test - void getId() { - assertEquals(id, negotiationId.getId()); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationInitiateRequestDtoTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationInitiateRequestDtoTest.java deleted file mode 100644 index 9062a6f7d0..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/NegotiationInitiateRequestDtoTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.notification; - -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Policy; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.policy.Prohibition; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class NegotiationInitiateRequestDtoTest { - - private static final String offerId = "offerId"; - private static final String assetId = "assetId"; - private static final String policyId = "policyId"; - - private static final String connectorAddress = "connectorAddress"; - private static final String protocol = "ids-multipart"; - private static final String connectorId = "connectorId"; - - static ContractOfferDescription contractOfferDescription; - static NegotiationInitiateRequestDto negotiationInitiateRequestDto; - - @BeforeAll - static void beforeAll() { - Prohibition prohibition = Prohibition.Builder.newInstance().assignee("ME").build(); - Policy policy = Policy.Builder.newInstance() - .assignee("ME") - .prohibition(prohibition) - .build(); - contractOfferDescription = new ContractOfferDescription( - offerId, assetId, policyId, policy - ); - negotiationInitiateRequestDto = NegotiationInitiateRequestDto.Builder.newInstance() - .connectorAddress(connectorAddress) - .protocol(protocol) - .connectorId(connectorId) - .build(); - } - - @Test - void getConnectorAddress() { - assertEquals(connectorAddress, negotiationInitiateRequestDto.getConnectorAddress()); - } - - @Test - void getProtocol() { - assertEquals(protocol, negotiationInitiateRequestDto.getProtocol()); - } - - @Test - void getConnectorId() { - assertEquals(connectorId, negotiationInitiateRequestDto.getConnectorId()); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/TransferIdTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/TransferIdTest.java deleted file mode 100644 index 2fd2bd4df0..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/notification/TransferIdTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.notification; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class TransferIdTest { - - private static final String id = "transferId"; - - static TransferId transferId; - - @BeforeAll - static void beforeAll() { - transferId = TransferId.Builder.newInstance() - .id(id) - .build(); - } - - @Test - void getId() { - assertEquals(id, transferId.getId()); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/offer/ContractDefinitionTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/offer/ContractDefinitionTest.java deleted file mode 100644 index 5c1b2417d9..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/offer/ContractDefinitionTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.offer; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.asset.AssetSelectorExpression; -import org.eclipse.tractusx.traceability.infrastructure.edc.blackbox.query.Criterion; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -@ExtendWith(MockitoExtension.class) -class ContractDefinitionTest { - - private static final String id = "id"; - private static final String accessPolicyId = "accessPolicyId"; - private static final String contractPolicyId = "contractPolicyId"; - - private AssetSelectorExpression selectorExpression; - private ContractDefinition contractDefinition; - - @BeforeEach - void setUp() { - List criteria = new ArrayList<>(); - selectorExpression = AssetSelectorExpression.Builder.newInstance() - .criteria(criteria) - .build(); - contractDefinition = ContractDefinition.Builder.newInstance() - .id(id) - .accessPolicyId(accessPolicyId) - .contractPolicyId(contractPolicyId) - .selectorExpression(selectorExpression) - .build(); - } - - @Test - void getId() { - assertEquals(id, contractDefinition.getId()); - } - - @Test - void getAccessPolicyId() { - assertEquals(accessPolicyId, contractDefinition.getAccessPolicyId()); - } - - @Test - void getContractPolicyId() { - assertEquals(contractPolicyId, contractDefinition.getContractPolicyId()); - } - - @Test - void getSelectorExpression() { - assertEquals(selectorExpression, contractDefinition.getSelectorExpression()); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/query/CriterionTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/query/CriterionTest.java deleted file mode 100644 index 1ac1ea614b..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/query/CriterionTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.query; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class CriterionTest { - - private static final String LEFT = "abc"; - private static final String OP_EQUALS = "="; - private static final String RIGHT = "xyz"; - - private Criterion criterion; - - @BeforeEach - void setUp() { - criterion = new Criterion(CriterionTest.LEFT, CriterionTest.OP_EQUALS, CriterionTest.RIGHT); - } - - @Test - void getOperandLeft() { - assertEquals(CriterionTest.LEFT, criterion.getOperandLeft()); - } - - @Test - void getOperator() { - assertEquals(CriterionTest.OP_EQUALS, criterion.getOperator()); - } - - @Test - void getOperandRight() { - assertEquals(CriterionTest.RIGHT, criterion.getOperandRight()); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataAddressTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataAddressTest.java deleted file mode 100644 index 1124c90702..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataAddressTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.transfer; - -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class DataAddressTest { - - public static final String type = "type"; - public static final String property = "property"; - public static final String keyName = "keyName"; - private static final Map properties = new HashMap<>(); - - private DataAddress dataAddress; - - @BeforeEach - void setUp() { - properties.put(property, property); - properties.put(keyName, keyName); - dataAddress = DataAddress.Builder.newInstance() - .type(type) - .property(property, property) - .properties(properties) - .build(); - } - - @Test - void getType() { - assertEquals(type, dataAddress.getType()); - } - - @Test - void getProperty() { - assertEquals(property, dataAddress.getProperty(property)); - } - - @Test - void getKeyName() { - assertEquals(keyName, dataAddress.getKeyName()); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataFlowRequestTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataFlowRequestTest.java deleted file mode 100644 index 01605c560c..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/DataFlowRequestTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.transfer; - -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class DataFlowRequestTest { - - private static final String processId = "processId"; - private static final boolean trackable = false; - private static final String id = "id"; - private static final String type = "type"; - - private Map properties; - private Map traceContext; - private DataAddress sourceDataAddress; - private DataAddress destinationDataAddress; - private DataFlowRequest request; - - @BeforeEach - void setUp() { - sourceDataAddress = DataAddress.Builder.newInstance() - .type(type) - .build(); - destinationDataAddress = DataAddress.Builder.newInstance() - .type(type) - .build(); - properties = new HashMap<>(); - properties.put(id, processId); - traceContext = new HashMap<>(); - traceContext.put(id, processId); - request = DataFlowRequest.Builder.newInstance() - .processId(processId) - .sourceDataAddress(sourceDataAddress) - .destinationDataAddress(destinationDataAddress) - .trackable(trackable) - .id(id) - .properties(properties) - .traceContext(traceContext) - .build(); - } - - @Test - void getId() { - assertEquals(id, request.getId()); - } - - @Test - void getProcessId() { - assertEquals(processId, request.getProcessId()); - } - - @Test - void getSourceDataAddress() { - assertEquals(sourceDataAddress, request.getSourceDataAddress()); - } - - @Test - void getDestinationDataAddress() { - assertEquals(destinationDataAddress, request.getDestinationDataAddress()); - } - - @Test - void isTrackable() { - assertFalse(request.isTrackable()); - } - - @Test - void getProperties() { - assertEquals(properties.keySet().size(), request.getProperties().keySet().size()); - assertTrue(processId.equalsIgnoreCase(request.getProperties().get(id))); - } - - @Test - void getTraceContext() { - assertTrue(traceContext.keySet().size() == request.getTraceContext().keySet().size() - && processId.equalsIgnoreCase(request.getTraceContext().get(id))); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferRequestDtoTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferRequestDtoTest.java deleted file mode 100644 index bf42286782..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferRequestDtoTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.transfer; - -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@ExtendWith(MockitoExtension.class) -class TransferRequestDtoTest { - - private static final String connectorAddress = "connectorAddress"; - private static final String id = "id"; - private static final String contractId = "contractId"; - private static final boolean managedResources = true; - private static final String protocol = "ids-multipart"; - private static final String connectorId = "connectorId"; - private static final String assetId = "assetId"; - public static final String type = "type"; - - private DataAddress dataDestination; - private Map properties; - private TransferType transferType; - private TransferRequestDto transferRequestDto; - - @BeforeEach - void setUp() { - properties = new HashMap<>(); - properties.put(id, id); - transferType = TransferType.Builder.transferType().build(); - dataDestination = DataAddress.Builder.newInstance() - .type(type) - .build(); - transferRequestDto = TransferRequestDto.Builder.newInstance() - .connectorAddress(connectorAddress) - .id(id) - .contractId(contractId) - .dataDestination(dataDestination) - .managedResources(managedResources) - .properties(properties) - .transferType(transferType) - .protocol(protocol) - .connectorId(connectorId) - .assetId(assetId) - .build(); - } - - @Test - void getConnectorAddress() { - assertEquals(connectorAddress, transferRequestDto.getConnectorAddress()); - } - - @Test - void getId() { - assertEquals(id, transferRequestDto.getId()); - } - - @Test - void getContractId() { - assertEquals(contractId, transferRequestDto.getContractId()); - } - - @Test - void getDataDestination() { - assertEquals(dataDestination, transferRequestDto.getDataDestination()); - } - - @Test - void isManagedResources() { - assertTrue(transferRequestDto.isManagedResources()); - } - - @Test - void getProperties() { - assertEquals(properties, transferRequestDto.getProperties()); - } - - @Test - void getTransferType() { - assertEquals(transferType, transferRequestDto.getTransferType()); - } - - @Test - void getProtocol() { - assertEquals(protocol, transferRequestDto.getProtocol()); - } - - @Test - void getConnectorId() { - assertEquals(connectorId, transferRequestDto.getConnectorId()); - } - - @Test - void getAssetId() { - assertEquals(assetId, transferRequestDto.getAssetId()); - } - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferTypeTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferTypeTest.java deleted file mode 100644 index 1d9bc49d5f..0000000000 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/transfer/TransferTypeTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 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.traceability.infrastructure.edc.blackbox.transfer; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class TransferTypeTest { - - private static final String contentType = "contentType"; - - private TransferType transferType; - - @BeforeEach - void setUp() { - transferType = TransferType.Builder.transferType() - .contentType(contentType) - .isFinite(true) - .build(); - } - - @Test - void getContentType() { - assertEquals(contentType, transferType.getContentType()); - } - - @Test - void isFinite() { - assertTrue(transferType.isFinite()); - } -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractServiceTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractServiceTest.java index 273d693e11..239591e506 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractServiceTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractServiceTest.java @@ -21,6 +21,7 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.service; +import com.fasterxml.jackson.core.JsonProcessingException; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.CreateNotificationContractRequest; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.CreateNotificationContractResponse; import org.eclipse.tractusx.traceability.infrastructure.edc.notificationcontract.controller.model.NotificationMethod; @@ -34,7 +35,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) @@ -57,23 +58,23 @@ class EdcNotificationContractServiceTest { private static final String contractDefinitionId = "999"; @BeforeEach - void setUp() { + void setUp() throws JsonProcessingException { NotificationType notificationType = NotificationType.QUALITY_INVESTIGATION; NotificationMethod notificationMethod = NotificationMethod.RESOLVE; request = new CreateNotificationContractRequest(notificationType, notificationMethod); when(edcNotitifcationAssetService.createNotificationAsset(notificationMethod, request.notificationType())).thenReturn(notificationAssetId); - when(edcPolicyDefinitionService.createAccessPolicy(notificationAssetId)).thenReturn(accessPolicyId); + when(edcPolicyDefinitionService.createAccessPolicy()).thenReturn(accessPolicyId); when(edcContractDefinitionService.createContractDefinition(notificationAssetId, accessPolicyId)).thenReturn(contractDefinitionId); edcNotificationContractService = new EdcNotificationContractService( - edcNotitifcationAssetService, edcPolicyDefinitionService, edcContractDefinitionService + edcNotitifcationAssetService, edcPolicyDefinitionService, edcContractDefinitionService ); } @Test void testHandle() { CreateNotificationContractResponse response = edcNotificationContractService.handle(request); - assertEquals(notificationAssetId, response.notificationAssetId()); - assertEquals(accessPolicyId, response.accessPolicyId()); - assertEquals(contractDefinitionId, response.contractDefinitionId()); + assertThat(notificationAssetId).isEqualTo(response.notificationAssetId()); + assertThat(accessPolicyId).isEqualTo(response.accessPolicyId()); + assertThat(contractDefinitionId).isEqualTo(response.contractDefinitionId()); } } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcContractDefinitionCriteriaTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcContractDefinitionCriteriaTest.java index 2047df9d32..20266e7662 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcContractDefinitionCriteriaTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/contract/model/EdcContractDefinitionCriteriaTest.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; @ExtendWith(MockitoExtension.class) class EdcContractDefinitionCriteriaTest { @@ -39,11 +39,12 @@ class EdcContractDefinitionCriteriaTest { @BeforeEach void setUp() { - edcContractDefinitionCriteria = new EdcContractDefinitionCriteria( - EdcContractDefinitionCriteriaTest.LEFT, - EdcContractDefinitionCriteriaTest.OP_EQUALS, - EdcContractDefinitionCriteriaTest.RIGHT - ); + edcContractDefinitionCriteria = EdcContractDefinitionCriteria.builder() + .type("CriterionDto") + .operandLeft(EdcContractDefinitionCriteriaTest.LEFT) + .operandRight(EdcContractDefinitionCriteriaTest.RIGHT) + .operator(EdcContractDefinitionCriteriaTest.OP_EQUALS) + .build(); } @Test diff --git a/tx-backend/testdata/CX_Testdata_MessagingTest_v0.0.3.json b/tx-backend/testdata/CX_Testdata_MessagingTest_v0.0.3.json index 4f0fc6bd3a..118c45fe55 100644 --- a/tx-backend/testdata/CX_Testdata_MessagingTest_v0.0.3.json +++ b/tx-backend/testdata/CX_Testdata_MessagingTest_v0.0.3.json @@ -1,30 +1,27 @@ { "policies": { "ID 3.0 Trace": { - "id": "id-3.0-trace", + "@context": { + "odrl": "http://www.w3.org/ns/odrl/2/" + }, + "@type": "PolicyDefinitionRequestDto", + "@id": "id-3.0-trace", "policy": { - "prohibitions": [], - "obligations": [], - "permissions": [ + "@type": "Policy", + "odrl:permission": [ { - "edctype": "dataspaceconnector:permission", - "action": { - "type": "USE" - }, - "constraints": [ - { - "edctype": "AtomicConstraint", - "leftExpression": { - "edctype": "dataspaceconnector:literalexpression", - "value": "idsc:PURPOSE" - }, - "rightExpression": { - "edctype": "dataspaceconnector:literalexpression", - "value": "ID 3.0 Trace" - }, - "operator": "EQ" - } - ] + "odrl:action": "USE", + "odrl:constraint": { + "@type": "AtomicConstraint", + "odrl:or": [ + { + "@type": "Constraint", + "odrl:leftOperand": "idsc:PURPOSE", + "odrl:operator": "EQ", + "odrl:rightOperand": "ID 3.0 Trace" + } + ] + } } ] } diff --git a/tx-coverage/pom.xml b/tx-coverage/pom.xml index 9975227507..f8582ea20f 100644 --- a/tx-coverage/pom.xml +++ b/tx-coverage/pom.xml @@ -33,6 +33,22 @@ org.jacoco jacoco-maven-plugin + + + + tx-backend/src/main/java/org/eclipse/tractusx/traceability/TraceabilityApplication.java + + + tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/HttpCallService.java + + + tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/InvestigationsEDCFacade.java + + + tx-backend/src/main/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/EdcService.java + + + report-aggregate diff --git a/tx-cucumber-tests/report.json b/tx-cucumber-tests/report.json index b162f8dbcc..b8f6d0d2e5 100644 --- a/tx-cucumber-tests/report.json +++ b/tx-cucumber-tests/report.json @@ -3,11 +3,11 @@ "line": 2, "elements": [ { - "start_timestamp": "2023-06-28T07:33:39.865Z", + "start_timestamp": "2023-07-03T15:06:54.531Z", "before": [ { "result": { - "duration": 755347900, + "duration": 862982800, "status": "passed" }, "match": { @@ -24,7 +24,7 @@ "steps": [ { "result": { - "duration": 2001900, + "duration": 1000100, "status": "passed" }, "line": 38, @@ -42,8 +42,8 @@ }, { "result": { - "error_message": "java.lang.IllegalArgumentException: path cannot be null\r\n\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)\r\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)\r\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:60)\r\n\tat org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:86)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)\r\n\tat io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:26)\r\n\tat io.restassured.internal.common.assertion.AssertParameter$notNull.callStatic(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:53)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:217)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:240)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1643)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:578)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1710)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:578)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:176)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.Authentication.obtainAccessToken(Authentication.java:58)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.getRequestSpecification(RestProvider.java:180)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.createInvestigation(RestProvider.java:107)\r\n\tat org.eclipse.tractusx.traceability.test.TraceabilityTestStepDefinition.iCreateQualityInvestigation(TraceabilityTestStepDefinition.java:81)\r\n\tat ✽.I create quality investigation(classpath:features/1_TRACEFOSS-1125.feature:39)\r\n", - "duration": 556975400, + "error_message": "java.lang.IllegalArgumentException: path cannot be null\r\n\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)\r\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)\r\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:60)\r\n\tat org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:86)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)\r\n\tat io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:26)\r\n\tat io.restassured.internal.common.assertion.AssertParameter$notNull.callStatic(Unknown Source)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:53)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:217)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:240)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1643)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:577)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1710)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:577)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:176)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.Authentication.obtainAccessToken(Authentication.java:58)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.getRequestSpecification(RestProvider.java:180)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.createInvestigation(RestProvider.java:107)\r\n\tat org.eclipse.tractusx.traceability.test.TraceabilityTestStepDefinition.iCreateQualityInvestigation(TraceabilityTestStepDefinition.java:81)\r\n\tat ✽.I create quality investigation(classpath:features/1_TRACEFOSS-1125.feature:39)\r\n", + "duration": 541877000, "status": "failed" }, "line": 39, @@ -279,11 +279,11 @@ ] }, { - "start_timestamp": "2023-06-28T07:33:41.250Z", + "start_timestamp": "2023-07-03T15:06:55.988Z", "before": [ { "result": { - "duration": 1105400, + "duration": 989100, "status": "passed" }, "match": { @@ -300,7 +300,6 @@ "steps": [ { "result": { - "duration": 550400, "status": "passed" }, "line": 38, @@ -318,8 +317,8 @@ }, { "result": { - "error_message": "java.lang.IllegalArgumentException: path cannot be null\r\n\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)\r\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)\r\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:60)\r\n\tat org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:86)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)\r\n\tat io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:26)\r\n\tat io.restassured.internal.common.assertion.AssertParameter$notNull.callStatic(Unknown Source)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1643)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:578)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1710)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:578)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:176)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.Authentication.obtainAccessToken(Authentication.java:58)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.getRequestSpecification(RestProvider.java:180)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.createInvestigation(RestProvider.java:107)\r\n\tat org.eclipse.tractusx.traceability.test.TraceabilityTestStepDefinition.iCreateQualityInvestigation(TraceabilityTestStepDefinition.java:81)\r\n\tat ✽.I create quality investigation(classpath:features/1_TRACEFOSS-1125.feature:39)\r\n", - "duration": 4993000, + "error_message": "java.lang.IllegalArgumentException: path cannot be null\r\n\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)\r\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)\r\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:60)\r\n\tat org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:86)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)\r\n\tat io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:26)\r\n\tat io.restassured.internal.common.assertion.AssertParameter$notNull.callStatic(Unknown Source)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1643)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:577)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1710)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:577)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:176)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.Authentication.obtainAccessToken(Authentication.java:58)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.getRequestSpecification(RestProvider.java:180)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.createInvestigation(RestProvider.java:107)\r\n\tat org.eclipse.tractusx.traceability.test.TraceabilityTestStepDefinition.iCreateQualityInvestigation(TraceabilityTestStepDefinition.java:81)\r\n\tat ✽.I create quality investigation(classpath:features/1_TRACEFOSS-1125.feature:39)\r\n", + "duration": 5000200, "status": "failed" }, "line": 39, @@ -345,7 +344,6 @@ }, { "result": { - "duration": 1000500, "status": "skipped" }, "line": 42, @@ -556,7 +554,7 @@ ] }, { - "start_timestamp": "2023-06-28T07:33:41.266Z", + "start_timestamp": "2023-07-03T15:06:56.001Z", "before": [ { "result": { @@ -576,7 +574,7 @@ "steps": [ { "result": { - "duration": 999100, + "duration": 998000, "status": "passed" }, "line": 38, @@ -594,8 +592,8 @@ }, { "result": { - "error_message": "java.lang.IllegalArgumentException: path cannot be null\r\n\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)\r\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)\r\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:60)\r\n\tat org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:86)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)\r\n\tat io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:26)\r\n\tat io.restassured.internal.common.assertion.AssertParameter$notNull.callStatic(Unknown Source)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1643)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:578)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1710)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:578)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:176)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.Authentication.obtainAccessToken(Authentication.java:58)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.getRequestSpecification(RestProvider.java:180)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.createInvestigation(RestProvider.java:107)\r\n\tat org.eclipse.tractusx.traceability.test.TraceabilityTestStepDefinition.iCreateQualityInvestigation(TraceabilityTestStepDefinition.java:81)\r\n\tat ✽.I create quality investigation(classpath:features/1_TRACEFOSS-1125.feature:39)\r\n", - "duration": 5005900, + "error_message": "java.lang.IllegalArgumentException: path cannot be null\r\n\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)\r\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)\r\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:60)\r\n\tat org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:86)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)\r\n\tat io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:26)\r\n\tat io.restassured.internal.common.assertion.AssertParameter$notNull.callStatic(Unknown Source)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1643)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:577)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1710)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:577)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:176)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.Authentication.obtainAccessToken(Authentication.java:58)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.getRequestSpecification(RestProvider.java:180)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.createInvestigation(RestProvider.java:107)\r\n\tat org.eclipse.tractusx.traceability.test.TraceabilityTestStepDefinition.iCreateQualityInvestigation(TraceabilityTestStepDefinition.java:81)\r\n\tat ✽.I create quality investigation(classpath:features/1_TRACEFOSS-1125.feature:39)\r\n", + "duration": 3000700, "status": "failed" }, "line": 39, @@ -831,10 +829,11 @@ ] }, { - "start_timestamp": "2023-06-28T07:33:41.281Z", + "start_timestamp": "2023-07-03T15:06:56.013Z", "before": [ { "result": { + "duration": 1001700, "status": "passed" }, "match": { @@ -868,8 +867,8 @@ }, { "result": { - "error_message": "java.lang.IllegalArgumentException: path cannot be null\r\n\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)\r\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)\r\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:60)\r\n\tat org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:86)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)\r\n\tat io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:26)\r\n\tat io.restassured.internal.common.assertion.AssertParameter$notNull.callStatic(Unknown Source)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1643)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:578)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1710)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:578)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:176)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.Authentication.obtainAccessToken(Authentication.java:58)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.getRequestSpecification(RestProvider.java:180)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.createInvestigation(RestProvider.java:107)\r\n\tat org.eclipse.tractusx.traceability.test.TraceabilityTestStepDefinition.iCreateQualityInvestigation(TraceabilityTestStepDefinition.java:81)\r\n\tat ✽.I create quality investigation(classpath:features/1_TRACEFOSS-1125.feature:39)\r\n", - "duration": 4998900, + "error_message": "java.lang.IllegalArgumentException: path cannot be null\r\n\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)\r\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)\r\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:60)\r\n\tat org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:86)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)\r\n\tat io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:26)\r\n\tat io.restassured.internal.common.assertion.AssertParameter$notNull.callStatic(Unknown Source)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1643)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:577)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1710)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:577)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:176)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.Authentication.obtainAccessToken(Authentication.java:58)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.getRequestSpecification(RestProvider.java:180)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.createInvestigation(RestProvider.java:107)\r\n\tat org.eclipse.tractusx.traceability.test.TraceabilityTestStepDefinition.iCreateQualityInvestigation(TraceabilityTestStepDefinition.java:81)\r\n\tat ✽.I create quality investigation(classpath:features/1_TRACEFOSS-1125.feature:39)\r\n", + "duration": 2999700, "status": "failed" }, "line": 39, @@ -895,7 +894,6 @@ }, { "result": { - "duration": 997200, "status": "skipped" }, "line": 42, @@ -1126,11 +1124,10 @@ "line": 2, "elements": [ { - "start_timestamp": "2023-06-28T07:33:41.297Z", + "start_timestamp": "2023-07-03T15:06:56.023Z", "before": [ { "result": { - "duration": 557400, "status": "passed" }, "match": { @@ -1147,7 +1144,7 @@ "steps": [ { "result": { - "duration": 35700, + "duration": 1002000, "status": "passed" }, "line": 15, @@ -1165,8 +1162,8 @@ }, { "result": { - "error_message": "java.lang.IllegalArgumentException: path cannot be null\r\n\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)\r\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)\r\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:60)\r\n\tat org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:86)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)\r\n\tat io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:26)\r\n\tat io.restassured.internal.common.assertion.AssertParameter$notNull.callStatic(Unknown Source)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1643)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:578)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1710)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:578)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:176)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.Authentication.obtainAccessToken(Authentication.java:58)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.getRequestSpecification(RestProvider.java:180)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.createInvestigation(RestProvider.java:107)\r\n\tat org.eclipse.tractusx.traceability.test.TraceabilityTestStepDefinition.iCreateQualityInvestigation(TraceabilityTestStepDefinition.java:81)\r\n\tat ✽.I create quality investigation(classpath:features/2_TRACEFOSS-608.feature:16)\r\n", - "duration": 8874400, + "error_message": "java.lang.IllegalArgumentException: path cannot be null\r\n\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)\r\n\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)\r\n\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)\r\n\tat org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:60)\r\n\tat org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:86)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)\r\n\tat io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:26)\r\n\tat io.restassured.internal.common.assertion.AssertParameter$notNull.callStatic(Unknown Source)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1643)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:577)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1710)\r\n\tat io.restassured.internal.RequestSpecificationImpl.this$2$applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy)\r\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:577)\r\n\tat org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)\r\n\tat groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)\r\n\tat groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1331)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006)\r\n\tat groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:789)\r\n\tat io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:46)\r\n\tat org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:57)\r\n\tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:176)\r\n\tat io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.Authentication.obtainAccessToken(Authentication.java:58)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.getRequestSpecification(RestProvider.java:180)\r\n\tat org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider.createInvestigation(RestProvider.java:107)\r\n\tat org.eclipse.tractusx.traceability.test.TraceabilityTestStepDefinition.iCreateQualityInvestigation(TraceabilityTestStepDefinition.java:81)\r\n\tat ✽.I create quality investigation(classpath:features/2_TRACEFOSS-608.feature:16)\r\n", + "duration": 6006400, "status": "failed" }, "line": 16, @@ -1198,7 +1195,6 @@ }, { "result": { - "duration": 540000, "status": "skipped" }, "line": 20,