) (Map) props).build();
}
-
- private String getProtocolEndpoint(ConnectorRemote connector) {
- return connector.getConfig().getProtocolEndpoint().getUri().toString();
- }
}
diff --git a/tests/src/test/java/de/sovity/edc/e2e/UseCaseApiWrapperTest.java b/tests/src/test/java/de/sovity/edc/e2e/UseCaseApiWrapperTest.java
index a32f56217..2e8fa6630 100644
--- a/tests/src/test/java/de/sovity/edc/e2e/UseCaseApiWrapperTest.java
+++ b/tests/src/test/java/de/sovity/edc/e2e/UseCaseApiWrapperTest.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.e2e;
@@ -36,82 +37,47 @@
import de.sovity.edc.client.gen.model.UiPolicyLiteralType;
import de.sovity.edc.extension.e2e.connector.ConnectorRemote;
import de.sovity.edc.extension.e2e.connector.MockDataAddressRemote;
-import de.sovity.edc.extension.e2e.db.TestDatabase;
-import de.sovity.edc.extension.e2e.db.TestDatabaseViaTestcontainers;
+import de.sovity.edc.extension.e2e.extension.Consumer;
+import de.sovity.edc.extension.e2e.extension.E2eTestExtension;
+import de.sovity.edc.extension.e2e.extension.Provider;
import de.sovity.edc.extension.utils.junit.DisabledOnGithub;
import de.sovity.edc.utils.jsonld.vocab.Prop;
-import org.eclipse.edc.junit.extensions.EdcExtension;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.extension.ExtendWith;
import java.time.OffsetDateTime;
import java.util.List;
-import static de.sovity.edc.extension.e2e.connector.config.ConnectorConfigFactory.forTestDatabase;
-import static de.sovity.edc.extension.e2e.connector.config.ConnectorRemoteConfigFactory.fromConnectorConfig;
import static org.assertj.core.api.Assertions.assertThat;
+@ExtendWith(E2eTestExtension.class)
class UseCaseApiWrapperTest {
- private static final String PROVIDER_PARTICIPANT_ID = "provider";
- private static final String CONSUMER_PARTICIPANT_ID = "consumer";
-
- @RegisterExtension
- static EdcExtension providerEdcContext = new EdcExtension();
- @RegisterExtension
- static EdcExtension consumerEdcContext = new EdcExtension();
-
- @RegisterExtension
- static final TestDatabase PROVIDER_DATABASE = new TestDatabaseViaTestcontainers();
- @RegisterExtension
- static final TestDatabase CONSUMER_DATABASE = new TestDatabaseViaTestcontainers();
-
- private ConnectorRemote providerConnector;
- private ConnectorRemote consumerConnector;
-
- private EdcClient providerClient;
- private EdcClient consumerClient;
private MockDataAddressRemote dataAddress;
private final String dataOfferData = "expected data 123";
private final String dataOfferId = "my-data-offer-2023-11";
@BeforeEach
- void setup() {
- // set up provider EDC + Client
- var providerConfig = forTestDatabase(PROVIDER_PARTICIPANT_ID, 21000, PROVIDER_DATABASE);
- providerEdcContext.setConfiguration(providerConfig.getProperties());
- providerConnector = new ConnectorRemote(fromConnectorConfig(providerConfig));
-
- providerClient = EdcClient.builder()
- .managementApiUrl(providerConfig.getManagementEndpoint().getUri().toString())
- .managementApiKey(providerConfig.getProperties().get("edc.api.auth.key"))
- .build();
-
- // set up consumer EDC + Client
- var consumerConfig = forTestDatabase(CONSUMER_PARTICIPANT_ID, 23000, CONSUMER_DATABASE);
- consumerEdcContext.setConfiguration(consumerConfig.getProperties());
- consumerConnector = new ConnectorRemote(fromConnectorConfig(consumerConfig));
-
- consumerClient = EdcClient.builder()
- .managementApiUrl(consumerConfig.getManagementEndpoint().getUri().toString())
- .managementApiKey(consumerConfig.getProperties().get("edc.api.auth.key"))
- .build();
-
+ void setup(@Provider ConnectorRemote providerConnector) {
// We use the provider EDC as data sink / data source (it has the test-backend-controller extension)
dataAddress = new MockDataAddressRemote(providerConnector.getConfig().getDefaultEndpoint());
}
@DisabledOnGithub
@Test
- void catalog_filtering_by_like() {
+ void catalog_filtering_by_like(
+ @Consumer EdcClient consumerClient,
+ @Provider ConnectorRemote providerConnector,
+ @Provider EdcClient providerClient) {
+
// arrange
- createPolicy();
- createAsset();
- createContractDefinition();
+ createPolicy(providerClient);
+ createAsset(providerClient);
+ createContractDefinition(providerClient);
- var query = criterion(Prop.Edc.ID, CatalogFilterExpressionOperator.LIKE, "%data-offer%");
+ var query = criterion(providerConnector, Prop.Edc.ID, CatalogFilterExpressionOperator.LIKE, "%data-offer%");
// act
var dataOffers = consumerClient.useCaseApi().queryCatalog(query);
@@ -123,7 +89,12 @@ void catalog_filtering_by_like() {
}
- private CatalogQuery criterion(String leftOperand, CatalogFilterExpressionOperator operator, String rightOperand) {
+ private CatalogQuery criterion(
+ ConnectorRemote providerConnector,
+ String leftOperand,
+ CatalogFilterExpressionOperator operator,
+ String rightOperand) {
+
return CatalogQuery.builder()
.connectorEndpoint(getProtocolEndpoint(providerConnector))
.filterExpressions(
@@ -138,7 +109,7 @@ private CatalogQuery criterion(String leftOperand, CatalogFilterExpressionOperat
.build();
}
- private void createAsset() {
+ private void createAsset(EdcClient providerClient) {
var dataSource = UiDataSource.builder()
.type(DataSourceType.HTTP_DATA)
.httpData(UiDataSourceHttpData.builder()
@@ -160,7 +131,7 @@ private void createAsset() {
providerClient.uiApi().createAsset(asset);
}
- private void createPolicy() {
+ private void createPolicy(EdcClient providerClient) {
var afterYesterday = UiPolicyConstraint.builder()
.left("POLICY_EVALUATION_TIME")
.operator(OperatorDto.GT)
@@ -189,7 +160,7 @@ private void createPolicy() {
providerClient.uiApi().createPolicyDefinition(policyDefinition);
}
- private void createContractDefinition() {
+ private void createContractDefinition(EdcClient providerClient) {
var contractDefinition = ContractDefinitionRequest.builder()
.contractDefinitionId(dataOfferId)
.accessPolicyId(dataOfferId)
diff --git a/utils/catalog-parser/build.gradle.kts b/utils/catalog-parser/build.gradle.kts
index daf3707ce..dee5ebaf0 100644
--- a/utils/catalog-parser/build.gradle.kts
+++ b/utils/catalog-parser/build.gradle.kts
@@ -23,7 +23,6 @@ dependencies {
testCompileOnly(libs.lombok)
testImplementation(project(":utils:test-utils"))
testImplementation(libs.mockito.core)
- testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.junitJupiter)
testImplementation(libs.assertj.core)
testImplementation(libs.junit.api)
diff --git a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/DspCatalogService.java b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/DspCatalogService.java
index e9559cf2a..603bd2b27 100644
--- a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/DspCatalogService.java
+++ b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/DspCatalogService.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.utils.catalog;
diff --git a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/DspCatalogServiceException.java b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/DspCatalogServiceException.java
index 1d2a53dc0..7397afa15 100644
--- a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/DspCatalogServiceException.java
+++ b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/DspCatalogServiceException.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.utils.catalog;
diff --git a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/mapper/DspContractOfferUtils.java b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/mapper/DspContractOfferUtils.java
deleted file mode 100644
index 53ad296ff..000000000
--- a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/mapper/DspContractOfferUtils.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package de.sovity.edc.utils.catalog.mapper;
-
-import de.sovity.edc.utils.JsonUtils;
-import de.sovity.edc.utils.jsonld.JsonLdUtils;
-import de.sovity.edc.utils.jsonld.vocab.Prop;
-import jakarta.json.Json;
-import jakarta.json.JsonObject;
-import lombok.val;
-import org.eclipse.edc.connector.contract.spi.ContractId;
-import org.jetbrains.annotations.NotNull;
-
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Base64;
-
-public class DspContractOfferUtils {
-
- /**
- * /!\ Workaround
- *
- * The Eclipse EDC uses a new random UUID for each policy that it returns and in turn a new contract ID.
- * This Eclipse ID can't be used as such.
- * As a workaround, we must introduce our own ID.
- * For a first iteration, we will assume that the content of the policy remains the same (same content, same order)
- * and hash it to use it as a key.
- *
- * @param contract The contract to compute an ID from
- * @return A base64 string that can be used as an id for the {@code contract}
- */
- public static String buildStableId(JsonObject contract) {
- // NOTE: This doesn't enforce any property order and may cause trouble if the returned policy schema is not consistent.
- // Use canonical form if needed later.
- val noId = Json.createObjectBuilder(contract).remove(Prop.ID).build();
- val policyId = hash(noId);
-
- val currentId = ContractId.parseId(JsonLdUtils.string(contract, Prop.ID))
- .orElseThrow((failure) -> {
- throw new RuntimeException("Failed to parse the contract id: " + failure.getFailureDetail());
- });
-
- return currentId.definitionPart() + ":" + currentId.assetIdPart() + ":" + policyId;
- }
-
- @NotNull
- private static String hash(JsonObject noId) {
- val policyJsonString = JsonUtils.toJson(noId);
- val sha1 = sha1(policyJsonString);
- // encoding with base16 to make the hash readable to humans (similarly to how the random UUID would have been readable)
- val base16 = toBase16(sha1);
- return toBase64(base16);
- }
-
- @NotNull
- private static String toBase64(String string) {
- byte[] stringBytes = string.getBytes(StandardCharsets.UTF_8);
- byte[] bytes = Base64.getEncoder().encode(stringBytes);
- return new String(bytes);
- }
-
- @NotNull
- private static String toBase16(byte[] bytes) {
- val sb = new StringBuilder();
- for (byte b : bytes) {
- sb.append(Character.forDigit(b >> 4 & 0xf, 16));
- sb.append(Character.forDigit(b & 0xf, 16));
- }
- return sb.toString();
- }
-
- private static byte[] sha1(String string) {
- try {
- return MessageDigest.getInstance("sha-1").digest(string.getBytes());
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/mapper/DspDataOfferBuilder.java b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/mapper/DspDataOfferBuilder.java
index 02c0ec338..cf6444b84 100644
--- a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/mapper/DspDataOfferBuilder.java
+++ b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/mapper/DspDataOfferBuilder.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.utils.catalog.mapper;
diff --git a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspCatalog.java b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspCatalog.java
index e68bb07c5..0fdb5ef25 100644
--- a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspCatalog.java
+++ b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspCatalog.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.utils.catalog.model;
diff --git a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspContractOffer.java b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspContractOffer.java
index a5150fc00..4ac17020e 100644
--- a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspContractOffer.java
+++ b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspContractOffer.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.utils.catalog.model;
diff --git a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspDataOffer.java b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspDataOffer.java
index 278098e35..e18f661c1 100644
--- a/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspDataOffer.java
+++ b/utils/catalog-parser/src/main/java/de/sovity/edc/utils/catalog/model/DspDataOffer.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.utils.catalog.model;
diff --git a/utils/json-and-jsonld-utils/build.gradle.kts b/utils/json-and-jsonld-utils/build.gradle.kts
index d2ef943f4..18ed02190 100644
--- a/utils/json-and-jsonld-utils/build.gradle.kts
+++ b/utils/json-and-jsonld-utils/build.gradle.kts
@@ -18,7 +18,6 @@ dependencies {
testAnnotationProcessor(libs.lombok)
testCompileOnly(libs.lombok)
testImplementation(libs.mockito.core)
- testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.junitJupiter)
testImplementation(libs.assertj.core)
testImplementation(libs.junit.api)
diff --git a/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/JsonUtils.java b/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/JsonUtils.java
index 1a91ae7cf..95c22d044 100644
--- a/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/JsonUtils.java
+++ b/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/JsonUtils.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.utils;
diff --git a/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/jsonld/JsonLdUtils.java b/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/jsonld/JsonLdUtils.java
index ec44ecdad..f264949af 100644
--- a/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/jsonld/JsonLdUtils.java
+++ b/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/jsonld/JsonLdUtils.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.utils.jsonld;
diff --git a/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/jsonld/vocab/Prop.java b/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/jsonld/vocab/Prop.java
index ea04f5e43..4a057ddd2 100644
--- a/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/jsonld/vocab/Prop.java
+++ b/utils/json-and-jsonld-utils/src/main/java/de/sovity/edc/utils/jsonld/vocab/Prop.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.utils.jsonld.vocab;
diff --git a/utils/test-connector-remote/build.gradle.kts b/utils/test-connector-remote/build.gradle.kts
deleted file mode 100644
index a3d3d6474..000000000
--- a/utils/test-connector-remote/build.gradle.kts
+++ /dev/null
@@ -1,35 +0,0 @@
-
-plugins {
- `java-library`
-}
-
-dependencies {
- annotationProcessor(libs.lombok)
- compileOnly(libs.lombok)
-
- api(libs.junit.api)
- implementation(libs.apache.commonsLang)
-
- api(libs.edc.junit)
- api(libs.awaitility.java)
- api(project(":utils:json-and-jsonld-utils"))
- implementation(project(":utils:versions"))
- implementation(libs.edc.sqlCore)
- implementation(libs.edc.jsonLdSpi)
- implementation(libs.edc.jsonLd)
- implementation(libs.assertj.core)
- implementation(libs.testcontainers.testcontainers)
- implementation(libs.testcontainers.junitJupiter)
- implementation(libs.testcontainers.postgresql)
- implementation(libs.restAssured.restAssured)
-}
-
-group = libs.versions.sovityEdcExtensionGroup.get()
-
-publishing {
- publications {
- create(project.name) {
- from(components["java"])
- }
- }
-}
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionWithTestDatabase.java b/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionWithTestDatabase.java
deleted file mode 100644
index af15b7822..000000000
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionWithTestDatabase.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package de.sovity.edc.extension.e2e.db;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import lombok.experimental.Delegate;
-import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ParameterResolver;
-
-import java.util.Map;
-import java.util.function.Function;
-
-@RequiredArgsConstructor
-public class EdcRuntimeExtensionWithTestDatabase
- implements BeforeAllCallback, AfterAllCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback, ParameterResolver {
-
- private final String moduleName;
- private final String logPrefix;
-
- @Getter
- @Delegate(types = {AfterAllCallback.class})
- private final TestDatabase testDatabase = new TestDatabaseViaTestcontainers();
-
- private final Function> propertyFactory;
-
- @Delegate(types = {
- BeforeTestExecutionCallback.class,
- AfterTestExecutionCallback.class,
- ParameterResolver.class
- })
- @Getter
- private EdcRuntimeExtensionFixed edcRuntimeExtension = null;
-
- @Override
- public void beforeAll(ExtensionContext extensionContext) throws Exception {
- testDatabase.beforeAll(extensionContext);
- edcRuntimeExtension = new EdcRuntimeExtensionFixed(moduleName, logPrefix, propertyFactory.apply(testDatabase));
- }
-}
diff --git a/utils/test-connector-remote/README.md b/utils/test-utils/README.md
similarity index 75%
rename from utils/test-connector-remote/README.md
rename to utils/test-utils/README.md
index 903aa7a09..fa298552d 100644
--- a/utils/test-connector-remote/README.md
+++ b/utils/test-utils/README.md
@@ -16,7 +16,11 @@
## About this Utility
-Connector Remote for creating simple test data via the management API.
+A toolset to ease testing.
+
+* Connector Remote for creating simple test data via the management API.
+* E2eTestExtension to bootstrap end-to-end tests using the wrapper API.
+* EdcRuntimeExtensionWithTestDatabase to test single connectors with a database.
## Why does this extension exist?
diff --git a/utils/test-utils/build.gradle.kts b/utils/test-utils/build.gradle.kts
index 5aae2ca05..e2d6e9038 100644
--- a/utils/test-utils/build.gradle.kts
+++ b/utils/test-utils/build.gradle.kts
@@ -4,7 +4,29 @@ plugins {
}
dependencies {
+ annotationProcessor(libs.lombok)
+ compileOnly(libs.lombok)
+
api(libs.junit.api)
+ implementation(libs.apache.commonsLang)
+
+ api(libs.edc.junit)
+ api(libs.awaitility.java)
+ api(project(":extensions:wrapper:clients:java-client"))
+ api(project(":utils:json-and-jsonld-utils"))
+
+ implementation(project(":extensions:policy-always-true"))
+ implementation(project(":utils:versions"))
+ implementation(libs.edc.jsonLdSpi)
+ implementation(libs.edc.jsonLd)
+ implementation(libs.edc.sqlCore)
+ implementation(libs.assertj.core)
+ implementation(libs.jooq.jooq)
+ implementation(libs.mockserver.netty)
+ implementation(libs.testcontainers.testcontainers)
+ implementation(libs.testcontainers.junitJupiter)
+ implementation(libs.testcontainers.postgresql)
+ implementation(libs.restAssured.restAssured)
}
group = libs.versions.sovityEdcExtensionGroup.get()
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/ConnectorRemote.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/ConnectorRemote.java
similarity index 95%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/ConnectorRemote.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/ConnectorRemote.java
index e85911e77..ddc180bad 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/ConnectorRemote.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/ConnectorRemote.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector;
@@ -34,7 +35,6 @@
import java.net.URI;
import java.time.Duration;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
@@ -56,8 +56,8 @@
@SuppressWarnings("java:S5960")
@RequiredArgsConstructor
public class ConnectorRemote {
- @Getter
+ @Getter
private final ConnectorRemoteConfig config;
private final ObjectMapper objectMapper = JacksonJsonLd.createObjectMapper();
@@ -84,22 +84,6 @@ public void createAsset(String assetId, Map dataAddressPropertie
.contentType(JSON);
}
- public List getAssetIds() {
- var requestBody = createObjectBuilder()
- .add(CONTEXT, createObjectBuilder().add(EDC_PREFIX, EDC_NAMESPACE))
- .add(TYPE, EDC_NAMESPACE + "QuerySpec")
- .build();
- return prepareManagementApiCall()
- .contentType(JSON)
- .body(requestBody)
- .when()
- .post("/v2/assets/request")
- .then()
- .statusCode(200)
- .contentType(JSON)
- .extract().jsonPath().getList("@id");
- }
-
public String createPolicy(JsonObject policyJsonObject) {
var requestBody = createObjectBuilder()
.add(CONTEXT, createObjectBuilder().add(EDC_PREFIX, EDC_NAMESPACE))
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/DataTransferTestUtil.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/DataTransferTestUtil.java
similarity index 98%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/DataTransferTestUtil.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/DataTransferTestUtil.java
index 88089a752..147debb37 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/DataTransferTestUtil.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/DataTransferTestUtil.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/MockDataAddressRemote.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/MockDataAddressRemote.java
similarity index 98%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/MockDataAddressRemote.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/MockDataAddressRemote.java
index e67af343b..00e68aeb0 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/MockDataAddressRemote.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/MockDataAddressRemote.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfig.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfig.java
similarity index 97%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfig.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfig.java
index ff34e619b..383ce8c93 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfig.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfig.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfigFactory.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfigFactory.java
similarity index 75%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfigFactory.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfigFactory.java
index a4e3d76a4..4608b9396 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfigFactory.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorConfigFactory.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config;
@@ -27,26 +28,12 @@
import static de.sovity.edc.extension.e2e.connector.config.DatasourceConfigUtils.configureDatasources;
import static de.sovity.edc.extension.e2e.connector.config.api.EdcApiConfigFactory.configureApi;
import static org.eclipse.edc.junit.testfixtures.TestUtils.MAX_TCP_PORT;
-import static org.eclipse.edc.junit.testfixtures.TestUtils.getFreePort;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ConnectorConfigFactory {
private static final Random RANDOM = new Random();
- /**
- * Creates the default configuration to start an EDC with the given test database.
- *
- * @deprecated Use {@link ConnectorConfigFactory#forTestDatabase(String, TestDatabase)}
- * with automatic ports allocation to prevent port allocation conflicts.
- */
- @Deprecated
- public static ConnectorConfig forTestDatabase(String participantId, int firstPort, TestDatabase testDatabase) {
- var config = basicEdcConfig(participantId, firstPort);
- config.setProperties(configureDatasources(testDatabase.getJdbcCredentials()));
- return config;
- }
-
public static ConnectorConfig forTestDatabase(String participantId, TestDatabase testDatabase) {
val firstPort = getFreePortRange(5);
var config = basicEdcConfig(participantId, firstPort);
@@ -56,16 +43,16 @@ public static ConnectorConfig forTestDatabase(String participantId, TestDatabase
public static synchronized int getFreePortRange(int size) {
// pick a random in a reasonable range
- int firstPort = getFreePort(RANDOM.nextInt(10_000, 50_000));
+ int firstPort = RANDOM.nextInt(10_000, 50_000);
int currentPort = firstPort;
do {
- if (canUsePort(currentPort + 1)) {
+ if (canUsePort(currentPort)) {
currentPort++;
} else {
- firstPort = getFreePort(currentPort++);
+ firstPort = currentPort++;
}
- } while (currentPort < firstPort + size);
+ } while (currentPort <= firstPort + size);
return firstPort;
}
@@ -98,6 +85,8 @@ public static ConnectorConfig basicEdcConfig(String participantId, int firstPort
properties.put("edc.last.commit.info", "test env commit message");
properties.put("edc.build.date", "2023-05-08T15:30:00Z");
+ properties.put("edc.server.db.connection.timeout.in.ms", "5000");
+
properties.put("my.edc.participant.id", participantId);
properties.put("my.edc.title", "Connector Title %s".formatted(participantId));
properties.put("my.edc.description", "Connector Description %s".formatted(participantId));
@@ -106,6 +95,17 @@ public static ConnectorConfig basicEdcConfig(String participantId, int firstPort
properties.put("my.edc.maintainer.url", "http://maintainer.%s".formatted(participantId));
properties.put("my.edc.maintainer.name", "Maintainer Name %s".formatted(participantId));
+ properties.put("edc.server.db.connection.pool.size", "3");
+
+ properties.put("web.http.port", String.valueOf(apiConfig.getDefaultApiGroup().port()));
+ properties.put("web.http.path", String.valueOf(apiConfig.getDefaultApiGroup().path()));
+ properties.put("web.http.protocol.port", String.valueOf(apiConfig.getProtocolApiGroup().port()));
+ properties.put("web.http.protocol.path", String.valueOf(apiConfig.getProtocolApiGroup().path()));
+ properties.put("web.http.management.port", String.valueOf(apiConfig.getManagementApiGroup().port()));
+ properties.put("web.http.management.path", String.valueOf(apiConfig.getManagementApiGroup().path()));
+ properties.put("web.http.control.port", String.valueOf(apiConfig.getControlApiGroup().port()));
+ properties.put("web.http.control.path", String.valueOf(apiConfig.getControlApiGroup().path()));
+
return new ConnectorConfig(
participantId,
apiConfig.getDefaultApiGroup(),
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfig.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfig.java
similarity index 96%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfig.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfig.java
index 69dbcf302..8577b1d92 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfig.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfig.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfigFactory.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfigFactory.java
similarity index 99%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfigFactory.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfigFactory.java
index 54f08c8fc..e3d9c4440 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfigFactory.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/ConnectorRemoteConfigFactory.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/DatasourceConfigUtils.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/DatasourceConfigUtils.java
similarity index 98%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/DatasourceConfigUtils.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/DatasourceConfigUtils.java
index fd1df4057..47b822453 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/DatasourceConfigUtils.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/DatasourceConfigUtils.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfig.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfig.java
similarity index 97%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfig.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfig.java
index d1cc4dd36..4aca4ef89 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfig.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfig.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config.api;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfigFactory.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfigFactory.java
similarity index 99%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfigFactory.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfigFactory.java
index 603172ea4..5f5f26302 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfigFactory.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiConfigFactory.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config.api;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroup.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroup.java
similarity index 97%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroup.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroup.java
index 3af481919..46bc7dcb6 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroup.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroup.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config.api;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroupConfig.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroupConfig.java
similarity index 96%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroupConfig.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroupConfig.java
index 78c610da5..af579097e 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroupConfig.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/EdcApiGroupConfig.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config.api;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/ApiKeyAuthProvider.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/ApiKeyAuthProvider.java
similarity index 95%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/ApiKeyAuthProvider.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/ApiKeyAuthProvider.java
index f747ed6e2..1b5919dfe 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/ApiKeyAuthProvider.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/ApiKeyAuthProvider.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config.api.auth;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/AuthProvider.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/AuthProvider.java
similarity index 93%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/AuthProvider.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/AuthProvider.java
index 35474d8a9..a2e11a921 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/AuthProvider.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/AuthProvider.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config.api.auth;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/NoneAuthProvider.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/NoneAuthProvider.java
similarity index 95%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/NoneAuthProvider.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/NoneAuthProvider.java
index 3181c9453..af59e7eb3 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/NoneAuthProvider.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/config/api/auth/NoneAuthProvider.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.connector.config.api.auth;
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionDeferred.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionDeferred.java
similarity index 100%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionDeferred.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionDeferred.java
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionFixed.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionFixed.java
similarity index 100%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionFixed.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionFixed.java
diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionWithTestDatabase.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionWithTestDatabase.java
new file mode 100644
index 000000000..868c3d89d
--- /dev/null
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/EdcRuntimeExtensionWithTestDatabase.java
@@ -0,0 +1,69 @@
+package de.sovity.edc.extension.e2e.db;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.experimental.Delegate;
+import lombok.val;
+import org.jooq.DSLContext;
+import org.jooq.impl.DSL;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+
+import java.util.Map;
+import java.util.function.Function;
+
+@RequiredArgsConstructor
+public class EdcRuntimeExtensionWithTestDatabase
+ implements BeforeAllCallback, AfterAllCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback, ParameterResolver {
+
+ private final String moduleName;
+ private final String logPrefix;
+
+ @Getter
+ @Delegate(types = {AfterAllCallback.class})
+ private final TestDatabase testDatabase = new TestDatabaseViaTestcontainers();
+
+ private final Function> propertyFactory;
+
+ @Delegate(types = {
+ BeforeTestExecutionCallback.class,
+ AfterTestExecutionCallback.class
+ })
+ @Getter
+ private EdcRuntimeExtensionFixed edcRuntimeExtension = null;
+
+ @Override
+ public void beforeAll(ExtensionContext extensionContext) throws Exception {
+ testDatabase.beforeAll(extensionContext);
+ edcRuntimeExtension = new EdcRuntimeExtensionFixed(moduleName, logPrefix, propertyFactory.apply(testDatabase));
+ }
+
+ @Override
+ public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
+ throws ParameterResolutionException {
+ boolean isJooqDsl = parameterContext.getParameter().getType().equals(DSLContext.class);
+ return isJooqDsl || edcRuntimeExtension.supportsParameter(parameterContext, extensionContext);
+ }
+
+ @Override
+ public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
+ throws ParameterResolutionException {
+ boolean isJooqDsl = parameterContext.getParameter().getType().equals(DSLContext.class);
+ if (isJooqDsl) {
+ return getDslContext().dsl();
+ } else {
+ return edcRuntimeExtension.resolveParameter(parameterContext, extensionContext);
+ }
+ }
+
+ private synchronized DSLContext getDslContext() {
+ val credentials = testDatabase.getJdbcCredentials();
+ return DSL.using(credentials.jdbcUrl(), credentials.jdbcUser(), credentials.jdbcPassword());
+ }
+}
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/JdbcCredentials.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/JdbcCredentials.java
similarity index 100%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/JdbcCredentials.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/JdbcCredentials.java
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabase.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabase.java
similarity index 100%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabase.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabase.java
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseFactory.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseFactory.java
similarity index 100%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseFactory.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseFactory.java
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseViaEnvVars.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseViaEnvVars.java
similarity index 100%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseViaEnvVars.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseViaEnvVars.java
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseViaTestcontainers.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseViaTestcontainers.java
similarity index 100%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseViaTestcontainers.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/db/TestDatabaseViaTestcontainers.java
diff --git a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/env/EnvUtil.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/env/EnvUtil.java
similarity index 97%
rename from utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/env/EnvUtil.java
rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/env/EnvUtil.java
index 1b1c1bd69..9a2cc713a 100644
--- a/utils/test-connector-remote/src/main/java/de/sovity/edc/extension/e2e/env/EnvUtil.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/env/EnvUtil.java
@@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
- * sovity GmbH - init
+ * sovity GmbH - init
+ *
*/
package de.sovity.edc.extension.e2e.env;
diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Consumer.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Consumer.java
new file mode 100644
index 000000000..cbd622765
--- /dev/null
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Consumer.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2024 sovity GmbH
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Contributors:
+ * sovity GmbH - initial API and implementation
+ *
+ */
+
+package de.sovity.edc.extension.e2e.extension;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * In test code, in conjunction with {@link E2eTestExtension}, specifies that the injected instance must come from the Consumer EDC
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Consumer {
+}
diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eScenario.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eScenario.java
new file mode 100644
index 000000000..a4bc6317d
--- /dev/null
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eScenario.java
@@ -0,0 +1,275 @@
+/*
+ * Copyright (c) 2024 sovity GmbH
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Contributors:
+ * sovity GmbH - initial API and implementation
+ *
+ */
+
+package de.sovity.edc.extension.e2e.extension;
+
+import de.sovity.edc.client.EdcClient;
+import de.sovity.edc.client.gen.model.ContractDefinitionRequest;
+import de.sovity.edc.client.gen.model.ContractNegotiationRequest;
+import de.sovity.edc.client.gen.model.ContractNegotiationSimplifiedState;
+import de.sovity.edc.client.gen.model.ContractTerminationRequest;
+import de.sovity.edc.client.gen.model.DataSourceType;
+import de.sovity.edc.client.gen.model.IdResponseDto;
+import de.sovity.edc.client.gen.model.InitiateCustomTransferRequest;
+import de.sovity.edc.client.gen.model.InitiateTransferRequest;
+import de.sovity.edc.client.gen.model.OperatorDto;
+import de.sovity.edc.client.gen.model.PolicyDefinitionCreateRequest;
+import de.sovity.edc.client.gen.model.UiAssetCreateRequest;
+import de.sovity.edc.client.gen.model.UiContractNegotiation;
+import de.sovity.edc.client.gen.model.UiCriterion;
+import de.sovity.edc.client.gen.model.UiCriterionLiteral;
+import de.sovity.edc.client.gen.model.UiCriterionLiteralType;
+import de.sovity.edc.client.gen.model.UiCriterionOperator;
+import de.sovity.edc.client.gen.model.UiDataSource;
+import de.sovity.edc.client.gen.model.UiDataSourceHttpData;
+import de.sovity.edc.client.gen.model.UiPolicyConstraint;
+import de.sovity.edc.client.gen.model.UiPolicyCreateRequest;
+import de.sovity.edc.client.gen.model.UiPolicyLiteral;
+import de.sovity.edc.client.gen.model.UiPolicyLiteralType;
+import de.sovity.edc.extension.e2e.connector.config.ConnectorConfig;
+import de.sovity.edc.utils.jsonld.vocab.Prop;
+import lombok.val;
+import org.awaitility.Awaitility;
+import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation;
+import org.mockserver.integration.ClientAndServer;
+import org.mockserver.model.HttpRequest;
+import org.mockserver.model.HttpResponse;
+
+import java.time.Duration;
+import java.time.OffsetDateTime;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static de.sovity.edc.client.gen.model.TransferProcessSimplifiedState.RUNNING;
+import static de.sovity.edc.extension.policy.AlwaysTruePolicyConstants.POLICY_DEFINITION_ID;
+import static java.time.Duration.ofSeconds;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class E2eScenario {
+ private final ConnectorConfig consumerConfig;
+ private final ConnectorConfig providerConfig;
+ private final ClientAndServer mockServer;
+ private final Duration timeout = ofSeconds(10);
+
+ private EdcClient consumerClient;
+ private EdcClient providerClient;
+
+ public E2eScenario(ConnectorConfig consumerConfig, ConnectorConfig providerConfig, ClientAndServer mockServer) {
+ this.consumerConfig = consumerConfig;
+ this.providerConfig = providerConfig;
+ this.mockServer = mockServer;
+
+ consumerClient = EdcClient.builder()
+ .managementApiUrl(consumerConfig.getManagementEndpoint().getUri().toString())
+ .managementApiKey(consumerConfig.getProperties().get("edc.api.auth.key"))
+ .build();
+
+ providerClient = EdcClient.builder()
+ .managementApiUrl(providerConfig.getManagementEndpoint().getUri().toString())
+ .managementApiKey(providerConfig.getProperties().get("edc.api.auth.key"))
+ .build();
+ }
+
+ private final String alwaysTruePolicyId = POLICY_DEFINITION_ID;
+
+ private final AtomicInteger assetCounter = new AtomicInteger(0);
+
+ public String createAsset() {
+ val dummyDataSource = UiDataSource.builder()
+ .type(DataSourceType.HTTP_DATA)
+ .httpData(UiDataSourceHttpData.builder()
+ .baseUrl("http://example.com")
+ .build())
+ .build();
+
+ return internalCreateAsset("asset-" + assetCounter.getAndIncrement(), dummyDataSource).getId();
+ }
+
+ public String createAsset(String id, UiDataSourceHttpData uiDataSourceHttpData) {
+ val uiDataSource = UiDataSource.builder()
+ .type(DataSourceType.HTTP_DATA)
+ .httpData(uiDataSourceHttpData)
+ .build();
+
+ return internalCreateAsset(id, uiDataSource).getId();
+ }
+
+ public MockedAsset createAssetWithMockResource(String id) {
+
+ val path = "/assets/" + id;
+ val url = "http://localhost:" + mockServer.getPort() + path;
+
+ val uiDataSource = UiDataSource.builder()
+ .type(DataSourceType.HTTP_DATA)
+ .httpData(UiDataSourceHttpData.builder().baseUrl(url).build())
+ .build();
+
+ val accesses = new AtomicInteger(0);
+
+ mockServer.when(HttpRequest.request(path).withMethod("GET")).respond(it -> {
+ accesses.incrementAndGet();
+ return HttpResponse.response().withStatusCode(200);
+ });
+
+ internalCreateAsset(id, uiDataSource);
+
+ return new MockedAsset(id, accesses);
+ }
+
+ private IdResponseDto internalCreateAsset(String assetId, UiDataSource dataSource) {
+ return providerClient.uiApi()
+ .createAsset(UiAssetCreateRequest.builder()
+ .id(assetId)
+ .title("AssetName " + assetId)
+ .version("1.0.0")
+ .language("en")
+ .dataSource(dataSource)
+ .build());
+ }
+
+ public String createPolicyDefinition(String policyId, UiPolicyConstraint... constraints) {
+ return createPolicyDefinition(policyId, Arrays.stream(constraints).toList()).getId();
+ }
+
+ private IdResponseDto createPolicyDefinition(String policyId, List constraints) {
+ var policyDefinition = PolicyDefinitionCreateRequest.builder()
+ .policyDefinitionId(policyId)
+ .policy(UiPolicyCreateRequest.builder()
+ .constraints(constraints)
+ .build()
+ )
+ .build();
+
+ return providerClient.uiApi().createPolicyDefinition(policyDefinition);
+ }
+
+ public String createContractDefinition(String assetId) {
+ return createContractDefinition(POLICY_DEFINITION_ID, assetId).getId();
+ }
+
+ public IdResponseDto createContractDefinition(String policyId, String assetId) {
+ return providerClient.uiApi().createContractDefinition(ContractDefinitionRequest.builder()
+ .contractDefinitionId("cd-" + policyId + "-" + assetId)
+ .accessPolicyId(policyId)
+ .contractPolicyId(policyId)
+ .assetSelector(List.of(UiCriterion.builder()
+ .operandLeft(Prop.Edc.ID)
+ .operator(UiCriterionOperator.EQ)
+ .operandRight(UiCriterionLiteral.builder()
+ .type(UiCriterionLiteralType.VALUE)
+ .value(assetId)
+ .build())
+ .build()))
+ .build());
+ }
+
+ public UiContractNegotiation negotiateAssetAndAwait(String assetId) {
+ val connectorEndpoint = providerConfig.getProtocolEndpoint().getUri().toString();
+ val offers = consumerClient.uiApi().getCatalogPageDataOffers(connectorEndpoint);
+
+ val offersContainingContract = offers.stream()
+ .filter(offer -> offer.getAsset().getAssetId().equals(assetId))
+ .toList();
+
+ assertThat(offersContainingContract).hasSize(1);
+
+ val firstContractOffer = offersContainingContract.get(0).getContractOffers().get(0);
+ val dataOffer = offersContainingContract.get(0);
+ var negotiationRequest = ContractNegotiationRequest.builder()
+ .counterPartyAddress(dataOffer.getEndpoint())
+ .counterPartyParticipantId(dataOffer.getParticipantId())
+ .assetId(dataOffer.getAsset().getAssetId())
+ .contractOfferId(firstContractOffer.getContractOfferId())
+ .policyJsonLd(firstContractOffer.getPolicy().getPolicyJsonLd())
+ .build();
+
+ val negotiation = consumerClient.uiApi().initiateContractNegotiation(negotiationRequest);
+
+ val neg = Awaitility.await().atMost(timeout).until(
+ () -> consumerClient.uiApi().getContractNegotiation(negotiation.getContractNegotiationId()),
+ it -> it.getState().getSimplifiedState() != ContractNegotiationSimplifiedState.IN_PROGRESS
+ );
+
+ assertThat(neg.getState().getSimplifiedState()).isEqualTo(ContractNegotiationSimplifiedState.AGREED);
+
+ return neg;
+ }
+
+ public void createPolicy(String id, OffsetDateTime from, OffsetDateTime until) {
+ val startConstraint = UiPolicyConstraint.builder()
+ .left("POLICY_EVALUATION_TIME")
+ .operator(OperatorDto.GT)
+ .right(UiPolicyLiteral.builder()
+ .type(UiPolicyLiteralType.STRING)
+ .value(from.toString())
+ .build())
+ .build();
+
+ val endConstraint = UiPolicyConstraint.builder()
+ .left("POLICY_EVALUATION_TIME")
+ .operator(OperatorDto.LT)
+ .right(UiPolicyLiteral.builder()
+ .type(UiPolicyLiteralType.STRING)
+ .value(until.toString())
+ .build())
+ .build();
+
+ var policyDefinition = PolicyDefinitionCreateRequest.builder()
+ .policyDefinitionId(id)
+ .policy(UiPolicyCreateRequest.builder()
+ .constraints(List.of(startConstraint, endConstraint))
+ .build())
+ .build();
+
+ providerClient.uiApi().createPolicyDefinition(policyDefinition);
+ }
+
+ public String transferAndAwait(InitiateTransferRequest transferRequest) {
+ val transferInit = consumerClient.uiApi().initiateTransfer(transferRequest).getId();
+ awaitTransferCompletion(transferInit);
+ return transferInit;
+ }
+
+ public String transferAndAwait(InitiateCustomTransferRequest transferRequest) {
+ val transferInit = consumerClient.uiApi().initiateCustomTransfer(transferRequest).getId();
+ awaitTransferCompletion(transferInit);
+ return transferInit;
+ }
+
+ public void awaitTransferCompletion(String transferId) {
+ Awaitility.await().atMost(timeout).until(
+ () -> consumerClient.uiApi()
+ .getTransferHistoryPage()
+ .getTransferEntries()
+ .stream()
+ .filter(it -> it.getTransferProcessId().equals(transferId))
+ .findFirst()
+ .map(it -> it.getState().getSimplifiedState()),
+ it -> it.orElse(RUNNING) != RUNNING
+ );
+ }
+
+ public IdResponseDto terminateContractAgreementAndAwait(
+ ContractNegotiation.Type party,
+ String contractAgreementId,
+ ContractTerminationRequest terminationRequest
+ ) {
+ if (party.equals(ContractNegotiation.Type.CONSUMER)) {
+ return consumerClient.uiApi().terminateContractAgreement(contractAgreementId, terminationRequest);
+ } else {
+ return providerClient.uiApi().terminateContractAgreement(contractAgreementId, terminationRequest);
+ }
+ }
+}
diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java
new file mode 100644
index 000000000..ddbd592ae
--- /dev/null
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2024 sovity GmbH
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Contributors:
+ * sovity GmbH - initial API and implementation
+ *
+ */
+
+package de.sovity.edc.extension.e2e.extension;
+
+import de.sovity.edc.client.EdcClient;
+import de.sovity.edc.extension.e2e.connector.ConnectorRemote;
+import de.sovity.edc.extension.e2e.connector.config.ConnectorConfig;
+import de.sovity.edc.extension.e2e.connector.config.ConnectorRemoteConfig;
+import de.sovity.edc.extension.e2e.db.EdcRuntimeExtensionWithTestDatabase;
+import de.sovity.edc.extension.utils.Lazy;
+import lombok.val;
+import org.jetbrains.annotations.NotNull;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+import org.mockserver.integration.ClientAndServer;
+
+import java.util.List;
+import java.util.stream.Stream;
+
+import static de.sovity.edc.extension.e2e.connector.config.ConnectorConfigFactory.forTestDatabase;
+import static org.eclipse.edc.junit.testfixtures.TestUtils.getFreePort;
+import static org.mockserver.stop.Stop.stopQuietly;
+
+public class E2eTestExtension
+ implements BeforeAllCallback, AfterAllCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback, ParameterResolver {
+
+ private final String consumerParticipantId;
+ private ConnectorConfig consumerConfig;
+ private final EdcRuntimeExtensionWithTestDatabase consumerExtension;
+
+ private final String providerParticipantId;
+ private ConnectorConfig providerConfig;
+ private final EdcRuntimeExtensionWithTestDatabase providerExtension;
+
+ private final List> partySupportedTypes = List.of(ConnectorConfig.class, EdcClient.class, ConnectorRemote.class, ClientAndServer.class);
+ private final List> supportedTypes = Stream.concat(partySupportedTypes.stream(), Stream.of(E2eScenario.class)).toList();
+
+ private Lazy clientAndServer;
+
+ public E2eTestExtension() {
+ this("consumer", "provider");
+ }
+
+ public E2eTestExtension(String consumerParticipantId, String providerParticipantId) {
+ this.consumerParticipantId = consumerParticipantId;
+ this.providerParticipantId = providerParticipantId;
+
+ consumerExtension = new EdcRuntimeExtensionWithTestDatabase(
+ ":launchers:connectors:sovity-dev",
+ "consumer",
+ testDatabase -> {
+ consumerConfig = forTestDatabase(this.consumerParticipantId, testDatabase);
+ return consumerConfig.getProperties();
+ }
+ );
+ providerExtension = new EdcRuntimeExtensionWithTestDatabase(
+ ":launchers:connectors:sovity-dev",
+ "provider",
+ testDatabase -> {
+ providerConfig = forTestDatabase(this.providerParticipantId, testDatabase);
+ return providerConfig.getProperties();
+ }
+ );
+ }
+
+ @Override
+ public void beforeAll(ExtensionContext context) throws Exception {
+ consumerExtension.beforeAll(context);
+ providerExtension.beforeAll(context);
+ }
+
+ @Override
+ public void beforeTestExecution(ExtensionContext context) throws Exception {
+ clientAndServer = new Lazy<>(() -> ClientAndServer.startClientAndServer(getFreePort()));
+ consumerExtension.beforeTestExecution(context);
+ providerExtension.beforeTestExecution(context);
+ }
+
+ @Override
+ public void afterTestExecution(ExtensionContext context) throws Exception {
+ if (clientAndServer.isInitialized()) {
+ stopQuietly(clientAndServer.get());
+ }
+ consumerExtension.afterTestExecution(context);
+ providerExtension.afterTestExecution(context);
+ }
+
+ @Override
+ public void afterAll(ExtensionContext context) throws Exception {
+ consumerExtension.afterAll(context);
+ providerExtension.afterAll(context);
+ }
+
+ @Override
+ public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
+ throws ParameterResolutionException {
+
+ val isProvider = isProvider(parameterContext);
+ val isConsumer = isConsumer(parameterContext);
+
+ if (isProvider && isConsumer) {
+ throw new ParameterResolutionException("Either @Provider or @Consumer may be used.");
+ }
+
+ val type = parameterContext.getParameter().getType();
+
+ if (isConsumer) {
+ return partySupportedTypes.contains(type) || consumerExtension.supportsParameter(parameterContext, extensionContext);
+ }
+
+ if (isProvider) {
+ return partySupportedTypes.contains(type) || providerExtension.supportsParameter(parameterContext, extensionContext);
+ }
+
+ if (supportedTypes.contains(type)) {
+ return true;
+ }
+
+ return consumerExtension.supportsParameter(parameterContext, extensionContext) ||
+ providerExtension.supportsParameter(parameterContext, extensionContext);
+ }
+
+ @Override
+ public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
+ throws ParameterResolutionException {
+
+ val isConsumer = isConsumer(parameterContext);
+ val isProvider = isProvider(parameterContext);
+
+ val type = parameterContext.getParameter().getType();
+
+ if (isConsumer) {
+ if (EdcClient.class.equals(type)) {
+ return newEdcClient(consumerConfig);
+ } else if (ConnectorConfig.class.equals(type)) {
+ return consumerConfig;
+ } else if (ConnectorRemote.class.equals(type)) {
+ return newConnectorRemote(consumerParticipantId, consumerConfig);
+ } else {
+ return consumerExtension.resolveParameter(parameterContext, extensionContext);
+ }
+ }
+
+ if (isProvider) {
+ if (EdcClient.class.equals(type)) {
+ return newEdcClient(providerConfig);
+ } else if (ConnectorConfig.class.equals(type)) {
+ return providerConfig;
+ } else if (ConnectorRemote.class.equals(type)) {
+ return newConnectorRemote(providerParticipantId, providerConfig);
+ } else {
+ return providerExtension.resolveParameter(parameterContext, extensionContext);
+ }
+ }
+
+ if (E2eScenario.class.equals(type)) {
+ return new E2eScenario(consumerConfig, providerConfig, clientAndServer.get());
+ } else if (ClientAndServer.class.equals(type)) {
+ return clientAndServer.get();
+ }
+
+ throw new IllegalArgumentException(
+ "The parameters must be annotated by the EDC side: @Provider or @Consumer or be one of the supported classes.");
+ }
+
+ private @NotNull ConnectorRemote newConnectorRemote(String participantId, ConnectorConfig config) {
+ return new ConnectorRemote(
+ new ConnectorRemoteConfig(
+ participantId,
+ config.getDefaultEndpoint(),
+ config.getManagementEndpoint(),
+ config.getProtocolEndpoint()));
+ }
+
+ private static boolean isProvider(ParameterContext parameterContext) {
+ return parameterContext.getParameter().getDeclaredAnnotation(Provider.class) != null;
+ }
+
+ private static boolean isConsumer(ParameterContext parameterContext) {
+ return parameterContext.getParameter().getDeclaredAnnotation(Consumer.class) != null;
+ }
+
+ private EdcClient newEdcClient(ConnectorConfig consumerConfig) {
+ return EdcClient.builder()
+ .managementApiUrl(consumerConfig.getManagementEndpoint().getUri().toString())
+ .managementApiKey(consumerConfig.getProperties().get("edc.api.auth.key"))
+ .build();
+ }
+}
diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/MockedAsset.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/MockedAsset.java
new file mode 100644
index 000000000..45609e48f
--- /dev/null
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/MockedAsset.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2024 sovity GmbH
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Contributors:
+ * sovity GmbH - initial API and implementation
+ *
+ */
+
+package de.sovity.edc.extension.e2e.extension;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * An asset that uses a mocked network resource.
+ *
+ * @param assetId The related asset's ID
+ * @param networkAccesses How many times the resource was accessed via the network.
+ */
+public record MockedAsset(
+ String assetId,
+ AtomicInteger networkAccesses
+) {
+}
diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Provider.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Provider.java
new file mode 100644
index 000000000..e3cff34b2
--- /dev/null
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Provider.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2024 sovity GmbH
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Contributors:
+ * sovity GmbH - initial API and implementation
+ *
+ */
+
+package de.sovity.edc.extension.e2e.extension;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * In test code, in conjunction with {@link E2eTestExtension}, specifies that the injected instance must come from the Provider EDC
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Provider {
+}
diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/utils/Lazy.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/utils/Lazy.java
new file mode 100644
index 000000000..ce89df5ee
--- /dev/null
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/utils/Lazy.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2024 sovity GmbH
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Contributors:
+ * sovity GmbH - initial API and implementation
+ *
+ */
+
+package de.sovity.edc.extension.utils;
+
+import lombok.RequiredArgsConstructor;
+
+import java.util.function.Supplier;
+
+@RequiredArgsConstructor
+public class Lazy {
+ private final Supplier supplier;
+
+ private T tt;
+
+ public synchronized T get() {
+ if (tt == null) {
+ tt = supplier.get();
+ }
+
+ return tt;
+ }
+
+ public boolean isInitialized() {
+ return tt != null;
+ }
+}
diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/utils/junit/DisabledOnGithub.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/utils/junit/DisabledOnGithub.java
index 6c91ac61c..f0382d096 100644
--- a/utils/test-utils/src/main/java/de/sovity/edc/extension/utils/junit/DisabledOnGithub.java
+++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/utils/junit/DisabledOnGithub.java
@@ -11,6 +11,7 @@
* sovity GmbH - initial API and implementation
*
*/
+
package de.sovity.edc.extension.utils.junit;
import org.junit.jupiter.api.Tag;