diff --git a/extensions/dataset-bugfix/src/main/java/org/eclipse/tractusx/edc/dataset/fix/DatasetFixExtension.java b/extensions/dataset-bugfix/src/main/java/org/eclipse/tractusx/edc/dataset/fix/DatasetFixExtension.java index 2f3263c98..fc2da6d26 100644 --- a/extensions/dataset-bugfix/src/main/java/org/eclipse/tractusx/edc/dataset/fix/DatasetFixExtension.java +++ b/extensions/dataset-bugfix/src/main/java/org/eclipse/tractusx/edc/dataset/fix/DatasetFixExtension.java @@ -24,11 +24,11 @@ import jakarta.ws.rs.container.ContainerRequestContext; import jakarta.ws.rs.container.ContainerResponseContext; import jakarta.ws.rs.container.ContainerResponseFilter; -import org.eclipse.edc.protocol.dsp.api.configuration.DspApiConfiguration; import org.eclipse.edc.runtime.metamodel.annotation.Inject; import org.eclipse.edc.spi.system.ServiceExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; import org.eclipse.edc.web.spi.WebService; +import org.eclipse.edc.web.spi.configuration.ApiContext; import static jakarta.ws.rs.HttpMethod.GET; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; @@ -37,16 +37,12 @@ public class DatasetFixExtension implements ServiceExtension { - - @Inject - private DspApiConfiguration apiConfiguration; - @Inject private WebService webService; @Override public void initialize(ServiceExtensionContext context) { - webService.registerResource(apiConfiguration.getContextAlias(), new DatasetFilter()); + webService.registerResource(ApiContext.PROTOCOL, new DatasetFilter()); } private static class DatasetFilter implements ContainerResponseFilter { diff --git a/tests/src/test/java/de/sovity/edc/e2e/DatasetTest.java b/tests/src/test/java/de/sovity/edc/e2e/DatasetTest.java index 7849715eb..0dd884051 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/DatasetTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/DatasetTest.java @@ -14,80 +14,82 @@ package de.sovity.edc.e2e; -import de.sovity.edc.extension.e2e.connector.ConnectorRemote; -import de.sovity.edc.extension.e2e.connector.config.ConnectorConfig; -import de.sovity.edc.extension.e2e.extension.Consumer; -import de.sovity.edc.extension.e2e.extension.E2eTestExtension; -import de.sovity.edc.extension.e2e.extension.Provider; +import de.sovity.edc.extension.e2e.connector.remotes.management_api.ManagementApiConnectorRemote; +import de.sovity.edc.extension.e2e.junit.CeE2eTestExtension; +import de.sovity.edc.extension.e2e.junit.utils.Consumer; +import de.sovity.edc.extension.e2e.junit.utils.Provider; import io.restassured.response.Response; +import org.eclipse.edc.spi.system.configuration.Config; +import org.eclipse.edc.web.spi.configuration.ApiContext; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import java.util.Map; import java.util.UUID; -import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension; import static io.restassured.http.ContentType.JSON; import static jakarta.json.Json.createObjectBuilder; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; -import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE; -import static org.eclipse.edc.spi.CoreConstants.EDC_PREFIX; +import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; +import static org.eclipse.edc.spi.constants.CoreConstants.EDC_PREFIX; import static org.hamcrest.Matchers.equalTo; class DatasetTest { @RegisterExtension - private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension(); + private static CeE2eTestExtension e2eTestExtension = CeE2eTestExtension.builder() + .additionalModule(":launchers:utils:vanilla-control-plane") + .build(); @Test void canRetrieveOfferedDataset( - @Consumer ConnectorRemote consumerConnector, - @Provider ConnectorConfig providerConfig, - @Provider ConnectorRemote providerConnector) { + @Consumer ManagementApiConnectorRemote consumerConnector, + @Provider Config providerConfig, + @Provider ManagementApiConnectorRemote providerConnector) { // arrange var assetId = UUID.randomUUID().toString(); providerConnector.createDataOffer(assetId, "http://example.com"); // act & assert prepareDatasetApiCall( - consumerConnector, - providerConfig.getProtocolApiUrl(), - assetId) - .then() - .statusCode(200) - .body("'edc:description'", equalTo("description")); + consumerConnector, + ApiContext.PROTOCOL, + assetId) + .then() + .statusCode(200) + .body("'edc:description'", equalTo("description")); } @Test void canNotRetrieveNotOfferedDataset( - @Consumer ConnectorRemote consumerConnector, - @Provider ConnectorConfig providerConfig, - @Provider ConnectorRemote providerConnector) { + @Consumer ManagementApiConnectorRemote consumerConnector, + @Provider Config providerConfig, + @Provider ManagementApiConnectorRemote providerConnector) { // arrange Map dataSource = Map.of( - EDC_NAMESPACE + "type", "HttpData", - EDC_NAMESPACE + "baseUrl", "http://localhost"); + EDC_NAMESPACE + "type", "HttpData", + EDC_NAMESPACE + "baseUrl", "http://localhost"); var assetId = UUID.randomUUID().toString(); providerConnector.createAsset(assetId, dataSource); // act & assert prepareDatasetApiCall( - consumerConnector, - providerConfig.getProtocolApiUrl(), - assetId) - .then() - .statusCode(502); + consumerConnector, + ApiContext.PROTOCOL, + assetId) + .then() + .statusCode(502); } @Test void canNotRetrieveNotOfferedDatasetIfValidOfferAvailable( - @Consumer ConnectorRemote consumerConnector, - @Provider ConnectorConfig providerConfig, - @Provider ConnectorRemote providerConnector) { + @Consumer ManagementApiConnectorRemote consumerConnector, + @Provider Config providerConfig, + @Provider ManagementApiConnectorRemote providerConnector) { // arrange Map dataSource = Map.of( - EDC_NAMESPACE + "type", "HttpData", - EDC_NAMESPACE + "baseUrl", "http://localhost"); + EDC_NAMESPACE + "type", "HttpData", + EDC_NAMESPACE + "baseUrl", "http://localhost"); var notOfferedAssetId = UUID.randomUUID().toString(); var offeredAssetId = UUID.randomUUID().toString(); providerConnector.createAsset(notOfferedAssetId, dataSource); @@ -95,35 +97,35 @@ void canNotRetrieveNotOfferedDatasetIfValidOfferAvailable( // act & assert prepareDatasetApiCall( - consumerConnector, - providerConfig.getProtocolApiUrl(), - notOfferedAssetId) - .then() - .statusCode(502); + consumerConnector, + ApiContext.PROTOCOL, + notOfferedAssetId) + .then() + .statusCode(502); prepareDatasetApiCall( - consumerConnector, - providerConfig.getProtocolApiUrl(), - offeredAssetId) - .then() - .statusCode(200) - .body("'edc:description'", equalTo("description")); + consumerConnector, + ApiContext.PROTOCOL, + offeredAssetId) + .then() + .statusCode(200) + .body("'edc:description'", equalTo("description")); } private static Response prepareDatasetApiCall( - ConnectorRemote consumerConnector, - String providerProtocolUrl, - String assetId) { + ManagementApiConnectorRemote consumerConnector, + String providerProtocolUrl, + String assetId) { var requestBody = createObjectBuilder() - .add(CONTEXT, createObjectBuilder().add(EDC_PREFIX, EDC_NAMESPACE)) - .add(EDC_NAMESPACE + "counterPartyAddress", providerProtocolUrl) - .add(EDC_NAMESPACE + "protocol", "dataspace-protocol-http") - .add("@id", assetId) - .build(); + .add(CONTEXT, createObjectBuilder().add(EDC_PREFIX, EDC_NAMESPACE)) + .add(EDC_NAMESPACE + "counterPartyAddress", providerProtocolUrl) + .add(EDC_NAMESPACE + "protocol", "dataspace-protocol-http") + .add("@id", assetId) + .build(); return consumerConnector.prepareManagementApiCall() - .contentType(JSON) - .body(requestBody) - .when() - .post("/v2/catalog/dataset/request"); + .contentType(JSON) + .body(requestBody) + .when() + .post("/v2/catalog/dataset/request"); } }