diff --git a/CHANGELOG.md b/CHANGELOG.md index cbf686da6e..a29f09c72d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ _**For better traceability add the corresponding GitHub issue number in each cha ## [Unreleased] +### Fixed + +- IRS now searches for Digital Twin Registry contract offers by + type `dct:type`: `https://w3id.org/catenax/taxonomy#DigitalTwinRegistry` + or `edc:type`: `data.core.digitalTwinRegistry`. #616 +- Fix missing and malformed properties for EDC policy transformation. #648 + + ## [5.1.2] - 2024-05-13 ### Fixed diff --git a/docs/src/api/irs-api.yaml b/docs/src/api/irs-api.yaml index 2f48b91208..1d7d2189d4 100644 --- a/docs/src/api/irs-api.yaml +++ b/docs/src/api/irs-api.yaml @@ -821,7 +821,7 @@ paths: createdOn: 2024-03-28T03:34:42.9454448Z validUntil: 2025-12-12T23:59:59.999Z permissions: - - action: USE + - action: use constraint: and: - leftOperand: Membership @@ -1807,7 +1807,7 @@ components: policy: '@type': Policy odrl:permission: - - odrl:action: USE + - odrl:action: use odrl:constraint: odrl:and: - odrl:leftOperand: Membership @@ -2200,7 +2200,7 @@ components: policy: '@type': Policy odrl:permission: - - odrl:action: USE + - odrl:action: use odrl:constraint: odrl:and: - odrl:leftOperand: Membership diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/RegistryConfiguration.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/RegistryConfiguration.java index 936aa6ebbc..032758c0ab 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/RegistryConfiguration.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/RegistryConfiguration.java @@ -76,9 +76,9 @@ public DecentralDigitalTwinRegistryService decentralDigitalTwinRegistryService( @Value("${digitalTwinRegistry.lookupShellsTemplate:}") final String lookupShellsTemplate, final EdcConfiguration edcConfiguration) { - final EdcEndpointReferenceRetriever endpointReferenceRetriever = (edcConnectorEndpoint, assetType, assetValue, bpn) -> { + final EdcEndpointReferenceRetriever endpointReferenceRetriever = (edcConnectorEndpoint, bpn) -> { try { - return facade.getEndpointReferencesForAsset(edcConnectorEndpoint, assetType, assetValue, bpn); + return facade.getEndpointReferencesForRegistryAsset(edcConnectorEndpoint, bpn); } catch (EdcClientException e) { throw new EdcRetrieverException(e); } diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcRegistration.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcRegistration.java index 9af1ac74dc..bc2f3a1d8c 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcRegistration.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/ess/service/EdcRegistration.java @@ -150,7 +150,7 @@ private void registerPolicy(final String policyId) { "policy": { "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "@type": "AtomicConstraint", "odrl:or": [ diff --git a/irs-cucumber-tests/src/test/resources/templates/policy-for-e2e-tests.json b/irs-cucumber-tests/src/test/resources/templates/policy-for-e2e-tests.json index bcfccffc15..854ad8f673 100644 --- a/irs-cucumber-tests/src/test/resources/templates/policy-for-e2e-tests.json +++ b/irs-cucumber-tests/src/test/resources/templates/policy-for-e2e-tests.json @@ -6,7 +6,7 @@ "policy": { "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "odrl:and": [ { diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClient.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClient.java index b1222f6f43..357492ade0 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClient.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClient.java @@ -37,7 +37,9 @@ /** * Public API facade for EDC domain */ -@SuppressWarnings({"PMD.ExcessiveImports", "PMD.UseObjectForClearerAPI"}) +@SuppressWarnings({ "PMD.ExcessiveImports", + "PMD.UseObjectForClearerAPI" +}) public interface EdcSubmodelClient { CompletableFuture getSubmodelPayload(String connectorEndpoint, String submodelDataplaneUrl, @@ -52,5 +54,8 @@ List> getEndpointReferencesForAsset(Str List> getEndpointReferencesForAsset(String endpointAddress, String filterKey, String filterValue, EndpointDataReferenceStatus cachedEndpointDataReference, String bpn) throws EdcClientException; + + List> getEndpointReferencesForRegistryAsset(String endpointAddress, + String bpn) throws EdcClientException; } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java index 0abebaabdd..86844d3646 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java @@ -27,6 +27,7 @@ import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_EDC_ID; import java.net.URI; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -52,6 +53,7 @@ import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotificationResponse; import org.eclipse.tractusx.irs.edc.client.model.notification.NotificationContent; import org.eclipse.tractusx.irs.edc.client.util.Masker; +import org.jetbrains.annotations.NotNull; import org.springframework.util.StopWatch; /** @@ -65,6 +67,11 @@ }) public class EdcSubmodelClientImpl implements EdcSubmodelClient { + private static final String DT_DCAT_TYPE_ID = "'http://purl.org/dc/terms/type'.'@id'"; + private static final String DT_TAXONOMY_REGISTRY = "https://w3id.org/catenax/taxonomy#DigitalTwinRegistry"; + private static final String DT_EDC_TYPE = "https://w3id.org/edc/v0.0.1/ns/type"; + private static final String DT_DATA_CORE_REGISTRY = "data.core.digitalTwinRegistry"; + private final EdcConfiguration config; private final ContractNegotiationService contractNegotiationService; private final EdcDataPlaneClient edcDataPlaneClient; @@ -99,8 +106,7 @@ private Optional retrieveSubmodelData(final String submodelD final String payload = edcDataPlaneClient.getData(endpointDataReference, submodelDataplaneUrl); stopWatchOnEdcTask(stopWatch); - return Optional.of( - new SubmodelDescriptor(endpointDataReference.getContractId(), payload)); + return Optional.of(new SubmodelDescriptor(endpointDataReference.getContractId(), payload)); } return Optional.empty(); @@ -234,11 +240,17 @@ public List> getEndpointReferencesForAs endpointAddress, filterKey, filterValue)); } - // We need to process each contract offer in parallel - // (see src/docs/arc42/cross-cutting/discovery-DTR--multiple-EDCs-with-multiple-DTRs.puml - // and src/docs/arc42/cross-cutting/discovery-DTR--multiple-EDCs-with-multiple-DTRs--detailed.puml) - return contractOffers.stream().map(contractOffer -> { + return createCompletableFuturesForContractOffers(endpointDataReferenceStatus, bpn, contractOffers, + providerWithSuffix, stopWatch); + } + // We need to process each contract offer in parallel + // (see src/docs/arc42/cross-cutting/discovery-DTR--multiple-EDCs-with-multiple-DTRs.puml + // and src/docs/arc42/cross-cutting/discovery-DTR--multiple-EDCs-with-multiple-DTRs--detailed.puml) + private @NotNull List> createCompletableFuturesForContractOffers( + final EndpointDataReferenceStatus endpointDataReferenceStatus, final String bpn, + final List contractOffers, final String providerWithSuffix, final StopWatch stopWatch) { + return contractOffers.stream().map(contractOffer -> { final NegotiationResponse negotiationResponse; try { negotiationResponse = negotiateContract(endpointDataReferenceStatus, contractOffer, providerWithSuffix, @@ -262,6 +274,41 @@ public List> getEndpointReferencesForAs }).toList(); } + @Override + public List> getEndpointReferencesForRegistryAsset( + final String endpointAddress, final String bpn) throws EdcClientException { + return execute(endpointAddress, () -> getEndpointReferencesForRegistryAsset(endpointAddress, + new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW), bpn)); + } + + public List> getEndpointReferencesForRegistryAsset( + final String endpointAddress, final EndpointDataReferenceStatus endpointDataReferenceStatus, + final String bpn) throws EdcClientException { + final StopWatch stopWatch = new StopWatch(); + stopWatch.start("Get EndpointDataReference task for shell descriptor, endpoint " + endpointAddress); + final String providerWithSuffix = appendSuffix(endpointAddress, config.getControlplane().getProviderSuffix()); + + // CatalogItem = contract offer + final List contractOffers = new ArrayList<>( + catalogFacade.fetchCatalogByFilter(providerWithSuffix, DT_DCAT_TYPE_ID, DT_TAXONOMY_REGISTRY, bpn)); + + if (contractOffers.isEmpty()) { + final List contractOffersDataCore = catalogFacade.fetchCatalogByFilter(providerWithSuffix, + DT_EDC_TYPE, DT_DATA_CORE_REGISTRY, bpn); + contractOffers.addAll(contractOffersDataCore); + } + + if (contractOffers.isEmpty()) { + throw new EdcClientException( + "No DigitalTwinRegistry contract offers found for endpointAddress '%s' filterKey '%s', filterValue '%s' or filterKey '%s', filterValue '%s'".formatted( + endpointAddress, DT_DCAT_TYPE_ID, DT_TAXONOMY_REGISTRY, DT_EDC_TYPE, + DT_DATA_CORE_REGISTRY)); + } + + return createCompletableFuturesForContractOffers(endpointDataReferenceStatus, bpn, contractOffers, + providerWithSuffix, stopWatch); + } + private NegotiationResponse negotiateContract(final EndpointDataReferenceStatus endpointDataReferenceStatus, final CatalogItem catalogItem, final String providerWithSuffix, final String bpn) throws EdcClientException { diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientLocalStub.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientLocalStub.java index 9ac58b2bd1..9df5ed79fd 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientLocalStub.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientLocalStub.java @@ -44,6 +44,7 @@ @SuppressWarnings("PMD.UseObjectForClearerAPI") public class EdcSubmodelClientLocalStub implements EdcSubmodelClient { + public static final String NOT_IMPLEMENTED = "Not implemented"; private final SubmodelTestdataCreator testdataCreator; /* package */ @@ -73,12 +74,18 @@ public CompletableFuture sendNotification(final String public List> getEndpointReferencesForAsset(final String endpointAddress, final String filterKey, final String filterValue, final EndpointDataReferenceStatus cachedEndpointDataReference, final String bpn) throws EdcClientException { - throw new EdcClientException("Not implemented"); + throw new EdcClientException(NOT_IMPLEMENTED); } @Override public List> getEndpointReferencesForAsset(final String endpointAddress, final String filterKey, final String filterValue, final String bpn) throws EdcClientException { - throw new EdcClientException("Not implemented"); + throw new EdcClientException(NOT_IMPLEMENTED); + } + + @Override + public List> getEndpointReferencesForRegistryAsset( + final String endpointAddress, final String bpn) throws EdcClientException { + throw new EdcClientException(NOT_IMPLEMENTED); } } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelFacade.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelFacade.java index e99107d1de..8913c52127 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelFacade.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelFacade.java @@ -43,7 +43,9 @@ */ @Slf4j @RequiredArgsConstructor -@SuppressWarnings({"PMD.AvoidDuplicateLiterals", "PMD.UseObjectForClearerAPI"}) +@SuppressWarnings({ "PMD.AvoidDuplicateLiterals", + "PMD.UseObjectForClearerAPI" +}) public class EdcSubmodelFacade { private final EdcSubmodelClient client; @@ -93,9 +95,9 @@ public EdcNotificationResponse sendNotification(final String submodelEndpointAdd } } - public List> getEndpointReferencesForAsset(final String endpointAddress, - final String filterKey, final String filterValue, final String bpn) throws EdcClientException { - return client.getEndpointReferencesForAsset(endpointAddress, filterKey, filterValue, bpn); + public List> getEndpointReferencesForRegistryAsset( + final String endpointAddress, final String bpn) throws EdcClientException { + return client.getEndpointReferencesForRegistryAsset(endpointAddress, bpn); } } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetService.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetService.java index 4691f5226b..06722a85df 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetService.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetService.java @@ -63,9 +63,15 @@ public class EdcAssetService { private static final String ASSET_CREATION_PROPERTY_DESCRIPTION = "https://w3id.org/edc/v0.0.1/ns/description"; private static final String ASSET_CREATION_PROPERTY_CONTENT_TYPE = "https://w3id.org/edc/v0.0.1/ns/contenttype"; private static final String ASSET_CREATION_PROPERTY_POLICY_ID = "https://w3id.org/edc/v0.0.1/ns/policy-id"; - private static final String ASSET_CREATION_PROPERTY_TYPE = "https://w3id.org/edc/v0.0.1/ns/type"; + private static final String ASSET_CREATION_PROPERTY_EDC_TYPE = "https://w3id.org/edc/v0.0.1/ns/type"; + private static final String ASSET_CREATION_PROPERTY_DATA_CORE_REGISTRY = "data.core.digitalTwinRegistry"; + private static final String ASSET_CREATION_PROPERTY_DCAT_TYPE = "http://purl.org/dc/terms/type"; + private static final String ASSET_CREATION_PROPERTY_DCAT_REGISTRY = "https://w3id.org/catenax/taxonomy#DigitalTwinRegistry"; + private static final String ASSET_CREATION_PROPERTY_COMMON_VERSION_KEY = "https://w3id.org/catenax/ontology/common#version"; + private static final String ASSET_CREATION_PROPERTY_COMMON_VERSION_VALUE = "3.0"; private static final String ASSET_CREATION_PROPERTY_NOTIFICATION_TYPE = "https://w3id.org/edc/v0.0.1/ns/notificationtype"; private static final String ASSET_CREATION_PROPERTY_NOTIFICATION_METHOD = "https://w3id.org/edc/v0.0.1/ns/notificationmethod"; + public static final String DATA_ADDRESS_TYPE_HTTP_DATA = "HttpData"; private final EdcTransformer edcTransformer; @@ -128,7 +134,7 @@ private Asset createNotificationAssetRequest(final String assetName, final Strin final String assetId = UUID.randomUUID().toString(); final Map properties = Map.of(ASSET_CREATION_PROPERTY_DESCRIPTION, assetName, ASSET_CREATION_PROPERTY_CONTENT_TYPE, DEFAULT_CONTENT_TYPE, ASSET_CREATION_PROPERTY_POLICY_ID, - DEFAULT_POLICY_ID, ASSET_CREATION_PROPERTY_TYPE, notificationType.getValue(), + DEFAULT_POLICY_ID, ASSET_CREATION_PROPERTY_EDC_TYPE, notificationType.getValue(), ASSET_CREATION_PROPERTY_NOTIFICATION_TYPE, notificationType.getValue(), ASSET_CREATION_PROPERTY_NOTIFICATION_METHOD, notificationMethod.getValue()); @@ -153,7 +159,10 @@ private Asset createNotificationAssetRequest(final String assetName, final Strin private Asset createDtrAssetRequest(final String assetId, final String baseUrl) { final Map properties = Map.of(ASSET_CREATION_PROPERTY_DESCRIPTION, - "Digital Twin Registry Asset", ASSET_CREATION_PROPERTY_TYPE, "data.core.digitalTwinRegistry"); + "Digital Twin Registry Asset", ASSET_CREATION_PROPERTY_EDC_TYPE, + ASSET_CREATION_PROPERTY_DATA_CORE_REGISTRY, ASSET_CREATION_PROPERTY_COMMON_VERSION_KEY, + ASSET_CREATION_PROPERTY_COMMON_VERSION_VALUE, ASSET_CREATION_PROPERTY_DCAT_TYPE, + Map.of("@id", ASSET_CREATION_PROPERTY_DCAT_REGISTRY)); final DataAddress dataAddress = DataAddress.Builder.newInstance() .type("DataAddress") diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/configuration/JsonLdConfiguration.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/configuration/JsonLdConfiguration.java index f4684299eb..71f49e3aa0 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/configuration/JsonLdConfiguration.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/configuration/JsonLdConfiguration.java @@ -51,8 +51,9 @@ public class JsonLdConfiguration { 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/"; + public static final String NAMESPACE_DCT = "http://purl.org/dc/terms/"; public static final String JSON_LD_OBJECT_MAPPER = "jsonLdObjectMapper"; + public static final String NAMESPACE_CATENAX_POLICY = "https://w3id.org/catenax/policy/"; @Bean /* package */ TitaniumJsonLd titaniumJsonLd(final Monitor monitor) { final TitaniumJsonLd titaniumJsonLd = new TitaniumJsonLd(monitor); @@ -62,6 +63,7 @@ public class JsonLdConfiguration { titaniumJsonLd.registerNamespace("edc", NAMESPACE_EDC); titaniumJsonLd.registerNamespace("dcat", JsonLdConfiguration.NAMESPACE_DCAT); titaniumJsonLd.registerNamespace("dspace", NAMESPACE_DSPACE); + titaniumJsonLd.registerNamespace("cx-policy", NAMESPACE_CATENAX_POLICY); return titaniumJsonLd; } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/Permission.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/Permission.java index a447e02388..639a6551df 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/Permission.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/Permission.java @@ -41,7 +41,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class Permission { - @Schema(implementation = PolicyType.class, example = "USE") + @Schema(implementation = PolicyType.class, example = "use") @JsonAlias({"odrl:action"}) private PolicyType action; @Schema diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyType.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyType.java index 481f15c642..c5ed0ac4ee 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyType.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyType.java @@ -23,11 +23,19 @@ ********************************************************************************/ package org.eclipse.tractusx.irs.edc.client.policy; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import com.fasterxml.jackson.annotation.JsonValue; + /** * A PolicyType object use in Permission */ +@Getter +@RequiredArgsConstructor public enum PolicyType { + ACCESS("access"), + USE("use"); - ACCESS, USE - + @JsonValue + private final String value; } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionService.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionService.java index 80f88f547f..db404d211d 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionService.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionService.java @@ -29,6 +29,7 @@ import org.eclipse.tractusx.irs.edc.client.EdcConfiguration; import org.eclipse.tractusx.irs.edc.client.asset.model.OdrlContext; import org.eclipse.tractusx.irs.edc.client.contract.model.EdcOperator; +import org.eclipse.tractusx.irs.edc.client.policy.PolicyType; import org.eclipse.tractusx.irs.edc.client.policy.model.EdcCreatePolicyDefinitionRequest; import org.eclipse.tractusx.irs.edc.client.policy.model.EdcPolicy; import org.eclipse.tractusx.irs.edc.client.policy.model.EdcPolicyPermission; @@ -54,12 +55,12 @@ @RequiredArgsConstructor public class EdcPolicyDefinitionService { - private static final String USE_ACTION = "USE"; 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 CONSTRAINT = "Constraint"; private static final String OPERATOR_PREFIX = "odrl:"; + private static final String USE_ACTION = PolicyType.USE.getValue(); private final EdcConfiguration config; private final RestTemplate restTemplate; diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientLocalStubTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientLocalStubTest.java index f979c91a8e..6db9e48d66 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientLocalStubTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientLocalStubTest.java @@ -23,21 +23,20 @@ ********************************************************************************/ package org.eclipse.tractusx.irs.edc.client; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import org.eclipse.tractusx.irs.edc.client.exceptions.EdcClientException; +import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification; +import org.eclipse.tractusx.irs.edc.client.model.notification.NotificationContent; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; -import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) class EdcSubmodelClientLocalStubTest { - @Mock - private SubmodelTestdataCreator testdataCreator; - @InjectMocks private EdcSubmodelClientLocalStub edcSubmodelClientLocalStub; @@ -47,6 +46,32 @@ void shouldThrowExceptionFor() { String assetId = "urn:uuid:c35ee875-5443-4a2d-bc14-fdacd64b9446"; // when - assertThrows(EdcClientException.class, () -> edcSubmodelClientLocalStub.getSubmodelPayload("", "", assetId, "")); + assertThrows(EdcClientException.class, + () -> edcSubmodelClientLocalStub.getSubmodelPayload("", "", assetId, "")); + } + + @Test + void sendNotification() { + final EdcNotification notification = EdcNotification.builder().build(); + final var actual = edcSubmodelClientLocalStub.sendNotification("", "", notification, ""); + assertThat(actual).isCompleted(); + } + + @Test + void getEndpointReferencesForAsset() { + assertThrows(EdcClientException.class, + () -> edcSubmodelClientLocalStub.getEndpointReferencesForAsset("", "", "", "")); + } + + @Test + void testGetEndpointReferencesForAsset() { + assertThrows(EdcClientException.class, + () -> edcSubmodelClientLocalStub.getEndpointReferencesForAsset("", "", "", "")); + } + + @Test + void getEndpointReferencesForRegistryAsset() { + assertThrows(EdcClientException.class, + () -> edcSubmodelClientLocalStub.getEndpointReferencesForRegistryAsset("", "")); } } \ No newline at end of file diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientTest.java index 0171c77e91..f9625f6858 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientTest.java @@ -24,6 +24,7 @@ package org.eclipse.tractusx.irs.edc.client; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.fail; import static org.eclipse.tractusx.irs.edc.client.cache.endpointdatareference.EndpointDataReferenceStatus.TokenStatus; import static org.mockito.ArgumentMatchers.any; @@ -45,6 +46,7 @@ import java.time.Duration; import java.time.Instant; import java.time.ZoneId; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -93,7 +95,11 @@ class EdcSubmodelClientTest extends LocalTestDataConfigurationAware { private static final String PROVIDER_SUFFIX = "/test"; private static final String CONNECTOR_ENDPOINT = "https://connector.endpoint.com"; private static final String existingCatenaXId = "urn:uuid:5e1908ed-e176-4f57-9616-1415097d0fdf"; - private static final String BPN = "BPNL00000003CRHK"; + private static final String BPN = "BPNL00000000TEST"; + public static final String TAXONOMY_DIGITAL_TWIN_REGISTRY = "https://w3id.org/catenax/taxonomy#DigitalTwinRegistry"; + public static final String DCT_TYPE_ID = "'http://purl.org/dc/terms/type'.'@id'"; + public static final String EDC_TYPE = "https://w3id.org/edc/v0.0.1/ns/type"; + public static final String DATA_CORE_DIGITAL_TWIN_REGISTRY = "data.core.digitalTwinRegistry"; private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); private final TimeMachine clock = new TimeMachine(); @@ -462,6 +468,79 @@ void shouldRetrieveEndpointReferenceForAsset2() throws Exception { assertThat(actual).isEqualTo(expected); } + @Test + void shouldRetrieveEndpointReferenceForRegistryAssetUsingFallbackOldIdentifier() throws Exception { + // arrange + // no catalog item for taxonomy#DigitalTwinRegistry is found, + // so the fallback data.core.digitalTwinRegistry is used + when(catalogFacade.fetchCatalogByFilter(any(), eq(DCT_TYPE_ID), eq(TAXONOMY_DIGITAL_TWIN_REGISTRY), + any())).thenReturn(Collections.emptyList()); + when(catalogFacade.fetchCatalogByFilter(any(), eq(EDC_TYPE), eq(DATA_CORE_DIGITAL_TWIN_REGISTRY), + any())).thenReturn(List.of(CatalogItem.builder().itemId("asset-id").build())); + + when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); + + final String agreementId = "agreementId"; + when(contractNegotiationService.negotiate(any(), any(), + eq(new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW)), any())).thenReturn( + NegotiationResponse.builder().contractAgreementId(agreementId).build()); + final EndpointDataReference expected = mock(EndpointDataReference.class); + when(endpointDataReferenceCacheService.getEndpointDataReferenceFromStorage(agreementId)).thenReturn( + Optional.ofNullable(expected)); + + // act + final var result = testee.getEndpointReferencesForRegistryAsset(ENDPOINT_ADDRESS, "bpn"); + + // assert + assertThat(result).hasSize(1); + final EndpointDataReference actual = result.get(0).get(5, TimeUnit.SECONDS); + assertThat(actual).isEqualTo(expected); + } + + @Test + void shouldRetrieveEndpointReferenceForRegistryAssetForNewIdentifier() throws Exception { + // arrange + // catalog item for taxonomy#DigitalTwinRegistry is found, so the fallback type is not used + when(catalogFacade.fetchCatalogByFilter(any(), eq(DCT_TYPE_ID), eq(TAXONOMY_DIGITAL_TWIN_REGISTRY), + any())).thenReturn(List.of(CatalogItem.builder().itemId("asset-id").build())); + + when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); + + final String agreementId = "agreementId"; + when(contractNegotiationService.negotiate(any(), any(), + eq(new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW)), any())).thenReturn( + NegotiationResponse.builder().contractAgreementId(agreementId).build()); + final EndpointDataReference expected = mock(EndpointDataReference.class); + when(endpointDataReferenceCacheService.getEndpointDataReferenceFromStorage(agreementId)).thenReturn( + Optional.ofNullable(expected)); + + // act + final var result = testee.getEndpointReferencesForRegistryAsset(ENDPOINT_ADDRESS, "bpn"); + + // assert + assertThat(result).hasSize(1); + final EndpointDataReference actual = result.get(0).get(5, TimeUnit.SECONDS); + assertThat(actual).isEqualTo(expected); + } + + @Test + void shouldFailEndpointReferenceRetrievalForNoRegistryAsset() { + // arrange + final String edcUrl = "https://edc.controlplane.org/public"; + when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); + + when(catalogFacade.fetchCatalogByFilter(any(), eq(DCT_TYPE_ID), eq(TAXONOMY_DIGITAL_TWIN_REGISTRY), + any())).thenReturn(Collections.emptyList()); + when(catalogFacade.fetchCatalogByFilter(any(), eq(EDC_TYPE), eq(DATA_CORE_DIGITAL_TWIN_REGISTRY), + any())).thenReturn(Collections.emptyList()); + + // act & assert + final String expectedErrorMessage = "No DigitalTwinRegistry contract offers found for endpointAddress '%s' filterKey '%s', filterValue '%s' or filterKey '%s', filterValue '%s'".formatted( + edcUrl, DCT_TYPE_ID, TAXONOMY_DIGITAL_TWIN_REGISTRY, EDC_TYPE, DATA_CORE_DIGITAL_TWIN_REGISTRY); + assertThatThrownBy(() -> testee.getEndpointReferencesForRegistryAsset(edcUrl, "bpn")).isInstanceOf( + EdcClientException.class).hasMessage(expectedErrorMessage); + } + @Test void shouldUseCachedEndpointReferenceValueWhenTokenIsValid() throws EdcClientException, ExecutionException, InterruptedException { diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelFacadeTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelFacadeTest.java index 95f81b1fc7..3f229e5fa1 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelFacadeTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelFacadeTest.java @@ -60,7 +60,7 @@ class EdcSubmodelFacadeTest { @Mock private EdcSubmodelClient client; - private EdcConfiguration config = new EdcConfiguration(); + private final EdcConfiguration config = new EdcConfiguration(); @BeforeEach public void beforeEach() { @@ -174,10 +174,10 @@ class GetEndpointReferencesForAssetTests { void shouldThrowEdcClientExceptionForEndpointReference() throws EdcClientException { // arrange final EdcClientException e = new EdcClientException("test"); - when(client.getEndpointReferencesForAsset(any(), any(), any(), any())).thenThrow(e); + when(client.getEndpointReferencesForRegistryAsset(any(), any())).thenThrow(e); // act - ThrowableAssert.ThrowingCallable action = () -> testee.getEndpointReferencesForAsset("", "", "", ""); + ThrowableAssert.ThrowingCallable action = () -> testee.getEndpointReferencesForRegistryAsset("", ""); // assert assertThatThrownBy(action).isInstanceOf(EdcClientException.class); @@ -187,12 +187,11 @@ void shouldThrowEdcClientExceptionForEndpointReference() throws EdcClientExcepti void shouldReturnFailedFuture() throws EdcClientException { // arrange - when(client.getEndpointReferencesForAsset(any(), any(), any(), any())).thenReturn( + when(client.getEndpointReferencesForRegistryAsset(any(), any())).thenReturn( List.of(CompletableFuture.failedFuture(new EdcClientException("test")))); // act - final List> results = testee.getEndpointReferencesForAsset("", "", - "", ""); + final List> results = testee.getEndpointReferencesForRegistryAsset("", ""); // assert assertThat(results).hasSize(1); diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetServiceTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetServiceTest.java index 48d0aec6e4..1653da5d41 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetServiceTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetServiceTest.java @@ -29,7 +29,6 @@ import java.util.Map; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -83,11 +82,12 @@ class EdcAssetServiceTest { void setUp() { TitaniumJsonLd jsonLd = new TitaniumJsonLd(new ConsoleMonitor()); jsonLd.registerNamespace("odrl", "http://www.w3.org/ns/odrl/2/"); - jsonLd.registerNamespace("dct", "https://purl.org/dc/terms/"); + jsonLd.registerNamespace("dct", "http://purl.org/dc/terms/"); jsonLd.registerNamespace("tx", "https://w3id.org/tractusx/v0.0.1/ns/"); jsonLd.registerNamespace("edc", "https://w3id.org/edc/v0.0.1/ns/"); jsonLd.registerNamespace("dcat", "https://www.w3.org/ns/dcat/"); jsonLd.registerNamespace("dspace", "https://w3id.org/dspace/v0.8/"); + jsonLd.registerNamespace("cx-policy", "https://w3id.org/catenax/policy/"); this.edcTransformer = new EdcTransformer(objectMapper(), jsonLd, new TypeTransformerRegistryImpl()); this.service = new EdcAssetService(edcTransformer, edcConfiguration, restTemplate); @@ -142,7 +142,66 @@ void testAssetCreateRequestStructure() throws JSONException { "edc:baseUrl": "https://traceability.dev.demo.catena-x.net/api/qualitynotifications/receive" }, "@context": { - "dct": "https://purl.org/dc/terms/", + "dct": "http://purl.org/dc/terms/", + "tx": "https://w3id.org/tractusx/v0.0.1/ns/", + "edc": "https://w3id.org/edc/v0.0.1/ns/", + "odrl": "http://www.w3.org/ns/odrl/2/", + "dcat": "https://www.w3.org/ns/dcat/", + "dspace": "https://w3id.org/dspace/v0.8/" + } + } + """, jsonObject.toString(), false); + } + + @Test + void testRegistryAssetCreateRequestStructure() throws JSONException { + + Map properties = Map.of("http://purl.org/dc/terms/type", + Map.of("@id", "https://w3id.org/catenax/taxonomy#DigitalTwinRegistry"), + "https://w3id.org/catenax/ontology/common#version", "3.0", "https://w3id.org/edc/v0.0.1/ns/type", + "data.core.digitalTwinRegistry"); + + DataAddress dataAddress = DataAddress.Builder.newInstance() + .type(DATA_ADDRESS_TYPE_HTTP_DATA) + .property("https://w3id.org/edc/v0.0.1/ns/type", "HttpData") + .property("https://w3id.org/edc/v0.0.1/ns/baseUrl", + "https://test.dtr/registry") + .property("https://w3id.org/edc/v0.0.1/ns/proxyMethod", "true") + .property("https://w3id.org/edc/v0.0.1/ns/proxyBody", "true") + .property("https://w3id.org/edc/v0.0.1/ns/method", "POST") + .build(); + + Asset asset = Asset.Builder.newInstance() + .id("Asset1") + .contentType("Asset") + .properties(properties) + .dataAddress(dataAddress) + .build(); + JsonObject jsonObject = edcTransformer.transformAssetToJson(asset); + + JSONAssert.assertEquals(""" + { + "@id": "Asset1", + "@type": "edc:Asset", + "edc:properties": { + "dct:type": { + "@id": "https://w3id.org/catenax/taxonomy#DigitalTwinRegistry" + }, + "https://w3id.org/catenax/ontology/common#version": "3.0", + "edc:type": "data.core.digitalTwinRegistry", + "edc:id": "Asset1", + "edc:contenttype": "Asset" + }, + "edc:dataAddress": { + "@type": "edc:DataAddress", + "edc:method": "POST", + "edc:type": "HttpData", + "edc:proxyMethod": "true", + "edc:proxyBody": "true", + "edc:baseUrl": "https://test.dtr/registry" + }, + "@context": { + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", "odrl": "http://www.w3.org/ns/odrl/2/", diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/configuration/JsonLdConfigurationTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/configuration/JsonLdConfigurationTest.java index 11d579dd55..561cebd908 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/configuration/JsonLdConfigurationTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/configuration/JsonLdConfigurationTest.java @@ -42,7 +42,7 @@ void shouldConvertJsonLD() { final JsonLdConfiguration jsonLdConfiguration = new JsonLdConfiguration(); final TitaniumJsonLd titaniumJsonLd = jsonLdConfiguration.titaniumJsonLd(jsonLdConfiguration.monitor()); final JsonObject build = Json.createObjectBuilder() - .add("dct", "https://purl.org/dc/terms/") + .add("dct", "http://purl.org/dc/terms/") .add("tx", "https://w3id.org/tractusx/v0.0.1/ns/") .add("edc", "https://w3id.org/edc/v0.0.1/ns/") .add("dcat", "https://www.w3.org/ns/dcat/") diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/contract/model/EdcContractAgreementNegotiationResponseTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/contract/model/EdcContractAgreementNegotiationResponseTest.java index 31814223e2..aa7d82fa9c 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/contract/model/EdcContractAgreementNegotiationResponseTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/contract/model/EdcContractAgreementNegotiationResponseTest.java @@ -42,7 +42,7 @@ void shouldParseEdcContractAgreementNegotiationResponse() throws JsonProcessingE "edc:createdAt": 1708590580001, "edc:contractAgreementId": "ODA3MmUyNTQtOGNlZi00YzQ2LTljNGYtNGYzNjE2YjQ5NTZl:cmVnaXN0cnktYXNzZXQ=:MDljNDMzY2EtODI5OS00OGE3LWI0MjYtNzZmZjJmODE1ZWE2", "@context": { - "dct": "https://purl.org/dc/terms/", + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", "dcat": "https://www.w3.org/ns/dcat/", diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/contract/model/EdcContractAgreementsResponseTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/contract/model/EdcContractAgreementsResponseTest.java index 045de84d92..f535088ee1 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/contract/model/EdcContractAgreementsResponseTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/contract/model/EdcContractAgreementsResponseTest.java @@ -42,7 +42,7 @@ void shouldParseEdcContractAgreementsResponse() throws JsonProcessingException { "odrl:permission": { "odrl:target": "registry-asset", "odrl:action": { - "odrl:type": "USE" + "odrl:type": "use" }, "odrl:constraint": { "odrl:or": { @@ -62,7 +62,7 @@ void shouldParseEdcContractAgreementsResponse() throws JsonProcessingException { "edc:consumerId": "BPNL00000003CML1", "edc:providerId": "BPNL00000003CML1", "@context": { - "dct": "https://purl.org/dc/terms/", + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", "dcat": "https://www.w3.org/ns/dcat/", diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionServiceTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionServiceTest.java index f47772e25d..4f91cf298a 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionServiceTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionServiceTest.java @@ -92,7 +92,7 @@ void testCreatePolicyDefinitionRequest() throws JsonProcessingException, JSONExc "@type": "Policy", "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "@type": "AtomicConstraint", "odrl:or": [ @@ -167,7 +167,7 @@ void givenPolicyName_WhenGetPolicy_ThenNotExists() throws GetEdcPolicyDefinition } @Test - void givenCreatePolicy_whenConflict_thenReturnExstingPolicyId() throws CreateEdcPolicyDefinitionException { + void givenCreatePolicy_whenConflict_thenReturnExstingPolicyId() { // given when(edcConfiguration.getControlplane()).thenReturn(controlplaneConfig); when(controlplaneConfig.getEndpoint()).thenReturn(endpointConfig); diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/testutil/TestMother.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/testutil/TestMother.java index 58a34c2d81..6504954a78 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/testutil/TestMother.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/testutil/TestMother.java @@ -23,6 +23,7 @@ ********************************************************************************/ package org.eclipse.tractusx.irs.edc.client.testutil; +import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_CATENAX_POLICY; import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_DCAT; import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_DCT; import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_DSPACE; @@ -66,6 +67,7 @@ import org.eclipse.tractusx.irs.data.StringMapper; import org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration; import org.eclipse.tractusx.irs.edc.client.model.EDRAuthCode; +import org.eclipse.tractusx.irs.edc.client.policy.PolicyType; import org.eclipse.tractusx.irs.edc.client.transformer.EdcTransformer; import org.jetbrains.annotations.NotNull; @@ -79,6 +81,7 @@ public static EdcTransformer createEdcTransformer() { titaniumJsonLd.registerNamespace("edc", NAMESPACE_EDC); titaniumJsonLd.registerNamespace("dcat", NAMESPACE_DCAT); titaniumJsonLd.registerNamespace("dspace", NAMESPACE_DSPACE); + titaniumJsonLd.registerNamespace("cx-policy", NAMESPACE_CATENAX_POLICY); return new EdcTransformer(objectMapper(), titaniumJsonLd, new TypeTransformerRegistryImpl()); } @@ -139,7 +142,7 @@ private static String getOfferId(final String assetId) { private static Permission createUsePermission(final Constraint constraint) { return Permission.Builder.newInstance() - .action(Action.Builder.newInstance().type("USE").build()) + .action(Action.Builder.newInstance().type(PolicyType.USE.getValue()).build()) .constraint(constraint) .build(); } diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformerTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformerTest.java index 6d5f0e9c7d..f5b5b287cd 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformerTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformerTest.java @@ -83,7 +83,7 @@ class EdcTransformerTest { "@type": "odrl:Offer", "odrl:permission": { "odrl:action": { - "odrl:type": "USE" + "odrl:type": "use" }, "odrl:constraint": { "odrl:or": { @@ -133,8 +133,8 @@ class EdcTransformerTest { "dct:terms": "connector", "dct:endpointUrl": "https://irs-test-controlplane-provider.dev.demo.catena-x.net/api/v1/dsp" }, - "dspace:participantId": "BPNL00000003CRHK", - "participantId": "BPNL00000003CRHK", + "dspace:participantId": "BPNL00000000TEST", + "participantId": "BPNL00000000TEST", "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", @@ -195,7 +195,7 @@ private static NegotiationRequest createNegotiation(final String providerBPN, fi } private static Policy createPolicy(final String assetId) { - final Action action = Action.Builder.newInstance().type("USE").build(); + final Action action = Action.Builder.newInstance().type("use").build(); final AtomicConstraint atomicConstraint = AtomicConstraint.Builder.newInstance() .leftExpression( new LiteralExpression("PURPOSE")) @@ -212,11 +212,12 @@ private static Policy createPolicy(final String assetId) { void setUp() { jsonLd = new TitaniumJsonLd(new ConsoleMonitor()); jsonLd.registerNamespace("odrl", "http://www.w3.org/ns/odrl/2/"); - jsonLd.registerNamespace("dct", "https://purl.org/dc/terms/"); + jsonLd.registerNamespace("dct", "http://purl.org/dc/terms/"); jsonLd.registerNamespace("tx", "https://w3id.org/tractusx/v0.0.1/ns/"); jsonLd.registerNamespace("edc", "https://w3id.org/edc/v0.0.1/ns/"); jsonLd.registerNamespace("dcat", "https://www.w3.org/ns/dcat/"); jsonLd.registerNamespace("dspace", "https://w3id.org/dspace/v0.8/"); + jsonLd.registerNamespace("cx-policy", "https://w3id.org/catenax/policy/"); ObjectMapper objectMapper = objectMapper(); edcTransformer = new EdcTransformer(objectMapper, jsonLd, new TypeTransformerRegistryImpl()); @@ -245,7 +246,7 @@ void shouldDeserializeJsonLdResponseToCatalog() throws JsonProcessingException { assertThat(actualCatalog).isNotNull(); assertThat(actualCatalog.getId()).isEqualTo("78ff625c-0c05-4014-965c-bd3d0a6a0de0"); assertThat(actualCatalog.getProperties()).containsEntry("https://w3id.org/edc/v0.0.1/ns/participantId", - "BPNL00000003CRHK"); + "BPNL00000000TEST"); assertThat(actualCatalog.getDatasets()).hasSize(1); assertThat(actualCatalog.getDataServices().get(0)).isEqualTo(expectedDataService); @@ -317,7 +318,7 @@ void shouldSerializeTransferRequestDtoToJsonObject() { final String protocol = "dataspace-protocol-http"; final String contractId = "7681f966-36ea-4542-b5ea-0d0db81967de:35c78eca-db53-442c-9e01-467fc22c9434-55840861-5d7f-444b-972a-6e8b78552d8a:66131c58-32af-4df0-825d-77f7df6017c"; final String assetId = "urn:uuid:35c78eca-db53-442c-9e01-467fc22c9434-urn:uuid:55840861-5d7f-444b-972a-6e8b78552d8a"; - final String connectorId = "BPNL00000003CRHK"; + final String connectorId = "BPNL00000000TEST"; final DataAddress dataAddress = DataAddress.Builder.newInstance().type("HttpProxy").build(); final List callbackAddresses = List.of(CallbackAddress.Builder.newInstance() .uri("https://backend.app/endpoint-data-reference") diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToCatalogTransformerTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToCatalogTransformerTest.java index 07f8560167..d546e7baef 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToCatalogTransformerTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToCatalogTransformerTest.java @@ -46,11 +46,12 @@ class JsonObjectToCatalogTransformerTest { void setUp() { final TitaniumJsonLd jsonLd = new TitaniumJsonLd(new ConsoleMonitor()); jsonLd.registerNamespace("odrl", "http://www.w3.org/ns/odrl/2/"); - jsonLd.registerNamespace("dct", "https://purl.org/dc/terms/"); + jsonLd.registerNamespace("dct", "http://purl.org/dc/terms/"); jsonLd.registerNamespace("tx", "https://w3id.org/tractusx/v0.0.1/ns/"); jsonLd.registerNamespace("edc", "https://w3id.org/edc/v0.0.1/ns/"); jsonLd.registerNamespace("dcat", "https://www.w3.org/ns/dcat/"); jsonLd.registerNamespace("dspace", "https://w3id.org/dspace/v0.8/"); + jsonLd.registerNamespace("cx-policy", "https://w3id.org/catenax/policy/"); ObjectMapper objectMapper = objectMapper(); edcTransformer = new EdcTransformer(objectMapper, jsonLd, new TypeTransformerRegistryImpl()); @@ -96,7 +97,7 @@ void shouldTransformJsonObjectToPolicyCorrectly() { "@type": "odrl:Offer", "odrl:permission": { "odrl:action": { - "odrl:type": "USE" + "odrl:type": "use" }, "odrl:constraint": { "odrl:or": { @@ -161,7 +162,7 @@ void shouldTransformJsonObjectToPolicyCorrectly() { "@type": "odrl:Offer", "odrl:permission": { "odrl:action": { - "odrl:type": "USE" + "odrl:type": "use" }, "odrl:constraint": { "odrl:or": { diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToIrsPolicyTransformerTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToIrsPolicyTransformerTest.java index 8c5c83ed8c..0fe40a1e52 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToIrsPolicyTransformerTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToIrsPolicyTransformerTest.java @@ -59,7 +59,7 @@ class JsonObjectToIrsPolicyTransformerTest { "policy": { "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "odrl:and": [ { diff --git a/irs-edc-client/src/test/resources/__files/edc/responseCatalog.json b/irs-edc-client/src/test/resources/__files/edc/responseCatalog.json index ba262b2acd..fb727a779a 100644 --- a/irs-edc-client/src/test/resources/__files/edc/responseCatalog.json +++ b/irs-edc-client/src/test/resources/__files/edc/responseCatalog.json @@ -1,7 +1,7 @@ { "@id": "78ff625c-0c05-4014-965c-bd3d0a6a0de0", "@type": "dcat:Catalog", - "dspace:participantId": "BPNL00000003CRHK", + "dspace:participantId": "BPNL00000000TEST", "dcat:dataset": { "@id": "urn:uuid:ea32f6f7-c884-4bfd-af4a-778666a1fffb", "@type": "dcat:Dataset", @@ -81,7 +81,7 @@ "dct:terms": "connector", "dct:endpointUrl": "http://edc.io/api/v1/dsp" }, - "participantId": "BPNL00000003CRHK", + "participantId": "BPNL00000000TEST", "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", diff --git a/irs-edc-client/src/test/resources/__files/edc/responseGetNegotiationConfirmed.json b/irs-edc-client/src/test/resources/__files/edc/responseGetNegotiationConfirmed.json index 7dd7e1ad38..080345bada 100644 --- a/irs-edc-client/src/test/resources/__files/edc/responseGetNegotiationConfirmed.json +++ b/irs-edc-client/src/test/resources/__files/edc/responseGetNegotiationConfirmed.json @@ -8,7 +8,7 @@ "edc:callbackAddresses": [], "edc:contractAgreementId": "7681f966-36ea-4542-b5ea-0d0db81967de:5a7ab616-989f-46ae-bdf2-32027b9f6ee6-31b614f5-ec14-4ed2-a509-e7b7780083e7:a6144a2e-c1b1-4ec6-96e1-a221da134e4f", "@context": { - "dct": "https://purl.org/dc/terms/", + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", "dcat": "https://www.w3.org/ns/dcat/", diff --git a/irs-edc-client/src/test/resources/__files/edc/responseGetNegotiationState.json b/irs-edc-client/src/test/resources/__files/edc/responseGetNegotiationState.json index ee4e9141e6..17ad6b9987 100644 --- a/irs-edc-client/src/test/resources/__files/edc/responseGetNegotiationState.json +++ b/irs-edc-client/src/test/resources/__files/edc/responseGetNegotiationState.json @@ -2,7 +2,7 @@ "@type": "edc:NegotiationState", "edc:state": "FINALIZED", "@context": { - "dct": "https://purl.org/dc/terms/", + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", "dcat": "https://www.w3.org/ns/dcat/", diff --git a/irs-edc-client/src/test/resources/__files/edc/responseGetTransferConfirmed.json b/irs-edc-client/src/test/resources/__files/edc/responseGetTransferConfirmed.json index 119861b6f0..f6e6234dfb 100644 --- a/irs-edc-client/src/test/resources/__files/edc/responseGetTransferConfirmed.json +++ b/irs-edc-client/src/test/resources/__files/edc/responseGetTransferConfirmed.json @@ -13,11 +13,11 @@ "@id": "1b21e963-0bc5-422a-b30d-fd3511861d88", "edc:assetId": "5a7ab616-989f-46ae-bdf2-32027b9f6ee6-31b614f5-ec14-4ed2-a509-e7b7780083e7", "edc:contractId": "7681f966-36ea-4542-b5ea-0d0db81967de:5a7ab616-989f-46ae-bdf2-32027b9f6ee6-31b614f5-ec14-4ed2-a509-e7b7780083e7:a6144a2e-c1b1-4ec6-96e1-a221da134e4f", - "edc:connectorId": "BPNL00000003CRHK" + "edc:connectorId": "BPNL00000000TEST" }, "edc:receiverHttpEndpoint": "https://irs-submodel-server3.dev.demo.catena-x.net/data/endpoint-data", "@context": { - "dct": "https://purl.org/dc/terms/", + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", "dcat": "https://www.w3.org/ns/dcat/", diff --git a/irs-edc-client/src/test/resources/__files/edc/responseGetTransferState.json b/irs-edc-client/src/test/resources/__files/edc/responseGetTransferState.json index 7d0b2f267c..22715906e8 100644 --- a/irs-edc-client/src/test/resources/__files/edc/responseGetTransferState.json +++ b/irs-edc-client/src/test/resources/__files/edc/responseGetTransferState.json @@ -2,7 +2,7 @@ "@type": "edc:TransferState", "edc:state": "COMPLETED", "@context": { - "dct": "https://purl.org/dc/terms/", + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", "dcat": "https://www.w3.org/ns/dcat/", diff --git a/irs-edc-client/src/test/resources/__files/edc/responseStartNegotiation.json b/irs-edc-client/src/test/resources/__files/edc/responseStartNegotiation.json index cb7ca32a7c..75cacfebbc 100644 --- a/irs-edc-client/src/test/resources/__files/edc/responseStartNegotiation.json +++ b/irs-edc-client/src/test/resources/__files/edc/responseStartNegotiation.json @@ -3,7 +3,7 @@ "@id": "1bbaec6e-c316-4e1e-8258-c07a648cc43c", "edc:createdAt": 1686830151573, "@context": { - "dct": "https://purl.org/dc/terms/", + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", "dcat": "https://www.w3.org/ns/dcat/", diff --git a/irs-edc-client/src/test/resources/__files/edc/responseStartTransferprocess.json b/irs-edc-client/src/test/resources/__files/edc/responseStartTransferprocess.json index f6be3d222e..c4a8edc4a2 100644 --- a/irs-edc-client/src/test/resources/__files/edc/responseStartTransferprocess.json +++ b/irs-edc-client/src/test/resources/__files/edc/responseStartTransferprocess.json @@ -3,7 +3,7 @@ "@id": "1b21e963-0bc5-422a-b30d-fd3511861d88", "edc:createdAt": 1686758532950, "@context": { - "dct": "https://purl.org/dc/terms/", + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", "dcat": "https://www.w3.org/ns/dcat/", diff --git a/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/controllers/PolicyStoreController.java b/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/controllers/PolicyStoreController.java index 470f714830..bd2aa004ca 100644 --- a/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/controllers/PolicyStoreController.java +++ b/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/controllers/PolicyStoreController.java @@ -46,6 +46,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.eclipse.tractusx.irs.common.auth.IrsRoles; +import org.eclipse.tractusx.irs.data.JsonParseException; import org.eclipse.tractusx.irs.dtos.ErrorResponse; import org.eclipse.tractusx.irs.edc.client.policy.Policy; import org.eclipse.tractusx.irs.policystore.models.CreatePoliciesResponse; @@ -126,8 +127,13 @@ public class PolicyStoreController { @ResponseStatus(HttpStatus.CREATED) @PreAuthorize("hasAuthority('" + IrsRoles.ADMIN_IRS + "')") public CreatePoliciesResponse registerAllowedPolicy(@Valid @RequestBody final CreatePolicyRequest request) { + final Policy registeredPolicy; - final Policy registeredPolicy = service.registerPolicy(request); + try { + registeredPolicy = service.registerPolicy(request); + } catch (JsonParseException e) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage(), e); + } if (registeredPolicy == null) { throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Policy was not registered"); diff --git a/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/CreatePolicyRequest.java b/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/CreatePolicyRequest.java index 59624d8d47..22d43026ed 100644 --- a/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/CreatePolicyRequest.java +++ b/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/CreatePolicyRequest.java @@ -72,7 +72,7 @@ The business partner number (BPN) for which the policy should be registered. "@type": "Policy", "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "odrl:and": [ { diff --git a/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/PolicyResponse.java b/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/PolicyResponse.java index b4c583a91a..11cbcdd24c 100644 --- a/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/PolicyResponse.java +++ b/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/PolicyResponse.java @@ -48,7 +48,7 @@ public record PolicyResponse(OffsetDateTime validUntil, Payload payload) { "validUntil": "2025-12-12T23:59:59.999Z", "permissions": [ { - "action": "USE", + "action": "use", "constraint": { "and": [ { @@ -94,7 +94,7 @@ public record PolicyResponse(OffsetDateTime validUntil, Payload payload) { "policy": { "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "odrl:and": [ { diff --git a/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/controllers/PolicyStoreControllerTest.java b/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/controllers/PolicyStoreControllerTest.java index efb004e775..393b27f2f7 100644 --- a/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/controllers/PolicyStoreControllerTest.java +++ b/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/controllers/PolicyStoreControllerTest.java @@ -70,7 +70,7 @@ public class PolicyStoreControllerTest { "policy": { "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "odrl:and": [ { diff --git a/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/DefaultConfiguration.java b/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/DefaultConfiguration.java index 73c4da4907..a15eeb7221 100644 --- a/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/DefaultConfiguration.java +++ b/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/DefaultConfiguration.java @@ -118,9 +118,9 @@ public ConnectorEndpointsService connectorEndpointsService(final DiscoveryFinder @ConditionalOnProperty(prefix = CONFIG_PREFIX, name = CONFIG_FIELD_TYPE, havingValue = CONFIG_VALUE_DECENTRAL) public EndpointDataForConnectorsService endpointDataForConnectorsService(final EdcSubmodelFacade facade) { - final EdcEndpointReferenceRetriever edcEndpointReferenceRetriever = (edcConnectorEndpoint, assetType, assetValue, bpn) -> { + final EdcEndpointReferenceRetriever edcEndpointReferenceRetriever = (edcConnectorEndpoint, bpn) -> { try { - return facade.getEndpointReferencesForAsset(edcConnectorEndpoint, assetType, assetValue, bpn); + return facade.getEndpointReferencesForRegistryAsset(edcConnectorEndpoint, bpn); } catch (EdcClientException e) { throw new EdcRetrieverException(e); } diff --git a/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/EdcEndpointReferenceRetriever.java b/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/EdcEndpointReferenceRetriever.java index 3b76116a3a..68ba435f48 100644 --- a/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/EdcEndpointReferenceRetriever.java +++ b/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/EdcEndpointReferenceRetriever.java @@ -37,13 +37,10 @@ public interface EdcEndpointReferenceRetriever { * Retrieves the EDC endpoint references from the specified connector endpoint and asset combination * * @param edcConnectorEndpoint the endpoint URL - * @param assetType the asset type id - * @param assetValue the asset type value * @param bpn bpn value * @return the endpoint data references as list of futures * @throws EdcRetrieverException on any EDC errors */ @SuppressWarnings("PMD.UseObjectForClearerAPI") - List> getEndpointReferencesForAsset(String edcConnectorEndpoint, - String assetType, String assetValue, String bpn) throws EdcRetrieverException; + List> getEndpointReferencesForAsset(String edcConnectorEndpoint, String bpn) throws EdcRetrieverException; } diff --git a/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsService.java b/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsService.java index c65abe5f1e..a71abc4d6e 100644 --- a/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsService.java +++ b/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsService.java @@ -40,8 +40,6 @@ @RequiredArgsConstructor public class EndpointDataForConnectorsService { - private static final String DT_REGISTRY_ASSET_TYPE = "https://w3id.org/edc/v0.0.1/ns/type"; - private static final String DT_REGISTRY_ASSET_VALUE = "data.core.digitalTwinRegistry"; private static final String TOOK_MS = "{} took {} ms"; private final EdcEndpointReferenceRetriever edcSubmodelFacade; @@ -77,8 +75,7 @@ private List> createGetEndpointReferenc log.info(msg); try { - return edcSubmodelFacade.getEndpointReferencesForAsset(edcUrl, DT_REGISTRY_ASSET_TYPE, - DT_REGISTRY_ASSET_VALUE, bpn); + return edcSubmodelFacade.getEndpointReferencesForAsset(edcUrl, bpn); } catch (EdcRetrieverException e) { log.warn("Exception occurred when retrieving EndpointDataReference from connector '{}'", edcUrl, e); return List.of(CompletableFuture.failedFuture(e)); diff --git a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/DefaultConfigurationTest.java b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/DefaultConfigurationTest.java index f5f47863ff..22bbf0c673 100644 --- a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/DefaultConfigurationTest.java +++ b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/DefaultConfigurationTest.java @@ -88,7 +88,7 @@ void endpointDataForConnectorsService() throws EdcClientException { final var endpointAddress = "endpointaddress"; final String contractAgreementId = "contractAgreementId"; final var endpointDataReference = endpointDataReference(contractAgreementId, endpointAddress); - when(mock.getEndpointReferencesForAsset(eq(endpointAddress), any(), any(), any())).thenReturn( + when(mock.getEndpointReferencesForRegistryAsset(eq(endpointAddress), any())).thenReturn( List.of(CompletableFuture.completedFuture(endpointDataReference))); // ACT @@ -107,13 +107,13 @@ void endpointDataForConnectorsService() throws EdcClientException { }); // ASSERT - verify(mock).getEndpointReferencesForAsset(eq(endpointAddress), any(), any(), any()); + verify(mock).getEndpointReferencesForRegistryAsset(eq(endpointAddress), any()); } @Test void endpointDataForConnectorsService_withException() throws EdcClientException { final var mock = mock(EdcSubmodelFacade.class); - when(mock.getEndpointReferencesForAsset(any(), any(), any(), any())).thenThrow(new EdcClientException("test")); + when(mock.getEndpointReferencesForRegistryAsset(any(), any())).thenThrow(new EdcClientException("test")); final var endpointDataForConnectorsService = testee.endpointDataForConnectorsService(mock); final var dummyEndpoints = List.of("test"); diff --git a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceWiremockTest.java b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceWiremockTest.java index 59a09cccb1..fb3164c045 100644 --- a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceWiremockTest.java +++ b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceWiremockTest.java @@ -112,8 +112,7 @@ void shouldDiscoverEDCAndRequestRegistry() throws RegistryServiceException, EdcR givenThat(getShellDescriptor200()); final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), - any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); // Act final Collection shells = decentralDigitalTwinRegistryService.fetchShells( @@ -161,8 +160,7 @@ void shouldThrowInCaseOfLookupShellsError() throws EdcRetrieverException { givenThat(postEdcDiscovery200()); final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), - any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); givenThat(getLookupShells404()); final List testId = List.of(new DigitalTwinRegistryKey("testId", TEST_BPN)); @@ -182,8 +180,7 @@ void shouldThrowInCaseOfShellDescriptorsError() throws EdcRetrieverException { givenThat(postEdcDiscovery200()); final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), - any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); givenThat(getLookupShells200()); givenThat(getShellDescriptor404()); @@ -205,8 +202,7 @@ void shouldThrowExceptionOnEmptyShells() throws EdcRetrieverException { givenThat(postEdcDiscovery200()); final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), - any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); givenThat(getLookupShells200Empty()); givenThat(getShellDescriptor404()); @@ -235,8 +231,7 @@ void lookupShellIdentifiers_oneEDC_oneDTR() throws RegistryServiceException, Edc // simulate endpoint data reference final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), - any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); // Act final Collection digitalTwinRegistryKeys = decentralDigitalTwinRegistryService.lookupShellIdentifiers( @@ -266,10 +261,8 @@ void lookupShellIdentifiers_multipleEDCs_oneDTR(String title, // simulate endpoint data reference final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc1Url), any(), any(), - any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc2Url), any(), any(), - any())).thenReturn(endpointDataReferenceForAssetFutures); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc1Url), any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc2Url), any())).thenReturn(endpointDataReferenceForAssetFutures); // Act final Collection digitalTwinRegistryKeys = decentralDigitalTwinRegistryService.lookupShellIdentifiers( @@ -311,10 +304,8 @@ void lookupShellIdentifiers_multipleEDCs_multipleDTRs() throws RegistryServiceEx // simulate endpoint data reference final var endpointDataReference1 = endpointDataReference("dtr1-assetId"); final var endpointDataReference2 = endpointDataReference("dtr2-assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc1Url), any(), any(), - any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference1))); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc2Url), any(), any(), - any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference2))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc1Url), any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference1))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc2Url), any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference2))); // Act & Assert final Collection digitalTwinRegistryKeys = decentralDigitalTwinRegistryService.lookupShellIdentifiers( diff --git a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsServiceTest.java b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsServiceTest.java index ffee494aaf..30163c000f 100644 --- a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsServiceTest.java +++ b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsServiceTest.java @@ -43,9 +43,6 @@ class EndpointDataForConnectorsServiceTest { - private static final String DT_REGISTRY_ASSET_TYPE = "https://w3id.org/edc/v0.0.1/ns/type"; - private static final String DT_REGISTRY_ASSET_VALUE = "data.core.digitalTwinRegistry"; - private static final String CONNECTION_ONE_ADDRESS = "connectionOneAddress"; private static final String CONNECTION_TWO_ADDRESS = "connectionTwoAddress"; private static final String CONNECTION_ONE_CONTRACT_ID = "id1"; @@ -77,8 +74,7 @@ class EndpointDataForConnectorsServiceTest { void shouldReturnExpectedEndpointDataReference() throws EdcRetrieverException { // GIVEN - when(edcSubmodelFacade.getEndpointReferencesForAsset(CONNECTION_ONE_ADDRESS, DT_REGISTRY_ASSET_TYPE, - DT_REGISTRY_ASSET_VALUE, BPN)).thenReturn( + when(edcSubmodelFacade.getEndpointReferencesForAsset(CONNECTION_ONE_ADDRESS, BPN)).thenReturn( List.of(CompletableFuture.completedFuture(CONNECTION_ONE_DATA_REF))); // WHEN @@ -99,13 +95,11 @@ void shouldReturnExpectedEndpointDataReferenceFromSecondConnectionEndpoint() thr // GIVEN // a first endpoint failing (1) - when(edcSubmodelFacade.getEndpointReferencesForAsset(CONNECTION_ONE_ADDRESS, DT_REGISTRY_ASSET_TYPE, - DT_REGISTRY_ASSET_VALUE, BPN)).thenThrow( + when(edcSubmodelFacade.getEndpointReferencesForAsset(CONNECTION_ONE_ADDRESS, BPN)).thenThrow( new EdcRetrieverException(new EdcClientException("EdcClientException"))); // and a second endpoint returning successfully (2) - when(edcSubmodelFacade.getEndpointReferencesForAsset(CONNECTION_TWO_ADDRESS, DT_REGISTRY_ASSET_TYPE, - DT_REGISTRY_ASSET_VALUE, BPN)).thenReturn( + when(edcSubmodelFacade.getEndpointReferencesForAsset(CONNECTION_TWO_ADDRESS, BPN)).thenReturn( List.of(CompletableFuture.completedFuture(CONNECTION_TWO_DATA_REF))); // WHEN @@ -140,8 +134,7 @@ private static EndpointDataReference executeFutureMappingErrorsToNull( void shouldThrowExceptionWhenConnectorEndpointsNotReachable() throws EdcRetrieverException { // GIVEN - when(edcSubmodelFacade.getEndpointReferencesForAsset(anyString(), eq(DT_REGISTRY_ASSET_TYPE), - eq(DT_REGISTRY_ASSET_VALUE), eq(BPN))).thenThrow( + when(edcSubmodelFacade.getEndpointReferencesForAsset(anyString(), eq(BPN))).thenThrow( new EdcRetrieverException(new EdcClientException("EdcClientException"))); // WHEN diff --git a/irs-testing/src/main/java/org/eclipse/tractusx/irs/testing/wiremock/SubmodelFacadeWiremockSupport.java b/irs-testing/src/main/java/org/eclipse/tractusx/irs/testing/wiremock/SubmodelFacadeWiremockSupport.java index 18ba695874..17d1573002 100644 --- a/irs-testing/src/main/java/org/eclipse/tractusx/irs/testing/wiremock/SubmodelFacadeWiremockSupport.java +++ b/irs-testing/src/main/java/org/eclipse/tractusx/irs/testing/wiremock/SubmodelFacadeWiremockSupport.java @@ -50,12 +50,13 @@ public final class SubmodelFacadeWiremockSupport { }"""; public static final String EDC_PROVIDER_DUMMY_URL = "https://edc.io/api/v1/dsp"; public static final String IRS_INTERNAL_CALLBACK_URL = "https://irs.test/internal/endpoint-data-reference"; - public static final String EDC_PROVIDER_BPN = "BPNL00000003CRHK"; + public static final String EDC_PROVIDER_BPN = "BPNL00000000TEST"; public static final int STATUS_CODE_OK = 200; public static final String CX_POLICY_FRAMEWORK_AGREEMENT = "cx-policy:FrameworkAgreement"; public static final String TRACEABILITY_1_0 = "traceability:1.0"; public static final String CX_POLICY_USAGE_PURPOSE = "cx-policy:UsagePurpose"; public static final String CX_CORE_INDUSTRYCORE_1 = "cx.core.industrycore:1"; + public static final String PERMISSION_TYPE = "use"; private SubmodelFacadeWiremockSupport() { } @@ -73,7 +74,8 @@ public static void prepareNegotiation(final String negotiationId, final String t stubFor(post(urlPathEqualTo(PATH_CATALOG)).willReturn(WireMockConfig.responseWithStatus(STATUS_CODE_OK) .withBody(getCatalogResponse(edcAssetId, - contractAgreementId, "USE", + contractAgreementId, + PERMISSION_TYPE, EDC_PROVIDER_BPN)))); stubFor(post(urlPathEqualTo(PATH_NEGOTIATE)).willReturn( diff --git a/local/testing/request-collection/IRS_Request_Collection.json b/local/testing/request-collection/IRS_Request_Collection.json index a1d2156f6d..569d04030d 100644 --- a/local/testing/request-collection/IRS_Request_Collection.json +++ b/local/testing/request-collection/IRS_Request_Collection.json @@ -2651,7 +2651,7 @@ "method": "POST", "body": { "mimeType": "application/json", - "text": "{\n\t\"@context\": {\n\t\t\"dct\": \"https://purl.org/dc/terms/\",\n\t\t\"tx\": \"https://w3id.org/tractusx/v0.0.1/ns/\",\n\t\t\"edc\": \"https://w3id.org/edc/v0.0.1/ns/\",\n\t\t\"odrl\": \"http://www.w3.org/ns/odrl/2/\",\n\t\t\"dcat\": \"https://www.w3.org/ns/dcat/\",\n\t\t\"dspace\": \"https://w3id.org/dspace/v0.8/\"\n\t},\n\t\"edc:protocol\": \"dataspace-protocol-http\",\n\t\"edc:providerUrl\": \"{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp\"\n}" + "text": "{\n\t\"@context\": {\n\t\t\"dct\": \"http://purl.org/dc/terms/\",\n\t\t\"tx\": \"https://w3id.org/tractusx/v0.0.1/ns/\",\n\t\t\"edc\": \"https://w3id.org/edc/v0.0.1/ns/\",\n\t\t\"odrl\": \"http://www.w3.org/ns/odrl/2/\",\n\t\t\"dcat\": \"https://www.w3.org/ns/dcat/\",\n\t\t\"dspace\": \"https://w3id.org/dspace/v0.8/\"\n\t},\n\t\"edc:protocol\": \"dataspace-protocol-http\",\n\t\"edc:providerUrl\": \"{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp\"\n}" }, "parameters": [], "headers": [ @@ -2712,7 +2712,7 @@ "method": "POST", "body": { "mimeType": "application/json", - "text": "{\n\t\"@context\": {\n\t\t\"dct\": \"https://purl.org/dc/terms/\",\n\t\t\"tx\": \"https://w3id.org/tractusx/v0.0.1/ns/\",\n\t\t\"edc\": \"https://w3id.org/edc/v0.0.1/ns/\",\n\t\t\"odrl\": \"http://www.w3.org/ns/odrl/2/\",\n\t\t\"dcat\": \"https://www.w3.org/ns/dcat/\",\n\t\t\"dspace\": \"https://w3id.org/dspace/v0.8/\"\n\t},\n\t\"edc:providerUrl\": \"{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp\",\n\t\"edc:protocol\": \"dataspace-protocol-http\",\n\t\"edc:querySpec\": {\n\t\t\"edc:filterExpression\": {\n\t\t\t\"edc:operandLeft\": \"https://w3id.org/edc/v0.0.1/ns/type\",\n\t\t\t\"edc:operator\": \"=\",\n\t\t\t\"edc:operandRight\": \"data.core.digitalTwinRegistry\"\n\t\t}\n\t}\n}" + "text": "{\n\t\"@context\": {\n\t\t\"dct\": \"http://purl.org/dc/terms/\",\n\t\t\"tx\": \"https://w3id.org/tractusx/v0.0.1/ns/\",\n\t\t\"edc\": \"https://w3id.org/edc/v0.0.1/ns/\",\n\t\t\"odrl\": \"http://www.w3.org/ns/odrl/2/\",\n\t\t\"dcat\": \"https://www.w3.org/ns/dcat/\",\n\t\t\"dspace\": \"https://w3id.org/dspace/v0.8/\"\n\t},\n\t\"edc:providerUrl\": \"{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp\",\n\t\"edc:protocol\": \"dataspace-protocol-http\",\n\t\"edc:querySpec\": {\n\t\t\"edc:filterExpression\": {\n\t\t\t\"edc:operandLeft\": \"https://w3id.org/edc/v0.0.1/ns/type\",\n\t\t\t\"edc:operator\": \"=\",\n\t\t\t\"edc:operandRight\": \"data.core.digitalTwinRegistry\"\n\t\t}\n\t}\n}" }, "parameters": [], "headers": [ @@ -2749,7 +2749,7 @@ "method": "POST", "body": { "mimeType": "application/json", - "text": "{\n\t\"@context\": {\n\t\t\"dct\": \"https://purl.org/dc/terms/\",\n\t\t\"tx\": \"https://w3id.org/tractusx/v0.0.1/ns/\",\n\t\t\"edc\": \"https://w3id.org/edc/v0.0.1/ns/\",\n\t\t\"odrl\": \"http://www.w3.org/ns/odrl/2/\",\n\t\t\"dcat\": \"https://www.w3.org/ns/dcat/\",\n\t\t\"dspace\": \"https://w3id.org/dspace/v0.8/\"\n\t},\n\t\"edc:providerUrl\": \"{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp\",\n\t\"edc:protocol\": \"dataspace-protocol-http\",\n\t\"edc:querySpec\": {\n\t\t\"edc:filterExpression\": {\n\t\t\t\"edc:operandLeft\": \"https://w3id.org/edc/v0.0.1/ns/id\",\n\t\t\t\"edc:operator\": \"=\",\n\t\t\t\"edc:operandRight\": \"{% prompt 'assetId', '', '', '', false, true %}\"\n\t\t}\n\t}\n}" + "text": "{\n\t\"@context\": {\n\t\t\"dct\": \"http://purl.org/dc/terms/\",\n\t\t\"tx\": \"https://w3id.org/tractusx/v0.0.1/ns/\",\n\t\t\"edc\": \"https://w3id.org/edc/v0.0.1/ns/\",\n\t\t\"odrl\": \"http://www.w3.org/ns/odrl/2/\",\n\t\t\"dcat\": \"https://www.w3.org/ns/dcat/\",\n\t\t\"dspace\": \"https://w3id.org/dspace/v0.8/\"\n\t},\n\t\"edc:providerUrl\": \"{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp\",\n\t\"edc:protocol\": \"dataspace-protocol-http\",\n\t\"edc:querySpec\": {\n\t\t\"edc:filterExpression\": {\n\t\t\t\"edc:operandLeft\": \"https://w3id.org/edc/v0.0.1/ns/id\",\n\t\t\t\"edc:operator\": \"=\",\n\t\t\t\"edc:operandRight\": \"{% prompt 'assetId', '', '', '', false, true %}\"\n\t\t}\n\t}\n}" }, "parameters": [], "headers": [ @@ -2786,7 +2786,7 @@ "method": "POST", "body": { "mimeType": "application/json", - "text": "{\n\t\"edc:connectorAddress\": \"{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp\",\n\t\"edc:connectorId\": \"BPNL00000001CRHK\",\n\t\"edc:offer\": {\n\t\t\"@type\": \"edc:ContractOfferDescription\",\n\t\t\"edc:offerId\": \"ZGR0ci1jeG1lbWJlcnMtY29udHJhY3Q=:ZGlnaXRhbC10d2luLXJlZ2lzdHJ5:OGQ0ZTNkODYtOTIxOC00MjljLWI1N2EtNWZlZTZkODIzMmEx\",\n\t\t\"edc:assetId\": \"digital-twin-registry\",\n\t\t\"edc:policy\": {\n\t\t\t\"@type\": \"odrl:Set\",\n\t\t\t\"odrl:permission\": {\n\t\t\t\t\"odrl:target\": \"digital-twin-registry\",\n\t\t\t\t\"odrl:action\": {\n\t\t\t\t\t\"odrl:type\": \"USE\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"odrl:prohibition\": [],\n\t\t\t\"odrl:obligation\": [],\n\t\t\t\"odrl:target\": \"digital-twin-registry\"\n\t\t}\n\t},\n\t\"edc:protocol\": \"dataspace-protocol-http\",\n\t\"edc:callbackAddresses\": [],\n\t\"@context\": {\n\t\t\"dct\": \"https://purl.org/dc/terms/\",\n\t\t\"tx\": \"https://w3id.org/tractusx/v0.0.1/ns/\",\n\t\t\"edc\": \"https://w3id.org/edc/v0.0.1/ns/\",\n\t\t\"odrl\": \"http://www.w3.org/ns/odrl/2/\",\n\t\t\"dcat\": \"https://www.w3.org/ns/dcat/\",\n\t\t\"dspace\": \"https://w3id.org/dspace/v0.8/\"\n\t}\n}" + "text": "{\n\t\"edc:connectorAddress\": \"{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp\",\n\t\"edc:connectorId\": \"BPNL00000001CRHK\",\n\t\"edc:offer\": {\n\t\t\"@type\": \"edc:ContractOfferDescription\",\n\t\t\"edc:offerId\": \"ZGR0ci1jeG1lbWJlcnMtY29udHJhY3Q=:ZGlnaXRhbC10d2luLXJlZ2lzdHJ5:OGQ0ZTNkODYtOTIxOC00MjljLWI1N2EtNWZlZTZkODIzMmEx\",\n\t\t\"edc:assetId\": \"digital-twin-registry\",\n\t\t\"edc:policy\": {\n\t\t\t\"@type\": \"odrl:Set\",\n\t\t\t\"odrl:permission\": {\n\t\t\t\t\"odrl:target\": \"digital-twin-registry\",\n\t\t\t\t\"odrl:action\": {\n\t\t\t\t\t\"odrl:type\": \"USE\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"odrl:prohibition\": [],\n\t\t\t\"odrl:obligation\": [],\n\t\t\t\"odrl:target\": \"digital-twin-registry\"\n\t\t}\n\t},\n\t\"edc:protocol\": \"dataspace-protocol-http\",\n\t\"edc:callbackAddresses\": [],\n\t\"@context\": {\n\t\t\"dct\": \"http://purl.org/dc/terms/\",\n\t\t\"tx\": \"https://w3id.org/tractusx/v0.0.1/ns/\",\n\t\t\"edc\": \"https://w3id.org/edc/v0.0.1/ns/\",\n\t\t\"odrl\": \"http://www.w3.org/ns/odrl/2/\",\n\t\t\"dcat\": \"https://www.w3.org/ns/dcat/\",\n\t\t\"dspace\": \"https://w3id.org/dspace/v0.8/\"\n\t}\n}" }, "parameters": [], "headers": [ @@ -2935,7 +2935,7 @@ "method": "POST", "body": { "mimeType": "application/json", - "text": "{\n\t\"edc:assetId\": \"digital-twin-registry\",\n\t\"edc:connectorAddress\": \"{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp\",\n\t\"edc:contractId\": \"ZGR0ci1jeG1lbWJlcnMtY29udHJhY3Q=:ZGlnaXRhbC10d2luLXJlZ2lzdHJ5:NGNlMDk0ODgtOTMzYy00ZDk3LThiNTAtNDMyZWRjMzIwM2Fm\",\n\t\"edc:dataDestination\": {\n\t\t\"edc:type\": \"HttpProxy\"\n\t},\n\t\"edc:protocol\": \"dataspace-protocol-http\",\n\t\"edc:managedResources\": false,\n\t\"edc:connectorId\": \"BPNL00000001CRHK\",\n\t\"@context\": {\n\t\t\"dct\": \"https://purl.org/dc/terms/\",\n\t\t\"tx\": \"https://w3id.org/tractusx/v0.0.1/ns/\",\n\t\t\"edc\": \"https://w3id.org/edc/v0.0.1/ns/\",\n\t\t\"odrl\": \"http://www.w3.org/ns/odrl/2/\",\n\t\t\"dcat\": \"https://www.w3.org/ns/dcat/\",\n\t\t\"dspace\": \"https://w3id.org/dspace/v0.8/\"\n\t}\n}" + "text": "{\n\t\"edc:assetId\": \"digital-twin-registry\",\n\t\"edc:connectorAddress\": \"{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp\",\n\t\"edc:contractId\": \"ZGR0ci1jeG1lbWJlcnMtY29udHJhY3Q=:ZGlnaXRhbC10d2luLXJlZ2lzdHJ5:NGNlMDk0ODgtOTMzYy00ZDk3LThiNTAtNDMyZWRjMzIwM2Fm\",\n\t\"edc:dataDestination\": {\n\t\t\"edc:type\": \"HttpProxy\"\n\t},\n\t\"edc:protocol\": \"dataspace-protocol-http\",\n\t\"edc:managedResources\": false,\n\t\"edc:connectorId\": \"BPNL00000001CRHK\",\n\t\"@context\": {\n\t\t\"dct\": \"http://purl.org/dc/terms/\",\n\t\t\"tx\": \"https://w3id.org/tractusx/v0.0.1/ns/\",\n\t\t\"edc\": \"https://w3id.org/edc/v0.0.1/ns/\",\n\t\t\"odrl\": \"http://www.w3.org/ns/odrl/2/\",\n\t\t\"dcat\": \"https://www.w3.org/ns/dcat/\",\n\t\t\"dspace\": \"https://w3id.org/dspace/v0.8/\"\n\t}\n}" }, "parameters": [], "headers": [ diff --git a/local/testing/testdata/CX_Testdata_v.1.7.0_PartType.json b/local/testing/testdata/CX_Testdata_v.1.7.0_PartType.json index 5572c4ff4b..c3fe01b1fa 100644 --- a/local/testing/testdata/CX_Testdata_v.1.7.0_PartType.json +++ b/local/testing/testdata/CX_Testdata_v.1.7.0_PartType.json @@ -2,7 +2,8 @@ "policies": { "traceability-core": { "@context": { - "odrl": "http://www.w3.org/ns/odrl/2/" + "odrl": "http://www.w3.org/ns/odrl/2/", + "cx-policy": "https://w3id.org/catenax/policy/" }, "@type": "PolicyDefinitionRequestDto", "@id": "traceability-core", @@ -10,7 +11,7 @@ "@type": "odrl:Set", "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "@type": "AtomicConstraint", "odrl:and": [ diff --git a/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-not-accepted-policy.json b/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-not-accepted-policy.json index 2106d4d0ac..8d3ecfcdae 100644 --- a/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-not-accepted-policy.json +++ b/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-not-accepted-policy.json @@ -10,7 +10,7 @@ "@type": "odrl:Set", "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "odrl:or": [ { diff --git a/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-reduced.json b/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-reduced.json index 923c27186b..a789d15a9c 100644 --- a/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-reduced.json +++ b/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-reduced.json @@ -2,7 +2,8 @@ "policies": { "traceability-core": { "@context": { - "odrl": "http://www.w3.org/ns/odrl/2/" + "odrl": "http://www.w3.org/ns/odrl/2/", + "cx-policy": "https://w3id.org/catenax/policy/" }, "@type": "PolicyDefinitionRequestDto", "@id": "traceability-core", @@ -10,7 +11,7 @@ "@type": "odrl:Set", "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "@type": "AtomicConstraint", "odrl:and": [ diff --git a/local/testing/testdata/ESS_Testdata_v2.0.0-AsPlanned.json b/local/testing/testdata/ESS_Testdata_v2.0.0-AsPlanned.json index 421ce2022b..43b0d510de 100644 --- a/local/testing/testdata/ESS_Testdata_v2.0.0-AsPlanned.json +++ b/local/testing/testdata/ESS_Testdata_v2.0.0-AsPlanned.json @@ -2,7 +2,8 @@ "policies": { "traceability-core": { "@context": { - "odrl": "http://www.w3.org/ns/odrl/2/" + "odrl": "http://www.w3.org/ns/odrl/2/", + "cx-policy": "https://w3id.org/catenax/policy/" }, "@type": "PolicyDefinitionRequestDto", "@id": "traceability-core", @@ -10,7 +11,7 @@ "@type": "odrl:Set", "odrl:permission": [ { - "odrl:action": "USE", + "odrl:action": "use", "odrl:constraint": { "@type": "AtomicConstraint", "odrl:and": [ diff --git a/local/testing/testdata/transform-and-upload.py b/local/testing/testdata/transform-and-upload.py index 9c7d3e3765..ed81839dc6 100644 --- a/local/testing/testdata/transform-and-upload.py +++ b/local/testing/testdata/transform-and-upload.py @@ -60,7 +60,11 @@ def create_edc_registry_asset_payload(registry_url_, asset_prop_id_): "@context": edc_context(), "@id": f"{asset_prop_id_}", # DTR-EDC-instance-unique-ID "edc:properties": { - "edc:description": "Digital Twin Registry Endpoint of IRS DEV", + "dct:type": { + "@id": "https://w3id.org/catenax/taxonomy#DigitalTwinRegistry" + }, + "cx-common:version": "3.0", + "edc:description": "Digital Twin Registry Endpoint", "edc:id": f"{asset_prop_id_}", # DTR-EDC-instance-unique-ID "edc:type": "data.core.digitalTwinRegistry" }, @@ -79,12 +83,13 @@ def create_edc_registry_asset_payload(registry_url_, asset_prop_id_): def edc_context(): return { - "dct": "https://purl.org/dc/terms/", + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", "dcat": "https://www.w3.org/ns/dcat/", "odrl": "http://www.w3.org/ns/odrl/2/", - "dspace": "https://w3id.org/dspace/v0.8/" + "dspace": "https://w3id.org/dspace/v0.8/", + "cx-common": "https://w3id.org/catenax/ontology/common#" }