diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 82f2f7b..cb3ba48 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -126,6 +126,7 @@ edc-bom-dataplane = { module = "org.eclipse.edc:dataplane-base-bom", version.ref ## EDC Fixtures edc-fixtures-sql = { module = "org.eclipse.edc:sql-test-fixtures", version.ref = "edc" } +edc-fixtures-mgmtapi = { module = "org.eclipse.edc:management-api-test-fixtures", version.ref = "edc" } ### IH for testing edc-ih-test-fixtures = { module = "org.eclipse.edc:identityhub-test-fixtures", version.ref = "edc" } diff --git a/system-tests/runtime-tests/build.gradle.kts b/system-tests/runtime-tests/build.gradle.kts index ba7f8fc..8bd494b 100644 --- a/system-tests/runtime-tests/build.gradle.kts +++ b/system-tests/runtime-tests/build.gradle.kts @@ -41,6 +41,7 @@ dependencies { exclude("com.networknt", "json-schema-validator") } testImplementation(testFixtures(libs.edc.lib.oauth2.authn)) + testImplementation(testFixtures(libs.edc.fixtures.mgmtapi)) testImplementation(libs.nimbus.jwt) testImplementation(libs.bouncyCastle.bcpkixJdk18on) diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/DcpTransferPullEndToEndTest.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/DcpTransferPullEndToEndTest.java index e198c26..e3094b9 100644 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/DcpTransferPullEndToEndTest.java +++ b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/DcpTransferPullEndToEndTest.java @@ -16,11 +16,21 @@ import org.eclipse.edc.api.authentication.OauthServerEndToEndExtension; import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiationStates; +import org.eclipse.edc.connector.controlplane.test.system.utils.Participants; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.ManagementApiClientV5; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.AssetDto; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.AtomicConstraintDto; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.CelExpressionDto; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.DataAddressDto; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.PermissionDto; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.PolicyDefinitionDto; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.PolicyDto; import org.eclipse.edc.identityhub.tests.fixtures.DefaultRuntimes; import org.eclipse.edc.identityhub.tests.fixtures.credentialservice.IdentityHub; import org.eclipse.edc.identityhub.tests.fixtures.credentialservice.IdentityHubApiClient; import org.eclipse.edc.identityhub.tests.fixtures.issuerservice.IssuerService; import org.eclipse.edc.junit.annotations.PostgresqlIntegrationTest; +import org.eclipse.edc.junit.extensions.ComponentRuntimeContext; import org.eclipse.edc.junit.extensions.ComponentRuntimeExtension; import org.eclipse.edc.junit.extensions.RuntimeExtension; import org.eclipse.edc.junit.utils.Endpoints; @@ -29,16 +39,7 @@ import org.eclipse.edc.spi.system.configuration.ConfigFactory; import org.eclipse.edc.sql.testfixtures.PostgresqlEndToEndExtension; import org.eclipse.edc.virtual.Runtimes; -import org.eclipse.edc.virtual.transfer.fixtures.Participants; import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnector; -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.AssetDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.AtomicConstraintDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.CelExpressionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.DataAddressDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.PermissionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.PolicyDefinitionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.PolicyDto; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Order; @@ -63,14 +64,16 @@ class DcpTransferPullEndToEndTest { public static final String PROVIDER_CONTEXT = "provider"; public static final String CONSUMER_CONTEXT = "consumer"; - private static Participants participants(Endpoints endpoints) { + private static Participants participants(ComponentRuntimeContext ctx, Endpoints endpoints) { + var protocolEndpoint = ctx.getEndpoint("protocol"); + var signalingEndpoint = ctx.getEndpoint("signaling"); var providerDid = Runtimes.IdentityHub.didFor(endpoints, PROVIDER_CONTEXT); var providerCfg = Runtimes.IdentityHub.dcpConfig(endpoints, PROVIDER_CONTEXT); var consumerDid = Runtimes.IdentityHub.didFor(endpoints, CONSUMER_CONTEXT); var consumerCfg = Runtimes.IdentityHub.dcpConfig(endpoints, CONSUMER_CONTEXT); return new Participants( - new Participants.Participant(PROVIDER_CONTEXT, providerDid, providerCfg.getEntries()), - new Participants.Participant(CONSUMER_CONTEXT, consumerDid, consumerCfg.getEntries()) + new Participants.Participant(PROVIDER_CONTEXT, providerDid, protocolEndpoint, signalingEndpoint, providerCfg.getEntries()), + new Participants.Participant(CONSUMER_CONTEXT, consumerDid, protocolEndpoint, signalingEndpoint, consumerCfg.getEntries()) ); } @@ -112,7 +115,7 @@ static void setup(IssuerService issuer, @Test void httpPull_dataTransfer_withMembershipExpression(VirtualConnector env, - VirtualConnectorClient connectorClient, + ManagementApiClientV5 connectorClient, Participants participants) { var leftOperand = "https://w3id.org/example/credentials/MembershipCredential"; @@ -142,7 +145,7 @@ void httpPull_dataTransfer_withMembershipExpression(VirtualConnector env, } @Test - void negotiation_fails_withMissingCredential(VirtualConnector env, VirtualConnectorClient connectorClient, + void negotiation_fails_withMissingCredential(VirtualConnector env, ManagementApiClientV5 connectorClient, Participants participants) { var leftOperand = "https://w3id.org/example/credentials/DataAccessCredential"; @@ -170,7 +173,7 @@ void negotiation_fails_withMissingCredential(VirtualConnector env, VirtualConnec } - private String setup(VirtualConnectorClient connectorClient, Participants.Participant provider, PolicyDto policy) { + private String setup(ManagementApiClientV5 connectorClient, Participants.Participant provider, PolicyDto policy) { var asset = new AssetDto(new DataAddressDto("HttpData")); var policyDef = new PolicyDefinitionDto(policy); @@ -244,8 +247,8 @@ class Postgres extends DcpTransferPullEndToEndTestBase { .configurationProvider(AUTH_SERVER_EXTENSION::getConfig) .configurationProvider(() -> ConfigFactory.fromMap(Map.of("edc.iam.did.web.use.https", "false"))) .paramProvider(VirtualConnector.class, VirtualConnector::forContext) - .paramProvider(VirtualConnectorClient.class, (ctx) -> VirtualConnectorClient.forContext(ctx, AUTH_SERVER_EXTENSION.getAuthServer())) - .paramProvider(Participants.class, context -> participants(IDENTITY_HUB_ENDPOINTS)) + .paramProvider(ManagementApiClientV5.class, (ctx) -> ManagementApiClientV5.forContext(ctx, AUTH_SERVER_EXTENSION.getAuthServer())) + .paramProvider(Participants.class, context -> participants(context, IDENTITY_HUB_ENDPOINTS)) .build(); private static Config runtimeConfiguration() { diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/TransferPullEndToEndTest.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/TransferPullEndToEndTest.java index 283acf7..a3684a2 100644 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/TransferPullEndToEndTest.java +++ b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/TransferPullEndToEndTest.java @@ -15,16 +15,17 @@ package org.eclipse.edc.virtual.transfer; import org.eclipse.edc.api.authentication.OauthServerEndToEndExtension; +import org.eclipse.edc.connector.controlplane.test.system.utils.Participants; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.ManagementApiClientV5; import org.eclipse.edc.junit.annotations.EndToEndTest; import org.eclipse.edc.junit.annotations.PostgresqlIntegrationTest; +import org.eclipse.edc.junit.extensions.ComponentRuntimeContext; import org.eclipse.edc.junit.extensions.ComponentRuntimeExtension; import org.eclipse.edc.junit.extensions.RuntimeExtension; import org.eclipse.edc.nats.testfixtures.NatsEndToEndExtension; import org.eclipse.edc.sql.testfixtures.PostgresqlEndToEndExtension; import org.eclipse.edc.virtual.Runtimes; -import org.eclipse.edc.virtual.transfer.fixtures.Participants; import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnector; -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.extension.BeforeAllCallback; @@ -40,10 +41,12 @@ class TransferPullEndToEndTest { public static final String PROVIDER_ID = "provider-id"; public static final String CONSUMER_ID = "consumer-id"; - private static Participants participants() { + private static Participants participants(ComponentRuntimeContext ctx) { + var protocolEndpoint = ctx.getEndpoint("protocol"); + var signalingEndpoint = ctx.getEndpoint("signaling"); return new Participants( - new Participants.Participant(PROVIDER_CONTEXT, PROVIDER_ID), - new Participants.Participant(CONSUMER_CONTEXT, CONSUMER_ID) + new Participants.Participant(PROVIDER_CONTEXT, PROVIDER_ID, protocolEndpoint, signalingEndpoint), + new Participants.Participant(CONSUMER_CONTEXT, CONSUMER_ID, protocolEndpoint, signalingEndpoint) ); } @@ -63,8 +66,8 @@ class InMemory extends TransferPullEndToEndTestBase { .configurationProvider(Runtimes.ControlPlane::config) .configurationProvider(AUTH_SERVER_EXTENSION::getConfig) .paramProvider(VirtualConnector.class, VirtualConnector::forContext) - .paramProvider(VirtualConnectorClient.class, (ctx) -> VirtualConnectorClient.forContext(ctx, AUTH_SERVER_EXTENSION.getAuthServer())) - .paramProvider(Participants.class, context -> participants()) + .paramProvider(ManagementApiClientV5.class, (ctx) -> ManagementApiClientV5.forContext(ctx, AUTH_SERVER_EXTENSION.getAuthServer())) + .paramProvider(Participants.class, TransferPullEndToEndTest::participants) .build(); } @@ -99,45 +102,8 @@ class Postgres extends TransferPullEndToEndTestBase { .configurationProvider(NATS_EXTENSION::configFor) .configurationProvider(AUTH_SERVER_EXTENSION::getConfig) .paramProvider(VirtualConnector.class, VirtualConnector::forContext) - .paramProvider(VirtualConnectorClient.class, (ctx) -> VirtualConnectorClient.forContext(ctx, AUTH_SERVER_EXTENSION.getAuthServer())) - .paramProvider(Participants.class, context -> participants()) - .build(); - - } - - @Nested - @PostgresqlIntegrationTest - class PostgresNatsTasks extends TransferPullEndToEndTestBase { - - @Order(0) - @RegisterExtension - static final OauthServerEndToEndExtension AUTH_SERVER_EXTENSION = OauthServerEndToEndExtension.Builder.newInstance().build(); - - @Order(0) - @RegisterExtension - static final NatsEndToEndExtension NATS_EXTENSION = new NatsEndToEndExtension(); - @Order(0) - @RegisterExtension - static final PostgresqlEndToEndExtension POSTGRESQL_EXTENSION = new PostgresqlEndToEndExtension(createPgContainer()); - @Order(1) - @RegisterExtension - static final BeforeAllCallback SETUP = context -> { - POSTGRESQL_EXTENSION.createDatabase(Runtimes.ControlPlane.NAME.toLowerCase()); - }; - - @Order(2) - @RegisterExtension - static final RuntimeExtension CONTROL_PLANE = ComponentRuntimeExtension.Builder.newInstance() - .name(Runtimes.ControlPlane.NAME) - .modules(Runtimes.ControlPlane.PG_NATS_TASKS_MODULES) - .endpoints(Runtimes.ControlPlane.ENDPOINTS.build()) - .configurationProvider(Runtimes.ControlPlane::config) - .configurationProvider(() -> POSTGRESQL_EXTENSION.configFor(Runtimes.ControlPlane.NAME.toLowerCase())) - .configurationProvider(NATS_EXTENSION::configFor) - .configurationProvider(AUTH_SERVER_EXTENSION::getConfig) - .paramProvider(VirtualConnector.class, VirtualConnector::forContext) - .paramProvider(VirtualConnectorClient.class, (ctx) -> VirtualConnectorClient.forContext(ctx, AUTH_SERVER_EXTENSION.getAuthServer())) - .paramProvider(Participants.class, context -> participants()) + .paramProvider(ManagementApiClientV5.class, (ctx) -> ManagementApiClientV5.forContext(ctx, AUTH_SERVER_EXTENSION.getAuthServer())) + .paramProvider(Participants.class, TransferPullEndToEndTest::participants) .build(); } diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/TransferPullEndToEndTestBase.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/TransferPullEndToEndTestBase.java index 8aae8a6..ba0c1b6 100644 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/TransferPullEndToEndTestBase.java +++ b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/TransferPullEndToEndTestBase.java @@ -19,20 +19,20 @@ import com.nimbusds.jose.jwk.Curve; import com.nimbusds.jose.jwk.gen.ECKeyGenerator; import org.eclipse.edc.connector.controlplane.services.spi.transferprocess.TransferProcessService; +import org.eclipse.edc.connector.controlplane.test.system.utils.Participants; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.ManagementApiClientV5; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.AssetDto; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.DataAddressDto; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.PermissionDto; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.PolicyDefinitionDto; +import org.eclipse.edc.connector.controlplane.test.system.utils.client.api.model.PolicyDto; import org.eclipse.edc.connector.dataplane.spi.Endpoint; import org.eclipse.edc.connector.dataplane.spi.iam.PublicEndpointGeneratorService; import org.eclipse.edc.junit.annotations.Runtime; import org.eclipse.edc.spi.EdcException; import org.eclipse.edc.spi.security.Vault; import org.eclipse.edc.virtual.Runtimes.ControlPlane; -import org.eclipse.edc.virtual.transfer.fixtures.Participants; import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnector; -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.AssetDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.DataAddressDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.PermissionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.PolicyDefinitionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.PolicyDto; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -56,7 +56,7 @@ abstract class TransferPullEndToEndTestBase { @BeforeAll static void beforeAll(PublicEndpointGeneratorService generatorService, - VirtualConnectorClient connectorClient, + ManagementApiClientV5 connectorClient, Participants participants, @Runtime(ControlPlane.NAME) Vault vault) { generatorService.addGeneratorFunction("HttpData", address -> Endpoint.url("http://example.com")); @@ -78,7 +78,7 @@ static void beforeAll(PublicEndpointGeneratorService generatorService, } @Test - void transfer(VirtualConnector env, VirtualConnectorClient connectorClient, Participants participants) { + void transfer(VirtualConnector env, ManagementApiClientV5 connectorClient, Participants participants) { var providerAddress = env.getProtocolEndpoint().get() + "/" + participants.provider().contextId() + "/2025-1"; var assetId = setup(connectorClient, participants.provider()); @@ -92,7 +92,7 @@ void transfer(VirtualConnector env, VirtualConnectorClient connectorClient, Part } @Test - void suspendAndResumeByProvider(VirtualConnector env, VirtualConnectorClient connectorClient, Participants participants) { + void suspendAndResumeByProvider(VirtualConnector env, ManagementApiClientV5 connectorClient, Participants participants) { var providerAddress = env.getProtocolEndpoint().get() + "/" + participants.provider().contextId() + "/2025-1"; var assetId = setup(connectorClient, participants.provider()); @@ -116,7 +116,7 @@ void suspendAndResumeByProvider(VirtualConnector env, VirtualConnectorClient con } @Test - void suspendAndResumeByConsumer(VirtualConnector env, VirtualConnectorClient connectorClient, Participants participants) { + void suspendAndResumeByConsumer(VirtualConnector env, ManagementApiClientV5 connectorClient, Participants participants) { var providerAddress = env.getProtocolEndpoint().get() + "/" + participants.provider().contextId() + "/2025-1"; var assetId = setup(connectorClient, participants.provider()); @@ -139,7 +139,7 @@ void suspendAndResumeByConsumer(VirtualConnector env, VirtualConnectorClient con } @Test - void terminateByConsumer(VirtualConnector env, VirtualConnectorClient connectorClient, Participants participants) { + void terminateByConsumer(VirtualConnector env, ManagementApiClientV5 connectorClient, Participants participants) { var providerAddress = env.getProtocolEndpoint().get() + "/" + participants.provider().contextId() + "/2025-1"; var assetId = setup(connectorClient, participants.provider()); @@ -158,7 +158,7 @@ void terminateByConsumer(VirtualConnector env, VirtualConnectorClient connectorC } @Test - void terminateByProvider(VirtualConnector env, VirtualConnectorClient connectorClient, Participants participants) { + void terminateByProvider(VirtualConnector env, ManagementApiClientV5 connectorClient, Participants participants) { var providerAddress = env.getProtocolEndpoint().get() + "/" + participants.provider().contextId() + "/2025-1"; var assetId = setup(connectorClient, participants.provider()); @@ -177,7 +177,7 @@ void terminateByProvider(VirtualConnector env, VirtualConnectorClient connectorC } @Test - void completeByProvider(VirtualConnector env, TransferProcessService service, VirtualConnectorClient connectorClient, Participants participants) { + void completeByProvider(VirtualConnector env, TransferProcessService service, ManagementApiClientV5 connectorClient, Participants participants) { var providerAddress = env.getProtocolEndpoint().get() + "/" + participants.provider().contextId() + "/2025-1"; var assetId = setup(connectorClient, participants.provider()); @@ -198,7 +198,7 @@ void completeByProvider(VirtualConnector env, TransferProcessService service, Vi } @Test - void completeByConsumer(VirtualConnector env, TransferProcessService service, VirtualConnectorClient connectorClient, Participants participants) { + void completeByConsumer(VirtualConnector env, TransferProcessService service, ManagementApiClientV5 connectorClient, Participants participants) { var providerAddress = env.getProtocolEndpoint().get() + "/" + participants.provider().contextId() + "/2025-1"; var assetId = setup(connectorClient, participants.provider()); @@ -218,7 +218,7 @@ void completeByConsumer(VirtualConnector env, TransferProcessService service, Vi } - private String setup(VirtualConnectorClient connectorClient, Participants.Participant provider) { + private String setup(ManagementApiClientV5 connectorClient, Participants.Participant provider) { var asset = new AssetDto(new DataAddressDto("HttpData")); var permissions = List.of(new PermissionDto()); diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/Participants.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/Participants.java deleted file mode 100644 index 4fa4025..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/Participants.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures; - -import java.util.Map; - -public record Participants(Participant provider, Participant consumer) { - - public record Participant(String contextId, String id, Map config) { - - public Participant(String contextId, String id) { - this(contextId, id, Map.of()); - } - } -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/VirtualConnectorClient.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/VirtualConnectorClient.java deleted file mode 100644 index 4f9e336..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/VirtualConnectorClient.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures; - -import io.restassured.specification.RequestSpecification; -import org.eclipse.edc.api.auth.spi.ParticipantPrincipal; -import org.eclipse.edc.api.authentication.OauthServer; -import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates; -import org.eclipse.edc.jsonld.spi.JsonLdNamespace; -import org.eclipse.edc.junit.extensions.ComponentRuntimeContext; -import org.eclipse.edc.junit.utils.LazySupplier; -import org.eclipse.edc.virtual.transfer.fixtures.api.AssetsApi; -import org.eclipse.edc.virtual.transfer.fixtures.api.CatalogApi; -import org.eclipse.edc.virtual.transfer.fixtures.api.CelExpressionApi; -import org.eclipse.edc.virtual.transfer.fixtures.api.ContractDefApi; -import org.eclipse.edc.virtual.transfer.fixtures.api.ContractNegotiationApi; -import org.eclipse.edc.virtual.transfer.fixtures.api.ParticipantContextApi; -import org.eclipse.edc.virtual.transfer.fixtures.api.ParticipantContextConfigApi; -import org.eclipse.edc.virtual.transfer.fixtures.api.PolicyDefApi; -import org.eclipse.edc.virtual.transfer.fixtures.api.TransferApi; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.AssetDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.ContractDefinitionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.ContractNegotiationDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.ContractRequestDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.CriterionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.DatasetDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.DatasetRequestDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.OfferDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.ParticipantContextConfigDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.ParticipantContextDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.PolicyDefinitionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.QuerySpectDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.TransferRequestDto; - -import java.net.URI; -import java.time.Duration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import static io.restassured.RestAssured.given; -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Awaitility.await; -import static org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiationStates.FINALIZED; -import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates.STARTED; -import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; - -public class VirtualConnectorClient { - - protected static final Duration TIMEOUT = Duration.ofSeconds(30); - private static final String PROTOCOL = "dataspace-protocol-http:2025-1"; - private static final JsonLdNamespace NS = new JsonLdNamespace(EDC_NAMESPACE); - private final OauthServer oauthServer; - private final LazySupplier managementEndpoint; - - private final AssetsApi assets; - private final PolicyDefApi policies; - private final ContractDefApi contractDefinitions; - private final ParticipantContextApi participantContexts; - private final ParticipantContextConfigApi participantConfigurations; - private final CatalogApi catalogs; - private final ContractNegotiationApi negotiations; - private final TransferApi transfers; - private final CelExpressionApi expressions; - - - public VirtualConnectorClient(OauthServer oauthServer, - LazySupplier managementEndpoint) { - this.oauthServer = oauthServer; - this.managementEndpoint = managementEndpoint; - this.assets = new AssetsApi(this); - this.policies = new PolicyDefApi(this); - this.contractDefinitions = new ContractDefApi(this); - this.participantContexts = new ParticipantContextApi(this); - this.participantConfigurations = new ParticipantContextConfigApi(this); - this.catalogs = new CatalogApi(this); - this.negotiations = new ContractNegotiationApi(this); - this.transfers = new TransferApi(this); - this.expressions = new CelExpressionApi(this); - } - - public static VirtualConnectorClient forContext(ComponentRuntimeContext ctx, OauthServer authServer) { - return new VirtualConnectorClient( - authServer, - ctx.getEndpoint("management") - ); - } - - public AssetsApi assets() { - return assets; - } - - public PolicyDefApi policies() { - return policies; - } - - public ContractDefApi contractDefinitions() { - return contractDefinitions; - } - - public ParticipantContextApi participantContexts() { - return participantContexts; - } - - public ParticipantContextConfigApi participantConfigurations() { - return participantConfigurations; - } - - public CatalogApi catalogs() { - return catalogs; - } - - public ContractNegotiationApi negotiations() { - return negotiations; - } - - public TransferApi transfers() { - return transfers; - } - - public CelExpressionApi expressions() { - return expressions; - } - - private String startTransferProcess(String participantContext, String contractAgreementId, String providerAddress, String transferType) { - var request = new TransferRequestDto(PROTOCOL, providerAddress, transferType, contractAgreementId); - var transferId = transfers.initTransfer(participantContext, request); - - waitTransferInState(participantContext, transferId, STARTED); - - return transferId; - - } - - public void waitTransferInState(String participantContextId, String transferId, TransferProcessStates state) { - await().atMost(TIMEOUT).untilAsserted(() -> { - var currentState = transfers.getState(participantContextId, transferId); - assertThat(currentState).isEqualTo(state.name()); - }); - } - - public String initContractNegotiation(String participantContext, String assetId, String providerAddress, String providerId) { - - try { - var dataset = fetchDataset(participantContext, assetId, providerAddress, providerId); - var offer = dataset.offers().stream().findFirst().orElseThrow(); - - return initContractNegotiation(participantContext, assetId, offer, providerAddress, providerId); - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private DatasetDto fetchDataset(String participantContext, String assetId, String providerAddress, String providerId) { - return catalogs.getDataset(participantContext, new DatasetRequestDto(assetId, PROTOCOL, providerAddress, providerId)); - } - - public void waitForContractNegotiationState(String participantContextId, String negotiationId, String state) { - await().atMost(TIMEOUT).untilAsserted(() -> { - var currentState = negotiations.getState(participantContextId, negotiationId); - assertThat(currentState).isEqualTo(state); - }); - } - - public String getNegotiationError(String participantContextId, String negotiationId) { - var contractNegotiation = negotiations.getNegotiation(participantContextId, negotiationId); - return Optional.of(contractNegotiation).map(ContractNegotiationDto::getErrorDetail) - .orElse(null); - } - - public String startContractNegotiation(String participantContext, String providerContextId, String assetId, OfferDto offerDto, String providerAddress, String providerId) { - var negotiationId = initContractNegotiation(participantContext, assetId, offerDto, providerAddress, providerId); - - - waitForContractNegotiationState(participantContext, negotiationId, FINALIZED.name()); - - await().atMost(TIMEOUT).untilAsserted(() -> { - var query = new QuerySpectDto(List.of(new CriterionDto("correlationId", "=", negotiationId))); - var state = negotiations.search(providerContextId, query).stream() - .map(ContractNegotiationDto::getState) - .findFirst(); - - assertThat(state).isEqualTo(Optional.of(FINALIZED.name())); - }); - - return negotiations.getNegotiation(participantContext, negotiationId).getContractAgreementId(); - - } - - public String initContractNegotiation(String participantContext, String assetId, OfferDto offerDto, String providerAddress, String providerId) { - var offer = new OfferDto(offerDto.getId(), providerId, assetId, offerDto.getPermissions()); - - var request = new ContractRequestDto(PROTOCOL, providerAddress, providerId, offer); - - return negotiations.initContractNegotiation(participantContext, request); - - } - - public String startTransfer(String participantContext, String providerContextId, String providerAddress, String providerId, String assetId, String transferType) { - try { - var dataset = fetchDataset(participantContext, assetId, providerAddress, providerId); - var offer = dataset.offers().stream().findFirst().orElseThrow(); - - var agreementId = startContractNegotiation(participantContext, providerContextId, assetId, offer, providerAddress, providerId); - return startTransferProcess(participantContext, agreementId, providerAddress, transferType); - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public String setupResources(String participantContext, AssetDto asset, PolicyDefinitionDto accessPolicy, PolicyDefinitionDto contractPolicy) { - - var assetId = assets.createAsset(participantContext, asset); - - var accessPolicyId = policies.createPolicyDefinition(participantContext, accessPolicy); - var contractPolicyId = policies.createPolicyDefinition(participantContext, contractPolicy); - - var selector = List.of(new CriterionDto(NS.toIri("id"), "=", assetId)); - var contractDefinition = new ContractDefinitionDto(accessPolicyId, contractPolicyId, selector); - contractDefinitions.createContractDefinition(participantContext, contractDefinition); - - return assetId; - } - - - public void createParticipant(String participantContextId, String participantId, Map cfg) { - - participantContexts.createParticipant(new ParticipantContextDto(participantContextId, participantId)); - - // to remove once it's not needed for iam mock - var configuration = new HashMap<>(cfg); - configuration.put("edc.participant.id", participantId); - participantConfigurations.saveConfig(participantContextId, new ParticipantContextConfigDto(configuration)); - - } - - public RequestSpecification baseManagementRequest(String participantContextId) { - if (participantContextId == null) { - return baseManagementRequest(null, ParticipantPrincipal.ROLE_ADMIN); - } else { - return baseManagementRequest(participantContextId, ParticipantPrincipal.ROLE_PARTICIPANT); - - } - } - - public RequestSpecification baseManagementRequest(String participantContextId, String role) { - var token = oauthServer.createToken(participantContextId, role); - return given().baseUri(managementEndpoint.get().toString()) - .header("Authorization", "Bearer " + token); - } -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/AssetsApi.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/AssetsApi.java deleted file mode 100644 index a775c89..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/AssetsApi.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api; - -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.AssetDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.WithContext; - -import static io.restassured.http.ContentType.JSON; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; - -/** - * API client for asset-related operations. - */ -public class AssetsApi { - private final VirtualConnectorClient connector; - - public AssetsApi(VirtualConnectorClient connector) { - this.connector = connector; - } - - /** - * Creates an asset in the specified participant context. - * - * @param participantContextId the participant context ID - * @param asset the asset to create - * @return the ID of the created asset - */ - public String createAsset(String participantContextId, AssetDto asset) { - return connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .body(new WithContext<>(asset)) - .when() - .post("/v5alpha/participants/%s/assets".formatted(participantContextId)) - .then() - .log().ifError() - .statusCode(200) - .contentType(JSON) - .extract().jsonPath().getString(ID); - } - - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/CatalogApi.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/CatalogApi.java deleted file mode 100644 index 03843ee..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/CatalogApi.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api; - -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.DatasetDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.DatasetRequestDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.WithContext; - -import static io.restassured.http.ContentType.JSON; - -/** - * API client for catalog-related operations. - */ -public class CatalogApi { - private final VirtualConnectorClient connector; - - public CatalogApi(VirtualConnectorClient connector) { - this.connector = connector; - } - - /** - * Requests a dataset from the catalog in the specified participant context. - * - * @param participantContextId the participant context ID - * @param datasetRequest the dataset request - * @return the requested dataset - */ - public DatasetDto getDataset(String participantContextId, DatasetRequestDto datasetRequest) { - return connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .body(new WithContext<>(datasetRequest)) - .when() - .post("/v5alpha/participants/%s/catalog/dataset/request".formatted(participantContextId)) - .then() - .log().ifValidationFails() - .statusCode(200) - .contentType(JSON) - .extract().as(DatasetDto.class); - } - - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/CelExpressionApi.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/CelExpressionApi.java deleted file mode 100644 index 4e7395b..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/CelExpressionApi.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api; - -import org.eclipse.edc.api.auth.spi.ParticipantPrincipal; -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.CelExpressionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.WithContext; - -import static com.apicatalog.jsonld.lang.Keywords.ID; -import static io.restassured.http.ContentType.JSON; - -/** - * API client for CEL expression-related operations. - */ -public class CelExpressionApi { - private final VirtualConnectorClient connector; - - public CelExpressionApi(VirtualConnectorClient connector) { - this.connector = connector; - } - - /** - * Creates a CEL expression. - * - * @param expression the CEL expression to create - * @return the ID of the created CEL expression - */ - public String createExpression(CelExpressionDto expression) { - return connector.baseManagementRequest(null, ParticipantPrincipal.ROLE_PROVISIONER) - .contentType(JSON) - .body(new WithContext<>(expression)) - .when() - .post("/v5alpha/celexpressions") - .then() - .log().ifValidationFails() - .statusCode(200) - .contentType(JSON) - .extract().jsonPath().getString(ID); - } - - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ContractDefApi.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ContractDefApi.java deleted file mode 100644 index e0f532d..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ContractDefApi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api; - -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.ContractDefinitionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.WithContext; - -import static io.restassured.http.ContentType.JSON; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; - -/** - * API client for contract definition-related operations. - */ -public class ContractDefApi { - - private final VirtualConnectorClient connector; - - public ContractDefApi(VirtualConnectorClient connector) { - this.connector = connector; - } - - /** - * Creates a contract definition in the specified participant context. - * - * @param participantContextId the participant context ID - * @param contractDefinitionDto the contract definition to create - * @return the ID of the created contract definition - */ - public String createContractDefinition(String participantContextId, ContractDefinitionDto contractDefinitionDto) { - return connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .body(new WithContext<>(contractDefinitionDto)) - .when() - .post("/v5alpha/participants/%s/contractdefinitions".formatted(participantContextId)) - .then() - .log().ifError() - .statusCode(200) - .contentType(JSON) - .extract().jsonPath().getString(ID); - } -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ContractNegotiationApi.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ContractNegotiationApi.java deleted file mode 100644 index d50e6c8..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ContractNegotiationApi.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api; - -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.ContractNegotiationDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.ContractRequestDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.QuerySpectDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.WithContext; - -import java.util.Arrays; -import java.util.List; - -import static io.restassured.http.ContentType.JSON; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; - -/** - * API client for contract negotiation-related operations. - */ -public class ContractNegotiationApi { - private final VirtualConnectorClient connector; - - public ContractNegotiationApi(VirtualConnectorClient connector) { - this.connector = connector; - } - - /** - * Initiates a contract negotiation in the specified participant context. - * - * @param participantContextId the participant context ID - * @param contractRequest the contract request - * @return the ID of the initiated contract negotiation - */ - public String initContractNegotiation(String participantContextId, ContractRequestDto contractRequest) { - return connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .body(new WithContext<>(contractRequest)) - .when() - .post("/v5alpha/participants/%s/contractnegotiations".formatted(participantContextId)) - .then() - .log().ifValidationFails() - .statusCode(200) - .contentType(JSON) - .extract().jsonPath().getString(ID); - } - - public String getState(String participantContextId, String negotiationId) { - return connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .when() - .get("/v5alpha/participants/%s/contractnegotiations/%s/state".formatted(participantContextId, negotiationId)) - .then() - .log().ifValidationFails() - .statusCode(200) - .contentType(JSON) - .extract().jsonPath().getString("state"); - } - - public ContractNegotiationDto getNegotiation(String participantContextId, String negotiationId) { - return connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .when() - .get("/v5alpha/participants/%s/contractnegotiations/%s".formatted(participantContextId, negotiationId)) - .then() - .log().ifValidationFails() - .statusCode(200) - .contentType(JSON) - .extract().as(ContractNegotiationDto.class); - } - - public List search(String participantContextId, QuerySpectDto filter) { - return Arrays.stream(connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .body(new WithContext<>(filter)) - .when() - .post("/v5alpha/participants/%s/contractnegotiations/request".formatted(participantContextId)) - .then() - .log().ifValidationFails() - .statusCode(200) - .contentType(JSON) - .extract().as(ContractNegotiationDto[].class)) - .toList(); - } - - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ParticipantContextApi.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ParticipantContextApi.java deleted file mode 100644 index ebac1ac..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ParticipantContextApi.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api; - -import org.eclipse.edc.api.auth.spi.ParticipantPrincipal; -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.ParticipantContextDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.WithContext; - -import static io.restassured.http.ContentType.JSON; - -public class ParticipantContextApi { - private final VirtualConnectorClient connector; - - public ParticipantContextApi(VirtualConnectorClient connector) { - this.connector = connector; - } - - /** - * Creates a participant context. - * - * @param participantContextDto the participant context to create - */ - public void createParticipant(ParticipantContextDto participantContextDto) { - connector.baseManagementRequest(null, ParticipantPrincipal.ROLE_PROVISIONER) - .contentType(JSON) - .body(new WithContext<>(participantContextDto)) - .when() - .post("/v5alpha/participants") - .then() - .log().ifError() - .statusCode(200); - } - - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ParticipantContextConfigApi.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ParticipantContextConfigApi.java deleted file mode 100644 index a28676f..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/ParticipantContextConfigApi.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api; - -import org.eclipse.edc.api.auth.spi.ParticipantPrincipal; -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.ParticipantContextConfigDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.WithContext; - -import static io.restassured.http.ContentType.JSON; - -/** - * API client for participant context configuration-related operations. - */ -public class ParticipantContextConfigApi { - private final VirtualConnectorClient connector; - - public ParticipantContextConfigApi(VirtualConnectorClient connector) { - this.connector = connector; - } - - /** - * Saves the configuration for a participant context. - * - * @param participantContextId the participant context ID - * @param participantContextDto the participant context configuration to save - */ - public void saveConfig(String participantContextId, ParticipantContextConfigDto participantContextDto) { - connector.baseManagementRequest(null, ParticipantPrincipal.ROLE_PROVISIONER) - .contentType(JSON) - .body(new WithContext<>(participantContextDto)) - .when() - .put("/v5alpha/participants/%s/config".formatted(participantContextId)) - .then() - .log().ifError() - .statusCode(204); - } - - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/PolicyDefApi.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/PolicyDefApi.java deleted file mode 100644 index 76c43aa..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/PolicyDefApi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api; - -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.PolicyDefinitionDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.WithContext; - -import static io.restassured.http.ContentType.JSON; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; - -/** - * API client for policy definition-related operations. - */ -public class PolicyDefApi { - - private final VirtualConnectorClient connector; - - public PolicyDefApi(VirtualConnectorClient connector) { - this.connector = connector; - } - - /** - * Creates a policy definition in the specified participant context. - * - * @param participantContextId the participant context ID - * @param policyDef the policy definition to create - * @return the ID of the created policy definition - */ - public String createPolicyDefinition(String participantContextId, PolicyDefinitionDto policyDef) { - return connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .body(new WithContext<>(policyDef)) - .when() - .post("/v5alpha/participants/%s/policydefinitions".formatted(participantContextId)) - .then() - .log().ifError() - .statusCode(200) - .contentType(JSON) - .extract().jsonPath().getString(ID); - } -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/TransferApi.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/TransferApi.java deleted file mode 100644 index 7919578..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/TransferApi.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api; - -import org.eclipse.edc.virtual.transfer.fixtures.VirtualConnectorClient; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.SuspendTransferDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.TerminateTransferDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.TransferProcessDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.TransferRequestDto; -import org.eclipse.edc.virtual.transfer.fixtures.api.model.WithContext; - -import static io.restassured.http.ContentType.JSON; -import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; - -/** - * API client for transfer-related operations. - */ -public class TransferApi { - private final VirtualConnectorClient connector; - - public TransferApi(VirtualConnectorClient connector) { - this.connector = connector; - } - - /** - * Initiates a transfer process in the specified participant context. - * - * @param participantContextId the participant context ID - * @param transferRequest the transfer request - * @return the ID of the initiated transfer process - */ - public String initTransfer(String participantContextId, TransferRequestDto transferRequest) { - return connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .body(new WithContext<>(transferRequest)) - .when() - .post("/v5alpha/participants/%s/transferprocesses".formatted(participantContextId)) - .then() - .log().ifValidationFails() - .statusCode(200) - .contentType(JSON) - .extract().jsonPath().getString(ID); - } - - /** - * Retrieves the state of a transfer process in the specified participant context. - * - * @param participantContextId the participant context ID - * @param transferId the transfer process ID - * @return the state of the transfer process - */ - public String getState(String participantContextId, String transferId) { - return connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .when() - .get("/v5alpha/participants/%s/transferprocesses/%s/state".formatted(participantContextId, transferId)) - .then() - .log().ifValidationFails() - .statusCode(200) - .contentType(JSON) - .extract().jsonPath().getString("state"); - } - - /** - * Retrieves a transfer process in the specified participant context. - * - * @param participantContextId the participant context ID - * @param transferId the transfer process ID - * @return the transfer process - */ - public TransferProcessDto getTransferProcess(String participantContextId, String transferId) { - return connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .when() - .get("/v5alpha/participants/%s/transferprocesses/%s".formatted(participantContextId, transferId)) - .then() - .log().ifValidationFails() - .statusCode(200) - .contentType(JSON) - .extract().as(TransferProcessDto.class); - } - - /** - * Suspends a transfer process in the specified participant context. - * - * @param participantContextId the participant context ID - * @param transferId the transfer process ID - * @param reason the reason for suspension - */ - public void suspendTransfer(String participantContextId, String transferId, String reason) { - var suspendTransferDto = new SuspendTransferDto(reason); - connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .body(new WithContext<>(suspendTransferDto)) - .when() - .post("/v5alpha/participants/%s/transferprocesses/%s/suspend".formatted(participantContextId, transferId)) - .then() - .log().ifValidationFails() - .statusCode(204); - - } - - /** - * Suspends a transfer process in the specified participant context. - * - * @param participantContextId the participant context ID - * @param transferId the transfer process ID - * @param reason the reason for suspension - */ - public void terminateTransfer(String participantContextId, String transferId, String reason) { - var terminateTransferDto = new TerminateTransferDto(reason); - connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .body(new WithContext<>(terminateTransferDto)) - .when() - .post("/v5alpha/participants/%s/transferprocesses/%s/terminate".formatted(participantContextId, transferId)) - .then() - .log().ifValidationFails() - .statusCode(204); - - } - - /** - * Resumes a suspended transfer process in the specified participant context. - * - * @param participantContextId the participant context ID - * @param transferId the transfer process ID - */ - public void resumeTransfer(String participantContextId, String transferId) { - connector.baseManagementRequest(participantContextId) - .contentType(JSON) - .when() - .post("/v5alpha/participants/%s/transferprocesses/%s/resume".formatted(participantContextId, transferId)) - .then() - .log().ifValidationFails() - .statusCode(204); - - } -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/AssetDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/AssetDto.java deleted file mode 100644 index aa4966b..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/AssetDto.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -/** - * DTO representation of an Asset. - */ -public class AssetDto extends Typed { - - @JsonProperty("@id") - @JsonInclude(JsonInclude.Include.NON_NULL) - private final String id; - private final Map properties; - private final Map privateProperties; - private final DataAddressDto dataAddress; - - public AssetDto(String id, - Map properties, Map privateProperties, - DataAddressDto dataAddress) { - super("Asset"); - this.id = id; - this.properties = properties; - this.privateProperties = privateProperties; - this.dataAddress = dataAddress; - } - - public AssetDto(Map properties, DataAddressDto dataAddress) { - this(null, properties, Map.of(), dataAddress); - } - - public AssetDto(DataAddressDto dataAddress) { - this(null, Map.of(), Map.of(), dataAddress); - } - - public String getId() { - return id; - } - - public Map getProperties() { - return properties; - } - - public Map getPrivateProperties() { - return privateProperties; - } - - public DataAddressDto getDataAddress() { - return dataAddress; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/AtomicConstraintDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/AtomicConstraintDto.java deleted file mode 100644 index 048f136..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/AtomicConstraintDto.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -/** - * DTO representation of an Atomic Constraint. - */ -public final class AtomicConstraintDto extends Typed { - private String operator; - private String rightOperand; - private String leftOperand; - - public AtomicConstraintDto() { - super("AtomicConstraint"); - } - - public AtomicConstraintDto(String leftOperand, String operator, String rightOperand) { - super("AtomicConstraint"); - this.leftOperand = leftOperand; - this.operator = operator; - this.rightOperand = rightOperand; - } - - public String getLeftOperand() { - return leftOperand; - } - - public String getOperator() { - return operator; - } - - public String getRightOperand() { - return rightOperand; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/CelExpressionDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/CelExpressionDto.java deleted file mode 100644 index 02d0261..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/CelExpressionDto.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Set; - -/** - * DTO representation of a CEL Expression. - */ -public final class CelExpressionDto extends Typed { - @JsonProperty("@id") - @JsonInclude(JsonInclude.Include.NON_NULL) - private final String id; - private final String leftOperand; - private final String expression; - private final Set scopes; - private final String description; - - public CelExpressionDto(String id, - String leftOperand, - String expression, - Set scopes, - String description) { - super("CelExpression"); - this.id = id; - this.leftOperand = leftOperand; - this.expression = expression; - this.scopes = scopes; - this.description = description; - } - - public CelExpressionDto(String leftOperand, String expression, String description) { - this(null, leftOperand, expression, Set.of(), description); - } - - public CelExpressionDto(String leftOperand, String expression, Set scopes, String description) { - this(null, leftOperand, expression, scopes, description); - } - - public String getId() { - return id; - } - - public String getLeftOperand() { - return leftOperand; - } - - public String getExpression() { - return expression; - } - - public Set getScopes() { - return scopes; - } - - public String getDescription() { - return description; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ContractDefinitionDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ContractDefinitionDto.java deleted file mode 100644 index 11bc6e2..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ContractDefinitionDto.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; - -/** - * DTO representation of a Contract Definition. - */ -public final class ContractDefinitionDto extends Typed { - @JsonProperty("@id") - @JsonInclude(JsonInclude.Include.NON_NULL) - private final String id; - private final String accessPolicyId; - private final String contractPolicyId; - private final List assetsSelector; - private final Map privateProperties; - - public ContractDefinitionDto(String id, - String accessPolicyId, String contractPolicyId, List assetsSelector, - Map privateProperties) { - super("ContractDefinition"); - this.id = id; - this.accessPolicyId = accessPolicyId; - this.contractPolicyId = contractPolicyId; - this.assetsSelector = assetsSelector; - this.privateProperties = privateProperties; - } - - public ContractDefinitionDto(String accessPolicyId, String contractPolicyId, List assetsSelector) { - this(null, accessPolicyId, contractPolicyId, assetsSelector, Map.of()); - } - - public String getId() { - return id; - } - - public String getAccessPolicyId() { - return accessPolicyId; - } - - public String getContractPolicyId() { - return contractPolicyId; - } - - public List getAssetsSelector() { - return assetsSelector; - } - - public Map getPrivateProperties() { - return privateProperties; - } -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ContractNegotiationDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ContractNegotiationDto.java deleted file mode 100644 index ce85d7f..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ContractNegotiationDto.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -/** - * DTO representation of a Contract Negotiation. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public final class ContractNegotiationDto extends Typed { - private String state; - private String contractAgreementId; - private String errorDetail; - private Map privateProperties; - @JsonProperty("@id") - private String id; - - public ContractNegotiationDto() { - super("ContractNegotiation"); - } - - public ContractNegotiationDto(String id, - String state, - String contractAgreementId, - String errorDetail, - Map privateProperties) { - super("ContractNegotiation"); - this.id = id; - this.state = state; - this.contractAgreementId = contractAgreementId; - this.errorDetail = errorDetail; - this.privateProperties = privateProperties; - } - - @Override - public String getJsonLdType() { - return "ContractNegotiation"; - } - - public String getId() { - return id; - } - - public String getState() { - return state; - } - - public String getContractAgreementId() { - return contractAgreementId; - } - - public String getErrorDetail() { - return errorDetail; - } - - public Map getPrivateProperties() { - return privateProperties; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ContractRequestDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ContractRequestDto.java deleted file mode 100644 index 6466d05..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ContractRequestDto.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * DTO representation of a Contract Request. - */ -public final class ContractRequestDto extends Typed { - - @JsonProperty("@id") - @JsonInclude(JsonInclude.Include.NON_NULL) - private final String id; - private final String protocol; - private final String counterPartyAddress; - private final String counterPartyId; - private final OfferDto policy; - - public ContractRequestDto(String id, - String protocol, - String counterPartyAddress, - String counterPartyId, - OfferDto policy) { - super("ContractRequest"); - this.id = id; - this.protocol = protocol; - this.counterPartyAddress = counterPartyAddress; - this.counterPartyId = counterPartyId; - this.policy = policy; - } - - public ContractRequestDto(String protocol, String counterPartyAddress, String counterPartyId, OfferDto policy) { - this(null, protocol, counterPartyAddress, counterPartyId, policy); - } - - public String getId() { - return id; - } - - public String getProtocol() { - return protocol; - } - - public String getCounterPartyAddress() { - return counterPartyAddress; - } - - public String getCounterPartyId() { - return counterPartyId; - } - - public OfferDto getPolicy() { - return policy; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/CriterionDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/CriterionDto.java deleted file mode 100644 index 7321514..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/CriterionDto.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -/** - * DTO representation of a Criterion. - */ -public final class CriterionDto extends Typed { - private final String operandLeft; - private final String operator; - private final Object operandRight; - - public CriterionDto(String operandLeft, String operator, Object operandRight) { - super("Criterion"); - this.operandLeft = operandLeft; - this.operator = operator; - this.operandRight = operandRight; - } - - - public String getOperandLeft() { - return operandLeft; - } - - public String getOperator() { - return operator; - } - - public Object getOperandRight() { - return operandRight; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/DataAddressDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/DataAddressDto.java deleted file mode 100644 index d77567b..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/DataAddressDto.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonUnwrapped; - -import java.util.Map; - -/** - * DTO representation of a Data Address. - */ -public final class DataAddressDto extends Typed { - private final String type; - @JsonUnwrapped - private final Map properties; - - public DataAddressDto(String type, Map properties) { - super("DataAddress"); - this.type = type; - this.properties = properties; - } - - public DataAddressDto(String type) { - this(type, Map.of()); - } - - public String getType() { - return type; - } - - @JsonUnwrapped - public Map getProperties() { - return properties; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/DatasetDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/DatasetDto.java deleted file mode 100644 index ee361dc..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/DatasetDto.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * DTO representation of a Dataset. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public final class DatasetDto extends Typed { - - @JsonProperty("hasPolicy") - private List offers; - @JsonProperty("@id") - private String id; - - - public DatasetDto() { - super("Dataset"); - } - - public DatasetDto(String id, - List offers) { - super("Dataset"); - this.id = id; - this.offers = offers; - } - - public String id() { - return id; - } - - public List offers() { - return offers; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/DatasetRequestDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/DatasetRequestDto.java deleted file mode 100644 index 13c7c43..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/DatasetRequestDto.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * DTO representation of a Dataset Request. - */ -public final class DatasetRequestDto extends Typed { - @JsonProperty("@id") - private final String id; - private final String protocol; - private final String counterPartyAddress; - private final String counterPartyId; - - public DatasetRequestDto(@JsonProperty("@id") String id, - String protocol, - String counterPartyAddress, - String counterPartyId) { - super("DatasetRequest"); - this.id = id; - this.protocol = protocol; - this.counterPartyAddress = counterPartyAddress; - this.counterPartyId = counterPartyId; - } - - @JsonProperty("@id") - public String getId() { - return id; - } - - public String getProtocol() { - return protocol; - } - - public String getCounterPartyAddress() { - return counterPartyAddress; - } - - public String getCounterPartyId() { - return counterPartyId; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/OfferDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/OfferDto.java deleted file mode 100644 index a1bcca2..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/OfferDto.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * DTO representation of an Offer. - */ -public final class OfferDto extends PolicyDto { - - @JsonProperty("@id") - private String id; - - public OfferDto() { - super("Offer"); - } - - public OfferDto(String id) { - super("Offer"); - this.id = id; - } - - public OfferDto(String id, String assigner, - String target, - List permissions) { - super("Offer", assigner, target, permissions); - this.id = id; - } - - - @JsonProperty("@id") - public String getId() { - return id; - } - - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ParticipantContextConfigDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ParticipantContextConfigDto.java deleted file mode 100644 index 3d946ba..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ParticipantContextConfigDto.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import java.util.Map; - -/** - * DTO representation of a Participant Context Config. - */ -public final class ParticipantContextConfigDto extends Typed { - private final Map entries; - private final Map privateEntries; - - public ParticipantContextConfigDto(Map entries, - Map privateEntries) { - super("ParticipantContextConfig"); - this.entries = entries; - this.privateEntries = privateEntries; - } - - public ParticipantContextConfigDto(Map entries) { - this(entries, Map.of()); - } - - public Map getEntries() { - return entries; - } - - public Map getPrivateEntries() { - return privateEntries; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ParticipantContextDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ParticipantContextDto.java deleted file mode 100644 index 3c4020e..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/ParticipantContextDto.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -/** - * DTO representation of a Participant Context. - */ -public final class ParticipantContextDto extends Typed { - @JsonProperty("@id") - private final String id; - private final String identity; - @JsonInclude(JsonInclude.Include.NON_NULL) - private final String state; - private final Map properties; - - public ParticipantContextDto(String id, String identity, - String state, - Map properties) { - super("ParticipantContext"); - this.id = id; - this.identity = identity; - this.state = state; - this.properties = properties; - } - - public ParticipantContextDto(String participantContextId, String identity) { - this(participantContextId, identity, null, Map.of()); - } - - @JsonProperty("@id") - public String getId() { - return id; - } - - public String getIdentity() { - return identity; - } - - @JsonInclude(JsonInclude.Include.NON_NULL) - public String getState() { - return state; - } - - public Map getProperties() { - return properties; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/PermissionDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/PermissionDto.java deleted file mode 100644 index c736381..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/PermissionDto.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * DTO representation of a Permission. - */ -public final class PermissionDto extends Typed { - private final String action; - @JsonProperty("constraint") - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private final List constraints; - - public PermissionDto(String action, List constraints) { - super("Permission"); - this.action = action; - this.constraints = constraints; - } - - public PermissionDto() { - this("use", List.of()); - } - - public PermissionDto(AtomicConstraintDto constraint) { - this("use", List.of(constraint)); - } - - public String getAction() { - return action; - } - - public List getConstraints() { - return constraints; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/PolicyDefinitionDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/PolicyDefinitionDto.java deleted file mode 100644 index c38eaa9..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/PolicyDefinitionDto.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * DTO representation of a Policy Definition. - */ -public final class PolicyDefinitionDto extends Typed { - @JsonProperty("@id") - @JsonInclude(JsonInclude.Include.NON_NULL) - private final String id; - private final PolicyDto policy; - - public PolicyDefinitionDto(String id, - PolicyDto policy) { - super("PolicyDefinition"); - this.id = id; - this.policy = policy; - } - - public PolicyDefinitionDto(PolicyDto policy) { - this(null, policy); - } - - @JsonProperty("@id") - @JsonInclude(JsonInclude.Include.NON_NULL) - public String getId() { - return id; - } - - public PolicyDto getPolicy() { - return policy; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/PolicyDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/PolicyDto.java deleted file mode 100644 index 40edbd1..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/PolicyDto.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * DTO representation of a Policy. - */ -public class PolicyDto extends Typed { - @JsonInclude(JsonInclude.Include.NON_NULL) - private final String assigner; - @JsonInclude(JsonInclude.Include.NON_NULL) - private final String target; - @JsonProperty("permission") - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private final List permissions; - - public PolicyDto(String type, - String assigner, - String target, - List permissions) { - super(type); - this.assigner = assigner; - this.target = target; - this.permissions = permissions; - } - - public PolicyDto() { - this("Set", null, null, List.of()); - } - - public PolicyDto(String type) { - this(type, null, null, List.of()); - } - - public PolicyDto(List permissions) { - this("Set", null, null, permissions); - } - - public String getAssigner() { - return assigner; - } - - public String getTarget() { - return target; - } - - public List getPermissions() { - return permissions; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/QuerySpectDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/QuerySpectDto.java deleted file mode 100644 index cd72b63..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/QuerySpectDto.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import java.util.List; - -/** - * DTO representation of a QuerySpec. - */ -public final class QuerySpectDto extends Typed { - private final List filterExpression; - - public QuerySpectDto(List filterExpression) { - super("QuerySpec"); - this.filterExpression = filterExpression; - } - - - public List filterExpression() { - return filterExpression; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/SuspendTransferDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/SuspendTransferDto.java deleted file mode 100644 index 657873a..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/SuspendTransferDto.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - * DTO representation of a Suspend Transfer request. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public final class SuspendTransferDto extends Typed { - - private final String reason; - - public SuspendTransferDto(String reason) { - super("SuspendTransfer"); - this.reason = reason; - } - - public String getReason() { - return reason; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/TerminateTransferDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/TerminateTransferDto.java deleted file mode 100644 index e90e897..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/TerminateTransferDto.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - * DTO representation of a Terminate Transfer request. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public final class TerminateTransferDto extends Typed { - - private final String reason; - - public TerminateTransferDto(String reason) { - super("TerminateTransfer"); - this.reason = reason; - } - - public String getReason() { - return reason; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/TransferProcessDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/TransferProcessDto.java deleted file mode 100644 index 7b3a12b..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/TransferProcessDto.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -/** - * DTO representation of a Transfer Process. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public final class TransferProcessDto extends Typed { - - private String state; - private String correlationId; - private String errorDetail; - private Map privateProperties; - @JsonProperty("@id") - private String id; - - public TransferProcessDto() { - super("TransferProcess"); - } - - public TransferProcessDto(String id, - String state, - String correlationId, - String errorDetail, - Map privateProperties) { - super("TransferProcess"); - this.id = id; - this.state = state; - this.correlationId = correlationId; - this.errorDetail = errorDetail; - this.privateProperties = privateProperties; - } - - @JsonProperty("@id") - public String getId() { - return id; - } - - public String getState() { - return state; - } - - public String getCorrelationId() { - return correlationId; - } - - public String getErrorDetail() { - return errorDetail; - } - - public Map getPrivateProperties() { - return privateProperties; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/TransferRequestDto.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/TransferRequestDto.java deleted file mode 100644 index d1914b5..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/TransferRequestDto.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * DTO representation of a Transfer Request. - */ -public final class TransferRequestDto extends Typed { - @JsonProperty("@id") - @JsonInclude(JsonInclude.Include.NON_NULL) - private final String id; - private final String protocol; - private final String counterPartyAddress; - private final String transferType; - private final String contractId; - - public TransferRequestDto(String id, - String protocol, - String counterPartyAddress, - String transferType, - String contractId) { - super("TransferRequest"); - this.id = id; - this.protocol = protocol; - this.counterPartyAddress = counterPartyAddress; - this.transferType = transferType; - this.contractId = contractId; - } - - public TransferRequestDto(String protocol, String counterPartyAddress, String transferType, String contractId) { - this(null, protocol, counterPartyAddress, transferType, contractId); - } - - - @JsonProperty("@id") - @JsonInclude(JsonInclude.Include.NON_NULL) - public String getId() { - return id; - } - - public String getProtocol() { - return protocol; - } - - public String getCounterPartyAddress() { - return counterPartyAddress; - } - - public String getTransferType() { - return transferType; - } - - public String getContractId() { - return contractId; - } - -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/Typed.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/Typed.java deleted file mode 100644 index 3135bd3..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/Typed.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public abstract class Typed { - - private final String jsonLdType; - - public Typed(String jsonLdType) { - this.jsonLdType = jsonLdType; - } - - @JsonProperty("@type") - public String getJsonLdType() { - return jsonLdType; - } -} diff --git a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/WithContext.java b/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/WithContext.java deleted file mode 100644 index 406879f..0000000 --- a/system-tests/runtime-tests/src/test/java/org/eclipse/edc/virtual/transfer/fixtures/api/model/WithContext.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtual.transfer.fixtures.api.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonUnwrapped; - -import java.util.List; - -import static org.eclipse.edc.spi.constants.CoreConstants.EDC_CONNECTOR_MANAGEMENT_CONTEXT_V2; - -/** - * Wrapper to add JSON-LD @context to any Typed entity. - */ -public record WithContext(@JsonUnwrapped T entity, @JsonProperty("@context") List context) { - public WithContext(T entity) { - this(entity, List.of(EDC_CONNECTOR_MANAGEMENT_CONTEXT_V2)); - } -}