diff --git a/CHANGELOG.md b/CHANGELOG.md index de3b23884..b04aaaea8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,12 +24,6 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md). ### Deployment Migration Notes -New configuration to access the database: - -- `EDC_SERVER_DB_CONNECTION_POOL_SIZE` - - The property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections. Basically this value will determine the maximum number of actual connections to the database backend. - - Defaults to `3` - #### Compatible Versions - Connector Backend Docker Images: diff --git a/build.gradle.kts b/build.gradle.kts index f9ff62348..9ee6fa69e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -45,6 +45,10 @@ allprojects { apply(plugin = "java") apply(plugin = "checkstyle") + configurations.all { + resolutionStrategy.force("org.eclipse.edc:runtime-metamodel:0.2.1") + } + tasks.withType { options.encoding = "UTF-8" sourceCompatibility = JavaVersion.VERSION_17.toString() diff --git a/extensions/catalog-crawler/catalog-crawler-e2e-test/src/test/java/de/sovity/edc/ext/catalog/crawler/CrawlerE2eTest.java b/extensions/catalog-crawler/catalog-crawler-e2e-test/src/test/java/de/sovity/edc/ext/catalog/crawler/CrawlerE2eTest.java index 759f65cf4..1882f283a 100644 --- a/extensions/catalog-crawler/catalog-crawler-e2e-test/src/test/java/de/sovity/edc/ext/catalog/crawler/CrawlerE2eTest.java +++ b/extensions/catalog-crawler/catalog-crawler-e2e-test/src/test/java/de/sovity/edc/ext/catalog/crawler/CrawlerE2eTest.java @@ -106,6 +106,7 @@ class CrawlerE2eTest { props.put(CrawlerExtension.CRON_DEAD_CONNECTOR_REFRESH, everySeconds); props.put(CrawlerExtension.SCHEDULED_KILL_OFFLINE_CONNECTORS, everySeconds); props.put(CrawlerExtension.KILL_OFFLINE_CONNECTORS_AFTER, "P1D"); + props.put("my.edc.datasource.placeholder.baseurl", "http://example.com/edc/backend"); return props; } diff --git a/extensions/catalog-crawler/catalog-crawler/src/main/java/de/sovity/edc/ext/catalog/crawler/CrawlerExtension.java b/extensions/catalog-crawler/catalog-crawler/src/main/java/de/sovity/edc/ext/catalog/crawler/CrawlerExtension.java index 290c5c2c3..ae1f0eca4 100644 --- a/extensions/catalog-crawler/catalog-crawler/src/main/java/de/sovity/edc/ext/catalog/crawler/CrawlerExtension.java +++ b/extensions/catalog-crawler/catalog-crawler/src/main/java/de/sovity/edc/ext/catalog/crawler/CrawlerExtension.java @@ -14,6 +14,7 @@ package de.sovity.edc.ext.catalog.crawler; +import de.sovity.edc.ext.wrapper.api.common.mappers.PlaceholderEndpointService; import org.eclipse.edc.connector.api.management.configuration.transform.ManagementApiTypeTransformerRegistry; import org.eclipse.edc.connector.spi.catalog.CatalogService; import org.eclipse.edc.jsonld.spi.JsonLd; @@ -117,12 +118,13 @@ public void initialize(ServiceExtensionContext context) { } services = CrawlerExtensionContextBuilder.buildContext( - context.getConfig(), - context.getMonitor(), - typeManager, - typeTransformerRegistry, - jsonLd, - catalogService + context.getConfig(), + context.getMonitor(), + typeManager, + typeTransformerRegistry, + jsonLd, + catalogService, + new PlaceholderEndpointService("http://0.0.0.0/") ); // Provide access for the tests diff --git a/extensions/catalog-crawler/catalog-crawler/src/main/java/de/sovity/edc/ext/catalog/crawler/CrawlerExtensionContextBuilder.java b/extensions/catalog-crawler/catalog-crawler/src/main/java/de/sovity/edc/ext/catalog/crawler/CrawlerExtensionContextBuilder.java index f95463a9f..89aa9e491 100644 --- a/extensions/catalog-crawler/catalog-crawler/src/main/java/de/sovity/edc/ext/catalog/crawler/CrawlerExtensionContextBuilder.java +++ b/extensions/catalog-crawler/catalog-crawler/src/main/java/de/sovity/edc/ext/catalog/crawler/CrawlerExtensionContextBuilder.java @@ -52,6 +52,7 @@ import de.sovity.edc.ext.catalog.crawler.orchestration.schedules.QuartzScheduleInitializer; import de.sovity.edc.ext.catalog.crawler.orchestration.schedules.utils.CronJobRef; import de.sovity.edc.ext.wrapper.api.common.mappers.AssetMapper; +import de.sovity.edc.ext.wrapper.api.common.mappers.PlaceholderEndpointService; import de.sovity.edc.ext.wrapper.api.common.mappers.PolicyMapper; import de.sovity.edc.ext.wrapper.api.common.mappers.asset.AssetEditRequestMapper; import de.sovity.edc.ext.wrapper.api.common.mappers.asset.AssetJsonLdBuilder; @@ -101,7 +102,8 @@ public static CrawlerExtensionContext buildContext( TypeManager typeManager, TypeTransformerRegistry typeTransformerRegistry, JsonLd jsonLd, - CatalogService catalogService + CatalogService catalogService, + PlaceholderEndpointService placeholderEndpointService ) { // Config var crawlerConfigFactory = new CrawlerConfigFactory(config); @@ -120,7 +122,7 @@ public static CrawlerExtensionContext buildContext( // Services var objectMapperJsonLd = getJsonLdObjectMapper(typeManager); - var assetMapper = newAssetMapper(typeTransformerRegistry, jsonLd); + var assetMapper = newAssetMapper(typeTransformerRegistry, jsonLd, placeholderEndpointService); var policyMapper = newPolicyMapper(typeTransformerRegistry, objectMapperJsonLd); var crawlerEventLogger = new CrawlerEventLogger(); var crawlerExecutionTimeLogger = new CrawlerExecutionTimeLogger(); @@ -229,7 +231,8 @@ private static PolicyMapper newPolicyMapper( @NotNull private static AssetMapper newAssetMapper( TypeTransformerRegistry typeTransformerRegistry, - JsonLd jsonLd + JsonLd jsonLd, + PlaceholderEndpointService placeholderEndpointService ) { var edcPropertyUtils = new EdcPropertyUtils(); var assetJsonLdUtils = new AssetJsonLdUtils(); @@ -241,7 +244,7 @@ private static AssetMapper newAssetMapper( endpoint -> false ); var httpHeaderMapper = new HttpHeaderMapper(); - var httpDataSourceMapper = new HttpDataSourceMapper(httpHeaderMapper); + var httpDataSourceMapper = new HttpDataSourceMapper(httpHeaderMapper, placeholderEndpointService); var dataSourceMapper = new DataSourceMapper( edcPropertyUtils, httpDataSourceMapper diff --git a/extensions/contract-termination/build.gradle.kts b/extensions/contract-termination/build.gradle.kts index 61c1ad4ec..a220fc241 100644 --- a/extensions/contract-termination/build.gradle.kts +++ b/extensions/contract-termination/build.gradle.kts @@ -13,8 +13,8 @@ dependencies { implementation(project(":extensions:sovity-messenger")) implementation(libs.edc.coreSpi) - implementation(libs.edc.transferSpi) implementation(libs.edc.dspNegotiationTransform) + implementation(libs.edc.transferSpi) implementation(libs.jakarta.rsApi) diff --git a/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/TerminateContractQueryTest.java b/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/TerminateContractQueryTest.java index c4e5dc825..1308eaf1c 100644 --- a/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/TerminateContractQueryTest.java +++ b/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/TerminateContractQueryTest.java @@ -21,6 +21,7 @@ import de.sovity.edc.extension.e2e.extension.E2eScenario; import de.sovity.edc.extension.e2e.extension.E2eTestExtension; import de.sovity.edc.extension.e2e.extension.Provider; +import de.sovity.edc.extension.utils.junit.DisabledOnGithub; import lombok.val; import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation; import org.junit.jupiter.api.Test; @@ -34,6 +35,7 @@ @ExtendWith(E2eTestExtension.class) class TerminateContractQueryTest { + @DisabledOnGithub @Test void terminateConsumerAgreementOrThrow_shouldInsertRowInTerminationTable( E2eScenario scenario, diff --git a/extensions/policy-referring-connector/build.gradle.kts b/extensions/policy-referring-connector/build.gradle.kts index c7fa700f5..1df2e5ac9 100644 --- a/extensions/policy-referring-connector/build.gradle.kts +++ b/extensions/policy-referring-connector/build.gradle.kts @@ -8,6 +8,8 @@ dependencies { api(libs.edc.authSpi) api(libs.edc.policyEngineSpi) api(libs.edc.contractSpi) + + testImplementation(libs.edc.junit) testImplementation(libs.mockito.core) diff --git a/extensions/policy-time-interval/build.gradle.kts b/extensions/policy-time-interval/build.gradle.kts index 66b2183c3..a469643c7 100644 --- a/extensions/policy-time-interval/build.gradle.kts +++ b/extensions/policy-time-interval/build.gradle.kts @@ -7,6 +7,8 @@ plugins { dependencies { api(libs.edc.authSpi) api(libs.edc.policyEngineSpi) + + testImplementation(libs.edc.junit) } diff --git a/extensions/postgres-flyway/build.gradle.kts b/extensions/postgres-flyway/build.gradle.kts index 8b0b67dca..96b90d1b5 100644 --- a/extensions/postgres-flyway/build.gradle.kts +++ b/extensions/postgres-flyway/build.gradle.kts @@ -14,6 +14,7 @@ dependencies { // Adds Database-Related EDC-Extensions (EDC-SQL-Stores, JDBC-Driver, Pool and Transactions) implementation(libs.edc.controlPlaneSql) implementation(libs.edc.transactionLocal) + implementation(libs.tractus.sqlPool) implementation(libs.apache.commonsLang) diff --git a/extensions/sovity-messenger/build.gradle.kts b/extensions/sovity-messenger/build.gradle.kts index cd9c7655d..b47765a69 100644 --- a/extensions/sovity-messenger/build.gradle.kts +++ b/extensions/sovity-messenger/build.gradle.kts @@ -17,7 +17,6 @@ dependencies { implementation(libs.edc.managementApiConfiguration) implementation(libs.edc.transformCore) - testAnnotationProcessor(libs.lombok) testCompileOnly(libs.lombok) diff --git a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/ContractAgreementPageQuery.java b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/ContractAgreementPageQuery.java index f836e5399..d9ef4a47e 100644 --- a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/ContractAgreementPageQuery.java +++ b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/ContractAgreementPageQuery.java @@ -14,7 +14,6 @@ package de.sovity.edc.ext.wrapper.api.ui.model; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; diff --git a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/usecase/UseCaseResource.java b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/usecase/UseCaseResource.java index b959ac0ec..e02e50e9c 100644 --- a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/usecase/UseCaseResource.java +++ b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/usecase/UseCaseResource.java @@ -19,7 +19,6 @@ import de.sovity.edc.ext.wrapper.api.usecase.model.KpiResult; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.GET; diff --git a/extensions/wrapper/wrapper-common-mappers/build.gradle.kts b/extensions/wrapper/wrapper-common-mappers/build.gradle.kts index fe5a1bf79..909ba8dbe 100644 --- a/extensions/wrapper/wrapper-common-mappers/build.gradle.kts +++ b/extensions/wrapper/wrapper-common-mappers/build.gradle.kts @@ -12,11 +12,15 @@ dependencies { api(libs.edc.coreSpi) api(libs.edc.transformCore) api(libs.edc.transformSpi) + api(project(":extensions:wrapper:wrapper-common-api")) api(project(":utils:json-and-jsonld-utils")) + implementation(libs.apache.commonsLang) implementation(libs.apache.commonsCollections) implementation(libs.flexmark.all) + implementation(libs.okhttp.okhttp) + testAnnotationProcessor(libs.lombok) testCompileOnly(libs.lombok) diff --git a/extensions/wrapper/wrapper-common-mappers/src/main/java/de/sovity/edc/ext/wrapper/api/common/mappers/PlaceholderEndpointService.java b/extensions/wrapper/wrapper-common-mappers/src/main/java/de/sovity/edc/ext/wrapper/api/common/mappers/PlaceholderEndpointService.java new file mode 100644 index 000000000..d3c1c955a --- /dev/null +++ b/extensions/wrapper/wrapper-common-mappers/src/main/java/de/sovity/edc/ext/wrapper/api/common/mappers/PlaceholderEndpointService.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 sovity GmbH + * + * 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 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * sovity GmbH - initial API and implementation + * + */ + +package de.sovity.edc.ext.wrapper.api.common.mappers; + +import lombok.RequiredArgsConstructor; +import okhttp3.HttpUrl; + +@RequiredArgsConstructor +public class PlaceholderEndpointService { + + private final String baseUrl; + + public static final String DUMMY_ENDPOINT_URL = "/data-source/placeholder/asset"; + + public String getPlaceholderEndpointForAsset(String email, String subject) { + return HttpUrl.parse(baseUrl + DUMMY_ENDPOINT_URL) + .newBuilder() + .addQueryParameter("email", email) + .addQueryParameter("subject", subject) + .build() + .toString(); + } +} diff --git a/extensions/wrapper/wrapper-common-mappers/src/main/java/de/sovity/edc/ext/wrapper/api/common/mappers/dataaddress/http/HttpDataSourceMapper.java b/extensions/wrapper/wrapper-common-mappers/src/main/java/de/sovity/edc/ext/wrapper/api/common/mappers/dataaddress/http/HttpDataSourceMapper.java index 32812934d..1c8b3a4bf 100644 --- a/extensions/wrapper/wrapper-common-mappers/src/main/java/de/sovity/edc/ext/wrapper/api/common/mappers/dataaddress/http/HttpDataSourceMapper.java +++ b/extensions/wrapper/wrapper-common-mappers/src/main/java/de/sovity/edc/ext/wrapper/api/common/mappers/dataaddress/http/HttpDataSourceMapper.java @@ -14,6 +14,7 @@ package de.sovity.edc.ext.wrapper.api.common.mappers.dataaddress.http; +import de.sovity.edc.ext.wrapper.api.common.mappers.PlaceholderEndpointService; import de.sovity.edc.ext.wrapper.api.common.model.UiDataSourceHttpData; import de.sovity.edc.ext.wrapper.api.common.model.UiDataSourceOnRequest; import de.sovity.edc.utils.jsonld.vocab.Prop; @@ -33,6 +34,7 @@ @RequiredArgsConstructor public class HttpDataSourceMapper { private final HttpHeaderMapper httpHeaderMapper; + private final PlaceholderEndpointService placeholderEndpointService; /** * Data Address for type HTTP_DATA @@ -92,8 +94,12 @@ public Map buildOnRequestDataAddress(@NonNull UiDataSourceOnRequ "Need contactPreferredEmailSubject" ); + var placeholderEndpointForAsset = placeholderEndpointService.getPlaceholderEndpointForAsset( + onRequest.getContactEmail(), + onRequest.getContactPreferredEmailSubject()); + var actualDataSource = UiDataSourceHttpData.builder() - .baseUrl("http://0.0.0.0") + .baseUrl(placeholderEndpointForAsset) .build(); var props = buildDataAddress(actualDataSource); diff --git a/extensions/wrapper/wrapper-common-mappers/src/test/java/de/sovity/edc/ext/wrapper/api/common/mappers/Factory.java b/extensions/wrapper/wrapper-common-mappers/src/test/java/de/sovity/edc/ext/wrapper/api/common/mappers/Factory.java index 4c9d7093b..5d03c1a8e 100644 --- a/extensions/wrapper/wrapper-common-mappers/src/test/java/de/sovity/edc/ext/wrapper/api/common/mappers/Factory.java +++ b/extensions/wrapper/wrapper-common-mappers/src/test/java/de/sovity/edc/ext/wrapper/api/common/mappers/Factory.java @@ -50,7 +50,7 @@ public static AssetJsonLdBuilder newAssetJsonLdBuilder(OwnConnectorEndpointServi return new AssetJsonLdBuilder( new DataSourceMapper( new EdcPropertyUtils(), - new HttpDataSourceMapper(new HttpHeaderMapper()) + new HttpDataSourceMapper(new HttpHeaderMapper(), new PlaceholderEndpointService("http://example.com/dummy/baseUrl")) ), newAssetJsonLdParser(ownConnectorEndpointService), new AssetEditRequestMapper() diff --git a/extensions/wrapper/wrapper-common-mappers/src/test/java/de/sovity/edc/ext/wrapper/api/common/mappers/asset/AssetJsonLdBuilderTest.java b/extensions/wrapper/wrapper-common-mappers/src/test/java/de/sovity/edc/ext/wrapper/api/common/mappers/asset/AssetJsonLdBuilderTest.java index ea0b8658e..060c29d03 100644 --- a/extensions/wrapper/wrapper-common-mappers/src/test/java/de/sovity/edc/ext/wrapper/api/common/mappers/asset/AssetJsonLdBuilderTest.java +++ b/extensions/wrapper/wrapper-common-mappers/src/test/java/de/sovity/edc/ext/wrapper/api/common/mappers/asset/AssetJsonLdBuilderTest.java @@ -534,7 +534,7 @@ void test_create_onRequest() { var dataAddress = Json.createObjectBuilder() .add(Prop.TYPE, Prop.Edc.TYPE_DATA_ADDRESS) .add(Prop.Edc.TYPE, Prop.Edc.DATA_ADDRESS_TYPE_HTTP_DATA) - .add(Prop.Edc.BASE_URL, "http://0.0.0.0") + .add(Prop.Edc.BASE_URL, "http://example.com/dummy/baseUrl/data-source/placeholder/asset?email=contact%40example.com&subject=Test") .add(Prop.SovityDcatExt.DATA_SOURCE_AVAILABILITY, Prop.SovityDcatExt.DATA_SOURCE_AVAILABILITY_ON_REQUEST) .add(Prop.SovityDcatExt.CONTACT_EMAIL, "contact@example.com") .add(Prop.SovityDcatExt.CONTACT_PREFERRED_EMAIL_SUBJECT, "Test"); diff --git a/extensions/wrapper/wrapper/build.gradle.kts b/extensions/wrapper/wrapper/build.gradle.kts index 2a080c73b..027f3c567 100644 --- a/extensions/wrapper/wrapper/build.gradle.kts +++ b/extensions/wrapper/wrapper/build.gradle.kts @@ -27,6 +27,7 @@ dependencies { implementation(libs.apache.commonsLang) implementation(libs.edc.apiCore) implementation(libs.edc.managementApiConfiguration) + implementation(libs.edc.dspApiConfiguration) implementation(libs.edc.dspHttpSpi) implementation(libs.jooq.jooq) implementation(libs.hibernate.validation) diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtension.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtension.java index 8f2b29210..3c0f81079 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtension.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtension.java @@ -19,7 +19,6 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import de.sovity.edc.extension.contacttermination.ContractAgreementTerminationService; import de.sovity.edc.extension.db.directaccess.DslContextFactory; -import de.sovity.edc.extension.messenger.SovityMessenger; import org.eclipse.edc.connector.api.management.configuration.ManagementApiConfiguration; import org.eclipse.edc.connector.api.management.configuration.transform.ManagementApiTypeTransformerRegistry; import org.eclipse.edc.connector.contract.spi.negotiation.store.ContractNegotiationStore; @@ -35,7 +34,9 @@ import org.eclipse.edc.connector.transfer.spi.store.TransferProcessStore; import org.eclipse.edc.jsonld.spi.JsonLd; import org.eclipse.edc.policy.engine.spi.PolicyEngine; +import org.eclipse.edc.protocol.dsp.api.configuration.DspApiConfiguration; import org.eclipse.edc.runtime.metamodel.annotation.Inject; +import org.eclipse.edc.runtime.metamodel.annotation.Setting; import org.eclipse.edc.spi.CoreConstants; import org.eclipse.edc.spi.asset.AssetIndex; import org.eclipse.edc.spi.system.ServiceExtension; @@ -45,6 +46,8 @@ public class WrapperExtension implements ServiceExtension { + @Setting(value = "Base URL for the On Request asset datasource, as reachable by the data plane") + public static final String MY_EDC_DATASOURCE_PLACEHOLDER_BASEURL = "my.edc.datasource.placeholder.baseurl"; public static final String EXTENSION_NAME = "WrapperExtension"; @@ -67,14 +70,14 @@ public class WrapperExtension implements ServiceExtension { @Inject private DslContextFactory dslContextFactory; @Inject + private DspApiConfiguration dspApiConfiguration; + @Inject private ManagementApiConfiguration dataManagementApiConfiguration; @Inject private PolicyDefinitionStore policyDefinitionStore; @Inject private PolicyEngine policyEngine; @Inject - private SovityMessenger sovityMessenger; - @Inject private TransferProcessService transferProcessService; @Inject private TransferProcessStore transferProcessStore; @@ -119,7 +122,6 @@ public void initialize(ServiceExtensionContext context) { policyDefinitionService, policyDefinitionStore, policyEngine, - sovityMessenger, transferProcessService, transferProcessStore, typeTransformerRegistry @@ -127,8 +129,11 @@ public void initialize(ServiceExtensionContext context) { wrapperExtensionContext.selfDescriptionService().validateSelfDescriptionConfig(); - wrapperExtensionContext.jaxRsResources().forEach(resource -> + wrapperExtensionContext.managementApiResources().forEach(resource -> webService.registerResource(dataManagementApiConfiguration.getContextAlias(), resource)); + + wrapperExtensionContext.dspApiResources().forEach(resource -> + webService.registerResource(dspApiConfiguration.getContextAlias(), resource)); } private void fixObjectMapperDateSerialization(ObjectMapper objectMapper) { diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContext.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContext.java index 7280df3b0..cc135b3bf 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContext.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContext.java @@ -22,13 +22,15 @@ /** * Manual Dependency Injection result * - * @param jaxRsResources Jax RS Resource implementations to register. Implementations of + * @param managementApiResources Jax RS Resource implementations to register. Implementations of * APIs supported by our EDC API Client that don't have their own * extension should land here. + * @param dspApiResources Jax RS Resource implementations to register. Rare DSP API * @param selfDescriptionService Required here for validation on start-up */ public record WrapperExtensionContext( - List jaxRsResources, + List managementApiResources, + List dspApiResources, SelfDescriptionService selfDescriptionService ) { } diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java index d554dd74f..48574717f 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import de.sovity.edc.ext.wrapper.api.common.mappers.AssetMapper; import de.sovity.edc.ext.wrapper.api.common.mappers.LegacyPolicyMapper; +import de.sovity.edc.ext.wrapper.api.common.mappers.PlaceholderEndpointService; import de.sovity.edc.ext.wrapper.api.common.mappers.PolicyMapper; import de.sovity.edc.ext.wrapper.api.common.mappers.asset.AssetEditRequestMapper; import de.sovity.edc.ext.wrapper.api.common.mappers.asset.AssetJsonLdBuilder; @@ -75,14 +76,13 @@ import de.sovity.edc.ext.wrapper.api.usecase.pages.catalog.UseCaseCatalogApiService; import de.sovity.edc.ext.wrapper.api.usecase.services.KpiApiService; import de.sovity.edc.ext.wrapper.api.usecase.services.SupportedPolicyApiService; +import de.sovity.edc.ext.wrapper.controller.PlaceholderEndpointController; import de.sovity.edc.extension.contacttermination.ContractAgreementTerminationService; -import de.sovity.edc.extension.contacttermination.query.ContractAgreementTerminationDetailsQuery; -import de.sovity.edc.extension.contacttermination.query.TerminateContractQuery; import de.sovity.edc.extension.db.directaccess.DslContextFactory; -import de.sovity.edc.extension.messenger.SovityMessenger; import de.sovity.edc.utils.catalog.DspCatalogService; import de.sovity.edc.utils.catalog.mapper.DspDataOfferBuilder; import lombok.NoArgsConstructor; +import lombok.val; import org.eclipse.edc.connector.contract.spi.negotiation.store.ContractNegotiationStore; import org.eclipse.edc.connector.contract.spi.offer.store.ContractDefinitionStore; import org.eclipse.edc.connector.policy.spi.store.PolicyDefinitionStore; @@ -135,7 +135,6 @@ public static WrapperExtensionContext buildContext( PolicyDefinitionService policyDefinitionService, PolicyDefinitionStore policyDefinitionStore, PolicyEngine policyEngine, - SovityMessenger sovityMessenger, TransferProcessService transferProcessService, TransferProcessStore transferProcessStore, TypeTransformerRegistry typeTransformerRegistry @@ -148,7 +147,10 @@ public static WrapperExtensionContext buildContext( var edcPropertyUtils = new EdcPropertyUtils(); var selfDescriptionService = new SelfDescriptionService(config, monitor); var ownConnectorEndpointService = new OwnConnectorEndpointServiceImpl(selfDescriptionService); - var assetMapper = newAssetMapper(typeTransformerRegistry, jsonLd, ownConnectorEndpointService); + var placeholderEndpointService = new PlaceholderEndpointService( + config.getString(WrapperExtension.MY_EDC_DATASOURCE_PLACEHOLDER_BASEURL, "http://0.0.0.0") + ); + var assetMapper = newAssetMapper(typeTransformerRegistry, jsonLd, ownConnectorEndpointService, placeholderEndpointService); var policyMapper = newPolicyMapper(objectMapper, typeTransformerRegistry, operatorMapper); var transferProcessStateService = new TransferProcessStateService(); var contractNegotiationUtils = new ContractNegotiationUtils( @@ -210,8 +212,6 @@ public static WrapperExtensionContext buildContext( transferRequestBuilder, transferProcessService ); - var agreementDetailsQuery = new ContractAgreementTerminationDetailsQuery(); - var terminateContractQuery = new TerminateContractQuery(); var contractAgreementTerminationApiService = new ContractAgreementTerminationApiService(contractAgreementTerminationService); var legacyPolicyMapper = new LegacyPolicyMapper(); var policyDefinitionApiService = new PolicyDefinitionApiService( @@ -294,19 +294,22 @@ public static WrapperExtensionContext buildContext( supportedPolicyApiService, useCaseCatalogApiService ); + val placeholderEndpointController = new PlaceholderEndpointController(); // Collect all JAX-RS resources - return new WrapperExtensionContext(List.of( - uiResource, - useCaseResource - ), selfDescriptionService); + return new WrapperExtensionContext( + List.of(uiResource, useCaseResource), + List.of(placeholderEndpointController), + selfDescriptionService + ); } @NotNull private static AssetMapper newAssetMapper( TypeTransformerRegistry typeTransformerRegistry, JsonLd jsonLd, - OwnConnectorEndpointService ownConnectorEndpointService + OwnConnectorEndpointService ownConnectorEndpointService, + PlaceholderEndpointService placeholderEndpointService ) { var edcPropertyUtils = new EdcPropertyUtils(); var assetJsonLdUtils = new AssetJsonLdUtils(); @@ -318,7 +321,7 @@ private static AssetMapper newAssetMapper( ownConnectorEndpointService ); var httpHeaderMapper = new HttpHeaderMapper(); - var httpDataSourceMapper = new HttpDataSourceMapper(httpHeaderMapper); + var httpDataSourceMapper = new HttpDataSourceMapper(httpHeaderMapper, placeholderEndpointService); var dataSourceMapper = new DataSourceMapper( edcPropertyUtils, httpDataSourceMapper diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_agreements/services/ContractAgreementData.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_agreements/services/ContractAgreementData.java index 6e3411762..47801afaf 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_agreements/services/ContractAgreementData.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_agreements/services/ContractAgreementData.java @@ -21,7 +21,6 @@ import org.eclipse.edc.spi.types.domain.asset.Asset; import java.util.List; -import java.util.Map; /** diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_agreements/services/ContractAgreementPageCardBuilder.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_agreements/services/ContractAgreementPageCardBuilder.java index 7e35f1a3d..87ba240d3 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_agreements/services/ContractAgreementPageCardBuilder.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_agreements/services/ContractAgreementPageCardBuilder.java @@ -23,7 +23,6 @@ import de.sovity.edc.ext.wrapper.api.ui.model.ContractAgreementTransferProcess; import de.sovity.edc.ext.wrapper.api.ui.model.ContractTerminatedBy; import de.sovity.edc.ext.wrapper.api.ui.pages.transferhistory.TransferProcessStateService; -import jakarta.validation.constraints.Null; import lombok.NonNull; import lombok.RequiredArgsConstructor; import org.eclipse.edc.connector.contract.spi.types.agreement.ContractAgreement; @@ -34,7 +33,6 @@ import java.util.Comparator; import java.util.List; -import java.util.Map; import static de.sovity.edc.ext.wrapper.api.ui.model.ContractTerminationStatus.ONGOING; import static de.sovity.edc.ext.wrapper.api.ui.model.ContractTerminationStatus.TERMINATED; diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/controller/PlaceholderEndpointController.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/controller/PlaceholderEndpointController.java new file mode 100644 index 000000000..a399afa39 --- /dev/null +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/controller/PlaceholderEndpointController.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 sovity GmbH + * + * 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 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * sovity GmbH - initial API and implementation + * + */ + +package de.sovity.edc.ext.wrapper.controller; + +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Produces({MediaType.APPLICATION_JSON}) +@Path("/data-source/placeholder") +public class PlaceholderEndpointController { + + @GET + @Path("/{path:.*}") + @Produces(MediaType.TEXT_PLAIN) + @Consumes("*/*") + public Response get(@QueryParam("email") String email, @QueryParam("subject") String subject) { + return Response.ok(""" + This is not real data. + + This asset is accessible on request. + + The offer you are trying to use only has this placeholder as a dummy endpoint and requires you to take extra steps to access it. + + Please contact the data provider for more information about how to access it. + """ + "\n\n" + "Email: " + email + "\n" + "Subject: " + subject + "\n" + ).build(); + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f32a5d574..748f8b6ec 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -117,6 +117,7 @@ edc-policyDefinitionApi = { module = "org.eclipse.edc:policy-definition-api", ve edc-policyEngineSpi = { module = "org.eclipse.edc:policy-engine-spi", version.ref = "edc" } edc-policyModel = { module = "org.eclipse.edc:policy-model", version.ref = "edc" } edc-policySpi = { module = "org.eclipse.edc:policy-spi", version.ref = "edc" } +edc-runtimeMetamodel = { module = "org.eclipse.edc:runtime-metamodel", version = "0.2.1" } edc-sqlCore = { module = "org.eclipse.edc:sql-core", version.ref = "edc" } edc-transactionLocal = { module = "org.eclipse.edc:transaction-local", version.ref = "edc" } edc-transferDataPlane = { module = "org.eclipse.edc:transfer-data-plane", version.ref = "edc" } diff --git a/launchers/.env.connector b/launchers/.env.connector index d58c1267a..5b2eb4284 100644 --- a/launchers/.env.connector +++ b/launchers/.env.connector @@ -51,6 +51,7 @@ EDC_DSP_CALLBACK_ADDRESS=${MY_EDC_PROTOCOL}${MY_EDC_FQDN}${WEB_HTTP_PROTOCOL_PAT EDC_UI_MANAGEMENT_API_URL_SHOWN_IN_DASHBOARD=${MY_EDC_PROTOCOL}${MY_EDC_FQDN}${WEB_HTTP_MANAGEMENT_PATH} # Flyway Extension: Defaults +EDC_SERVER_DB_CONNECTION_POOL_SIZE=10 EDC_DATASOURCE_DEFAULT_NAME=default EDC_DATASOURCE_DEFAULT_URL=$MY_EDC_JDBC_URL EDC_DATASOURCE_DEFAULT_USER=$MY_EDC_JDBC_USER @@ -95,3 +96,6 @@ EDC_AGENT_IDENTITY_KEY=referringConnector # but for some reason it is required, and EDC won't start up if it isn't configured # it is created in the Dockerfile EDC_VAULT=/app/empty-properties-file.properties + +# Base URL for the On Request asset datasource, as reachable by the data plane +MY_EDC_DATASOURCE_PLACEHOLDER_BASEURL=${EDC_DSP_CALLBACK_ADDRESS} diff --git a/tests/build.gradle.kts b/tests/build.gradle.kts index 8b232a5f1..e5e0d221b 100644 --- a/tests/build.gradle.kts +++ b/tests/build.gradle.kts @@ -19,6 +19,7 @@ dependencies { testImplementation(libs.junit.api) testImplementation(libs.junit.params) testImplementation(libs.mockserver.netty) + testImplementation(libs.okhttp.okhttp) testImplementation(libs.restAssured.restAssured) testRuntimeOnly(libs.junit.engine) } diff --git a/tests/src/test/java/de/sovity/edc/e2e/ContractTerminationTest.java b/tests/src/test/java/de/sovity/edc/e2e/ContractTerminationTest.java index a20f44b0c..7b39169a7 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/ContractTerminationTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/ContractTerminationTest.java @@ -137,6 +137,7 @@ void canGetAgreementPageForTerminatedContract( assertTermination(agreementsAfterTermination, details, reason, SELF); } + @DisabledOnGithub @Test @SneakyThrows void canTerminateFromConsumer( @@ -253,6 +254,7 @@ void limitTheDetailSizeAt1000Chars( // termination completed == success } + @DisabledOnGithub @TestFactory List theDetailsAreMandatory( E2eScenario scenario, @@ -291,6 +293,7 @@ List theDetailsAreMandatory( })).toList(); } + @DisabledOnGithub @Test @SneakyThrows void canTerminateFromProvider( diff --git a/tests/src/test/java/de/sovity/edc/e2e/PlaceholderDataSourceExtensionTest.java b/tests/src/test/java/de/sovity/edc/e2e/PlaceholderDataSourceExtensionTest.java new file mode 100644 index 000000000..5e6fb8b7f --- /dev/null +++ b/tests/src/test/java/de/sovity/edc/e2e/PlaceholderDataSourceExtensionTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024 sovity GmbH + * + * 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 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * sovity GmbH - initial API and implementation + * + */ + +package de.sovity.edc.e2e; + +import de.sovity.edc.client.EdcClient; +import de.sovity.edc.client.gen.model.DataSourceType; +import de.sovity.edc.client.gen.model.InitiateTransferRequest; +import de.sovity.edc.client.gen.model.UiAssetCreateRequest; +import de.sovity.edc.client.gen.model.UiDataSource; +import de.sovity.edc.client.gen.model.UiDataSourceOnRequest; +import de.sovity.edc.extension.e2e.extension.E2eScenario; +import de.sovity.edc.extension.e2e.extension.E2eTestExtension; +import de.sovity.edc.extension.e2e.extension.Provider; +import jakarta.ws.rs.HttpMethod; +import lombok.SneakyThrows; +import lombok.val; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockserver.integration.ClientAndServer; +import org.mockserver.model.HttpRequest; +import org.mockserver.model.HttpResponse; +import org.mockserver.model.HttpStatusCode; + +import java.util.Base64; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE; + +@ExtendWith(E2eTestExtension.class) +class PlaceholderDataSourceExtensionTest { + + @SneakyThrows + @Test + void shouldAccessDummyEndpoint( + E2eScenario scenario, + ClientAndServer clientAndServer, + @Provider EdcClient providerClient + ) { + // arrange + + val assetId = "asset-1"; + val email = "contact@example.com"; + val subject = "Data request"; + providerClient.uiApi().createAsset( + UiAssetCreateRequest.builder() + .dataSource(UiDataSource.builder() + .type(DataSourceType.ON_REQUEST) + .onRequest(UiDataSourceOnRequest.builder() + .contactEmail(email) + .contactPreferredEmailSubject(subject) + .build()) + .build()) + .id(assetId) + .build() + ); + + scenario.createContractDefinition(assetId); + val negotiation = scenario.negotiateAssetAndAwait(assetId); + + val accessed = new AtomicReference<>("Not accessed."); + val destinationPath = "/foo/bar"; + val destinationUrl = "http://localhost:" + clientAndServer.getPort() + destinationPath; + + clientAndServer.when(HttpRequest.request().withMethod(HttpMethod.POST)) + .respond((it) -> { + accessed.set(it.getBodyAsString()); + return HttpResponse.response().withStatusCode(HttpStatusCode.OK_200.code()); + }); + + scenario.transferAndAwait(InitiateTransferRequest.builder() + .contractAgreementId(negotiation.getContractAgreementId()) + .dataSinkProperties(Map.of( + EDC_NAMESPACE + "baseUrl", destinationUrl, + EDC_NAMESPACE + "method", HttpMethod.POST, + EDC_NAMESPACE + "type", "HttpData" + )) + .build()); + + // assert + assertThat(new String(Base64.getDecoder().decode(accessed.get()))) + .contains("This is not real data.") + .contains(email) + .contains(subject); + } +} diff --git a/utils/catalog-parser/build.gradle.kts b/utils/catalog-parser/build.gradle.kts index dee5ebaf0..f5d8fc433 100644 --- a/utils/catalog-parser/build.gradle.kts +++ b/utils/catalog-parser/build.gradle.kts @@ -19,6 +19,7 @@ dependencies { implementation(libs.apache.commonsCollections) implementation(libs.apache.commonsIo) + testAnnotationProcessor(libs.lombok) testCompileOnly(libs.lombok) testImplementation(project(":utils:test-utils")) diff --git a/utils/test-utils/build.gradle.kts b/utils/test-utils/build.gradle.kts index e2d6e9038..b6b1eab88 100644 --- a/utils/test-utils/build.gradle.kts +++ b/utils/test-utils/build.gradle.kts @@ -12,6 +12,7 @@ dependencies { api(libs.edc.junit) api(libs.awaitility.java) + api(libs.postgres) api(project(":extensions:wrapper:clients:java-client")) api(project(":utils:json-and-jsonld-utils")) diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfigFactory.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfigFactory.java index 4608b9396..b2fab5ea9 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfigFactory.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfigFactory.java @@ -85,8 +85,6 @@ public static ConnectorConfig basicEdcConfig(String participantId, int firstPort properties.put("edc.last.commit.info", "test env commit message"); properties.put("edc.build.date", "2023-05-08T15:30:00Z"); - properties.put("edc.server.db.connection.timeout.in.ms", "5000"); - properties.put("my.edc.participant.id", participantId); properties.put("my.edc.title", "Connector Title %s".formatted(participantId)); properties.put("my.edc.description", "Connector Description %s".formatted(participantId)); @@ -95,7 +93,7 @@ public static ConnectorConfig basicEdcConfig(String participantId, int firstPort properties.put("my.edc.maintainer.url", "http://maintainer.%s".formatted(participantId)); properties.put("my.edc.maintainer.name", "Maintainer Name %s".formatted(participantId)); - properties.put("edc.server.db.connection.pool.size", "3"); + properties.put("my.edc.datasource.placeholder.baseurl", apiConfig.getProtocolApiGroup().getUri().toString()); properties.put("web.http.port", String.valueOf(apiConfig.getDefaultApiGroup().port())); properties.put("web.http.path", String.valueOf(apiConfig.getDefaultApiGroup().path())); diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionWithTestDatabase.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionWithTestDatabase.java index 868c3d89d..eab4e8eea 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionWithTestDatabase.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionWithTestDatabase.java @@ -4,6 +4,7 @@ import lombok.RequiredArgsConstructor; import lombok.experimental.Delegate; import lombok.val; +import org.eclipse.edc.junit.extensions.EdcExtension; import org.jooq.DSLContext; import org.jooq.impl.DSL; import org.junit.jupiter.api.extension.AfterAllCallback; @@ -47,16 +48,28 @@ public void beforeAll(ExtensionContext extensionContext) throws Exception { @Override public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { - boolean isJooqDsl = parameterContext.getParameter().getType().equals(DSLContext.class); - return isJooqDsl || edcRuntimeExtension.supportsParameter(parameterContext, extensionContext); + + val type = parameterContext.getParameter().getType(); + + if (DSLContext.class.equals(type)) { + return true; + } else if (EdcExtension.class.equals(type)) { + return true; + } + + return edcRuntimeExtension.supportsParameter(parameterContext, extensionContext); } @Override public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { - boolean isJooqDsl = parameterContext.getParameter().getType().equals(DSLContext.class); - if (isJooqDsl) { + + val type = parameterContext.getParameter().getType(); + + if (DSLContext.class.equals(type)) { return getDslContext().dsl(); + } else if (EdcExtension.class.equals(type)) { + return edcRuntimeExtension; } else { return edcRuntimeExtension.resolveParameter(parameterContext, extensionContext); } diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eScenario.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eScenario.java index 346e256e6..a8560544e 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eScenario.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eScenario.java @@ -43,13 +43,13 @@ import lombok.val; import org.awaitility.Awaitility; import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation; +import org.jetbrains.annotations.NotNull; import org.mockserver.integration.ClientAndServer; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; import java.time.Duration; import java.time.OffsetDateTime; -import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; @@ -96,7 +96,11 @@ public String createAsset() { .build()) .build(); - return internalCreateAsset("asset-" + assetCounter.getAndIncrement(), dummyDataSource).getId(); + return internalCreateAsset(nextAssetId(), dummyDataSource).getId(); + } + + private @NotNull String nextAssetId() { + return "asset-" + assetCounter.getAndIncrement(); } public String createAsset(String id, UiDataSourceHttpData uiDataSourceHttpData) { @@ -108,6 +112,10 @@ public String createAsset(String id, UiDataSourceHttpData uiDataSourceHttpData) return internalCreateAsset(id, uiDataSource).getId(); } + public String createAsset(String id, UiDataSource uiDataSource) { + return internalCreateAsset(id, uiDataSource).getId(); + } + public MockedAsset createAssetWithMockResource(String id) { val path = "/assets/" + id; @@ -141,31 +149,8 @@ private IdResponseDto internalCreateAsset(String assetId, UiDataSource dataSourc .build()); } - public String createPolicyDefinition(String policyId, UiPolicyConstraint... constraints) { - return createPolicyDefinition(policyId, Arrays.stream(constraints).toList()).getId(); - } - - private IdResponseDto createPolicyDefinition(String policyId, List constraints) { - var expression = UiPolicyExpression.builder() - .type(UiPolicyExpressionType.AND) - .expressions(constraints.stream() - .map(it -> UiPolicyExpression.builder() - .type(UiPolicyExpressionType.CONSTRAINT) - .constraint(it) - .build()) - .toList()) - .build(); - - var policyDefinition = PolicyDefinitionCreateDto.builder() - .policyDefinitionId(policyId) - .expression(expression) - .build(); - - return providerClient.uiApi().createPolicyDefinitionV2(policyDefinition); - } - public String createContractDefinition(String assetId) { - return createContractDefinition(POLICY_DEFINITION_ID, assetId).getId(); + return createContractDefinition(alwaysTruePolicyId, assetId).getId(); } public IdResponseDto createContractDefinition(String policyId, String assetId) { diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java index ddbd592ae..95f45ec4b 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java @@ -50,7 +50,8 @@ public class E2eTestExtension private ConnectorConfig providerConfig; private final EdcRuntimeExtensionWithTestDatabase providerExtension; - private final List> partySupportedTypes = List.of(ConnectorConfig.class, EdcClient.class, ConnectorRemote.class, ClientAndServer.class); + private final List> partySupportedTypes = + List.of(ConnectorConfig.class, EdcClient.class, ConnectorRemote.class, ClientAndServer.class); private final List> supportedTypes = Stream.concat(partySupportedTypes.stream(), Stream.of(E2eScenario.class)).toList(); private Lazy clientAndServer; diff --git a/utils/versions/build.gradle.kts b/utils/versions/build.gradle.kts index 2d27f8408..6d9aca986 100644 --- a/utils/versions/build.gradle.kts +++ b/utils/versions/build.gradle.kts @@ -5,8 +5,6 @@ import com.squareup.javapoet.TypeSpec import javax.lang.model.element.Modifier.FINAL import javax.lang.model.element.Modifier.PUBLIC import javax.lang.model.element.Modifier.STATIC -import java.lang.String as JavaString - plugins { `java-library` @@ -26,7 +24,7 @@ val generateGradleVersions by tasks.creating { val versionsClass = TypeSpec.classBuilder("GradleVersions") .addModifiers(PUBLIC, FINAL) .addField( - FieldSpec.builder(TypeName.get(JavaString::class.java), "POSTGRES_IMAGE_TAG") + FieldSpec.builder(TypeName.get(String::class.java), "POSTGRES_IMAGE_TAG") .initializer("\$S", libs.versions.postgresDbImage.get()) .addModifiers(PUBLIC, STATIC, FINAL) .build()