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 ad76aa4c15..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; @@ -59,7 +60,7 @@ public class EdcPolicyDefinitionService { 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 = "use"; + 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/EdcSubmodelClientTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientTest.java index 33a61964db..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 @@ -469,15 +469,18 @@ void shouldRetrieveEndpointReferenceForAsset2() throws Exception { } @Test - void shouldRetrieveEndpointReferenceForRegistryAssetForOldIdentifier() throws Exception { + void shouldRetrieveEndpointReferenceForRegistryAssetUsingFallbackOldIdentifier() throws Exception { // arrange - when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); - - final String agreementId = "agreementId"; + // 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()); @@ -497,11 +500,13 @@ void shouldRetrieveEndpointReferenceForRegistryAssetForOldIdentifier() throws Ex @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(catalogFacade.fetchCatalogByFilter(any(), eq(DCT_TYPE_ID), eq(TAXONOMY_DIGITAL_TWIN_REGISTRY), - any())).thenReturn(List.of(CatalogItem.builder().itemId("asset-id").build())); when(contractNegotiationService.negotiate(any(), any(), eq(new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW)), any())).thenReturn( NegotiationResponse.builder().contractAgreementId(agreementId).build()); 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 369624a740..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 @@ -67,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; @@ -141,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(); }