From 2ab6621b3ef4b0b352e3eaa682624d3db78c64a4 Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Fri, 26 Jul 2024 16:32:02 +0200 Subject: [PATCH 1/3] Rework E2E test extension to be used in the EDC EE --- docs/api/sovity-edc-api-wrapper.yaml | 4 +- .../ext/catalog/crawler/CrawlerE2eTest.java | 2 +- ...tAgreementTerminationDetailsQueryTest.java | 7 +-- .../query/TerminateContractQueryTest.java | 7 ++- ...a => AlwaysTrueMigrationReversedTest.java} | 15 ++++-- .../edc/e2e/AlwaysTrueMigrationTest.java | 27 ++++++++-- .../edc/e2e/ContractTerminationTest.java | 7 ++- .../e2e/DataSourceParameterizationTest.java | 8 ++- .../edc/e2e/DataSourceQueryParamsTest.java | 7 ++- .../edc/e2e/ManagementApiTransferTest.java | 7 ++- .../PlaceholderDataSourceExtensionTest.java | 7 ++- .../de/sovity/edc/e2e/UiApiWrapperTest.java | 3 +- .../sovity/edc/e2e/UseCaseApiWrapperTest.java | 7 ++- .../e2e/db/EdcRuntimeExtensionFixed.java | 1 + .../e2e/extension/E2eTestExtension.java | 51 ++++++++----------- .../e2e/extension/E2eTestExtensionConfig.java | 40 +++++++++++++++ .../E2eTestExtensionConfigFactory.java | 28 ++++++++++ .../edc/extension/e2e/extension/Helpers.java | 26 ++++++++++ 18 files changed, 194 insertions(+), 60 deletions(-) rename tests/src/test/java/de/sovity/edc/e2e/{AlwaysTrueMigrationTestReversed.java => AlwaysTrueMigrationReversedTest.java} (58%) create mode 100644 utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfig.java create mode 100644 utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfigFactory.java create mode 100644 utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java diff --git a/docs/api/sovity-edc-api-wrapper.yaml b/docs/api/sovity-edc-api-wrapper.yaml index 3f9ca3a7f..4440e71de 100644 --- a/docs/api/sovity-edc-api-wrapper.yaml +++ b/docs/api/sovity-edc-api-wrapper.yaml @@ -584,11 +584,11 @@ components: DataSourceType: type: string description: Supported Data Source Types by UiDataSource - default: CUSTOM enum: - HTTP_DATA - ON_REQUEST - CUSTOM + default: CUSTOM SecretValue: type: object properties: @@ -796,7 +796,6 @@ components: UiDataSourceHttpDataMethod: type: string description: Supported HTTP Methods by UiDataSource - default: GET enum: - GET - POST @@ -804,6 +803,7 @@ components: - PATCH - DELETE - OPTIONS + default: GET UiDataSourceOnRequest: required: - contactEmail diff --git a/extensions/catalog-crawler/catalog-crawler-e2e-test/src/test/java/de/sovity/edc/ext/catalog/crawler/CrawlerE2eTest.java b/extensions/catalog-crawler/catalog-crawler-e2e-test/src/test/java/de/sovity/edc/ext/catalog/crawler/CrawlerE2eTest.java index 1882f283a..8ae17ae24 100644 --- a/extensions/catalog-crawler/catalog-crawler-e2e-test/src/test/java/de/sovity/edc/ext/catalog/crawler/CrawlerE2eTest.java +++ b/extensions/catalog-crawler/catalog-crawler-e2e-test/src/test/java/de/sovity/edc/ext/catalog/crawler/CrawlerE2eTest.java @@ -62,7 +62,7 @@ class CrawlerE2eTest { private static EdcClient connectorClient; @RegisterExtension - static EdcRuntimeExtensionWithTestDatabase providerExtension = new EdcRuntimeExtensionWithTestDatabase( + private static EdcRuntimeExtensionWithTestDatabase providerExtension = new EdcRuntimeExtensionWithTestDatabase( ":launchers:connectors:sovity-dev", "provider", testDatabase -> { diff --git a/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/ContractAgreementTerminationDetailsQueryTest.java b/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/ContractAgreementTerminationDetailsQueryTest.java index a3baebb4b..ebc74740c 100644 --- a/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/ContractAgreementTerminationDetailsQueryTest.java +++ b/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/ContractAgreementTerminationDetailsQueryTest.java @@ -26,15 +26,16 @@ import de.sovity.edc.extension.utils.junit.DisabledOnGithub; import lombok.val; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation.Type.CONSUMER; - -@ExtendWith(E2eTestExtension.class) class ContractAgreementTerminationDetailsQueryTest { + @RegisterExtension + private static E2eTestExtension e2eTestExtension = new E2eTestExtension(":launchers:connectors:sovity-dev"); + @DisabledOnGithub @Test void fetchAgreementDetailsOrThrow_whenAgreementIsPresent_shouldReturnTheAgreementDetails( diff --git a/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/TerminateContractQueryTest.java b/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/TerminateContractQueryTest.java index 5fb3c67ee..b7000d35a 100644 --- a/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/TerminateContractQueryTest.java +++ b/extensions/contract-termination/src/test/java/de/sovity/edc/extension/contacttermination/query/TerminateContractQueryTest.java @@ -25,18 +25,21 @@ import lombok.val; import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import java.time.OffsetDateTime; import java.time.temporal.ChronoUnit; import static de.sovity.edc.ext.db.jooq.enums.ContractTerminatedBy.COUNTERPARTY; +import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; -@ExtendWith(E2eTestExtension.class) class TerminateContractQueryTest { + @RegisterExtension + private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension(); + @DisabledOnGithub @Test void terminateConsumerAgreementOrThrow_shouldInsertRowInTerminationTable( diff --git a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTestReversed.java b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java similarity index 58% rename from tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTestReversed.java rename to tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java index 9d9bf62a9..baad46494 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTestReversed.java +++ b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java @@ -11,14 +11,19 @@ import org.mockserver.integration.ClientAndServer; import static de.sovity.edc.e2e.AlwaysTrueMigrationTest.testTransfer; +import static de.sovity.edc.extension.e2e.extension.E2eTestExtensionConfigFactory.defaultBuilder; -class AlwaysTrueMigrationTestReversed { +class AlwaysTrueMigrationReversedTest { @RegisterExtension - private static final E2eTestExtension E2E_TEST_EXTENSION = E2eTestExtension.builder() - .additionalConsumerMigrationLocation("classpath:db/additional-test-data/always-true-policy-legacy") - .additionalProviderMigrationLocation("classpath:db/additional-test-data/always-true-policy-migrated") - .build(); + private static final E2eTestExtension E2E_TEST_EXTENSION = new E2eTestExtension( + defaultBuilder() + .consumerConfigCustomizer(config -> config.getProperties() + .put("edc.flyway.additional.migration.locations", "classpath:db/additional-test-data/always-true-policy-legacy")) + .providerConfigCustomizer(config -> config.getProperties() + .put("edc.flyway.additional.migration.locations", "classpath:db/additional-test-data/always-true-policy-migrated")) + .build() + ); @Test @DisabledOnGithub diff --git a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java index b80a7cfe1..3d25b38f1 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2024 sovity GmbH + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * sovity GmbH - initial API and implementation + * + */ + package de.sovity.edc.e2e; import de.sovity.edc.client.EdcClient; @@ -23,15 +37,20 @@ import java.util.Map; +import static de.sovity.edc.extension.e2e.extension.E2eTestExtensionConfigFactory.withModule; import static org.assertj.core.api.Assertions.assertThat; class AlwaysTrueMigrationTest { @RegisterExtension - private static final E2eTestExtension E2E_TEST_EXTENSION = E2eTestExtension.builder() - .additionalConsumerMigrationLocation("classpath:db/additional-test-data/always-true-policy-migrated") - .additionalProviderMigrationLocation("classpath:db/additional-test-data/always-true-policy-legacy") - .build(); + private static final E2eTestExtension E2E_TEST_EXTENSION = new E2eTestExtension( + withModule(":launchers:connectors:sovity-dev") + .consumerConfigCustomizer(config -> config.getProperties() + .put("edc.flyway.additional.migration.locations", "classpath:db/additional-test-data/always-true-policy-migrated")) + .providerConfigCustomizer(config -> config.getProperties() + .put("edc.flyway.additional.migration.locations", "classpath:db/additional-test-data/always-true-policy-legacy")) + .build() + ); @Test @DisabledOnGithub diff --git a/tests/src/test/java/de/sovity/edc/e2e/ContractTerminationTest.java b/tests/src/test/java/de/sovity/edc/e2e/ContractTerminationTest.java index e55cc6f10..bc4d8bb10 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/ContractTerminationTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/ContractTerminationTest.java @@ -37,7 +37,7 @@ import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestFactory; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockserver.integration.ClientAndServer; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; @@ -52,6 +52,7 @@ import static de.sovity.edc.client.gen.model.ContractTerminatedBy.SELF; import static de.sovity.edc.client.gen.model.ContractTerminationStatus.ONGOING; import static de.sovity.edc.client.gen.model.ContractTerminationStatus.TERMINATED; +import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension; import static java.time.Duration.ofSeconds; import static java.util.concurrent.TimeUnit.SECONDS; import static org.assertj.core.api.Assertions.assertThat; @@ -59,9 +60,11 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.DynamicTest.dynamicTest; -@ExtendWith(E2eTestExtension.class) public class ContractTerminationTest { + @RegisterExtension + private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension(); + @Test @DisabledOnGithub void canGetAgreementPageForNonTerminatedContract( diff --git a/tests/src/test/java/de/sovity/edc/e2e/DataSourceParameterizationTest.java b/tests/src/test/java/de/sovity/edc/e2e/DataSourceParameterizationTest.java index f0bdd6ea3..300dd0fdc 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/DataSourceParameterizationTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/DataSourceParameterizationTest.java @@ -55,7 +55,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockserver.integration.ClientAndServer; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; @@ -77,6 +77,7 @@ import javax.annotation.Nullable; import static de.sovity.edc.client.gen.model.TransferProcessSimplifiedState.OK; +import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension; import static java.time.Duration.ofSeconds; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Fail.fail; @@ -91,9 +92,12 @@ import static org.mockserver.model.HttpRequest.request; import static org.mockserver.stop.Stop.stopQuietly; -@ExtendWith(E2eTestExtension.class) + class DataSourceParameterizationTest { + @RegisterExtension + private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension(); + private final int port = getFreePort(); private final String sourcePath = "/source/some/path/"; private final String destinationPath = "/destination/some/path/"; diff --git a/tests/src/test/java/de/sovity/edc/e2e/DataSourceQueryParamsTest.java b/tests/src/test/java/de/sovity/edc/e2e/DataSourceQueryParamsTest.java index 76b641959..b3bb3d0d5 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/DataSourceQueryParamsTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/DataSourceQueryParamsTest.java @@ -28,15 +28,18 @@ import lombok.val; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import java.util.HashMap; import static de.sovity.edc.extension.e2e.connector.DataTransferTestUtil.validateDataTransferred; +import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension; -@ExtendWith(E2eTestExtension.class) class DataSourceQueryParamsTest { + @RegisterExtension + private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension(); + private MockDataAddressRemote dataAddress; private final String encodedParam = "a=%25"; // Unencoded param "a=%" diff --git a/tests/src/test/java/de/sovity/edc/e2e/ManagementApiTransferTest.java b/tests/src/test/java/de/sovity/edc/e2e/ManagementApiTransferTest.java index 08876aaa0..1f571485b 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/ManagementApiTransferTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/ManagementApiTransferTest.java @@ -21,15 +21,18 @@ import de.sovity.edc.extension.e2e.extension.Provider; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import java.util.UUID; import static de.sovity.edc.extension.e2e.connector.DataTransferTestUtil.validateDataTransferred; +import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension; -@ExtendWith(E2eTestExtension.class) class ManagementApiTransferTest { + @RegisterExtension + private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension(); + private MockDataAddressRemote dataAddress; private static final String TEST_BACKEND_TEST_DATA = UUID.randomUUID().toString(); diff --git a/tests/src/test/java/de/sovity/edc/e2e/PlaceholderDataSourceExtensionTest.java b/tests/src/test/java/de/sovity/edc/e2e/PlaceholderDataSourceExtensionTest.java index 5e6fb8b7f..c2d4b875c 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/PlaceholderDataSourceExtensionTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/PlaceholderDataSourceExtensionTest.java @@ -27,7 +27,7 @@ import lombok.SneakyThrows; import lombok.val; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockserver.integration.ClientAndServer; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; @@ -37,12 +37,15 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicReference; +import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension; import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE; -@ExtendWith(E2eTestExtension.class) class PlaceholderDataSourceExtensionTest { + @RegisterExtension + private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension(); + @SneakyThrows @Test void shouldAccessDummyEndpoint( diff --git a/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java b/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java index 790e0c268..daae60d83 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java @@ -69,6 +69,7 @@ import static de.sovity.edc.client.gen.model.ContractAgreementDirection.CONSUMING; import static de.sovity.edc.client.gen.model.ContractAgreementDirection.PROVIDING; import static de.sovity.edc.extension.e2e.connector.DataTransferTestUtil.validateDataTransferred; +import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension; import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -80,7 +81,7 @@ class UiApiWrapperTest { private static final String CONSUMER_PARTICIPANT_ID = "consumer"; @RegisterExtension - private static E2eTestExtension e2eTestExtension = new E2eTestExtension(CONSUMER_PARTICIPANT_ID, PROVIDER_PARTICIPANT_ID); + private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension(); private MockDataAddressRemote dataAddress; 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 3231fda3d..521a670af 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/UseCaseApiWrapperTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/UseCaseApiWrapperTest.java @@ -45,16 +45,19 @@ import de.sovity.edc.utils.jsonld.vocab.Prop; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import java.time.OffsetDateTime; import java.util.List; +import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension; import static org.assertj.core.api.Assertions.assertThat; -@ExtendWith(E2eTestExtension.class) class UseCaseApiWrapperTest { + @RegisterExtension + private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension(); + private MockDataAddressRemote dataAddress; private final String dataOfferData = "expected data 123"; diff --git a/utils/test-utils/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 index d344b5f00..495ba4a81 100644 --- a/utils/test-utils/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 @@ -49,6 +49,7 @@ * {@link AfterTestExecutionCallback} lifecycle hooks. Parameter injection of runtime services is supported. */ public class EdcRuntimeExtensionFixed extends EdcExtension { + private static final Monitor MONITOR = loadMonitor(); private final String moduleName; diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java index 0605a69cd..54571fabd 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtension.java @@ -20,7 +20,6 @@ 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.Builder; import lombok.val; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.extension.AfterAllCallback; @@ -43,13 +42,11 @@ public class E2eTestExtension implements BeforeAllCallback, AfterAllCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback, ParameterResolver { - private final String consumerParticipantId; - private final String additionalConsumerMigrationLocation; + private E2eTestExtensionConfig config; + private ConnectorConfig consumerConfig; private final EdcRuntimeExtensionWithTestDatabase consumerExtension; - private String providerParticipantId; - private final String additionalProviderMigrationLocation; private ConnectorConfig providerConfig; private final EdcRuntimeExtensionWithTestDatabase providerExtension; @@ -59,41 +56,35 @@ public class E2eTestExtension private Lazy clientAndServer; - public E2eTestExtension() { - this("consumer", "provider", "", ""); - } - - @Builder - public E2eTestExtension(String additionalConsumerMigrationLocation, String additionalProviderMigrationLocation) { - this("consumer", "provider", additionalConsumerMigrationLocation, additionalProviderMigrationLocation); + public E2eTestExtension(String moduleName) { + this(E2eTestExtensionConfig.builder().moduleName(moduleName).build()); } public E2eTestExtension( - String consumerParticipantId, - String providerParticipantId, - String additionalConsumerMigrationLocation, - String additionalProviderMigrationLocation + E2eTestExtensionConfig config ) { - this.consumerParticipantId = consumerParticipantId; - this.providerParticipantId = providerParticipantId; - this.additionalConsumerMigrationLocation = additionalConsumerMigrationLocation; - this.additionalProviderMigrationLocation = additionalProviderMigrationLocation; + this.config = config; consumerExtension = new EdcRuntimeExtensionWithTestDatabase( - ":launchers:connectors:sovity-dev", - "consumer", + config.getModuleName(), + config.getConsumerParticipantId(), testDatabase -> { - consumerConfig = forTestDatabase(this.consumerParticipantId, testDatabase); - consumerConfig.getProperties().put("edc.flyway.additional.migration.locations", this.additionalConsumerMigrationLocation); + consumerConfig = forTestDatabase(config.getConsumerParticipantId(), testDatabase); + + config.getConfigCustomizer().accept(consumerConfig); + config.getConsumerConfigCustomizer().accept(consumerConfig); return consumerConfig.getProperties(); } ); + providerExtension = new EdcRuntimeExtensionWithTestDatabase( - ":launchers:connectors:sovity-dev", - "provider", + config.getModuleName(), + config.getProviderParticipantId(), testDatabase -> { - providerConfig = forTestDatabase(this.providerParticipantId, testDatabase); - providerConfig.getProperties().put("edc.flyway.additional.migration.locations", this.additionalProviderMigrationLocation); + providerConfig = forTestDatabase(config.getProviderParticipantId(), testDatabase); + + config.getConfigCustomizer().accept(providerConfig); + config.getProviderConfigCustomizer().accept(providerConfig); return providerConfig.getProperties(); } ); @@ -171,7 +162,7 @@ public Object resolveParameter(ParameterContext parameterContext, ExtensionConte } else if (ConnectorConfig.class.equals(type)) { return consumerConfig; } else if (ConnectorRemote.class.equals(type)) { - return newConnectorRemote(consumerParticipantId, consumerConfig); + return newConnectorRemote(config.getConsumerParticipantId(), consumerConfig); } else { return consumerExtension.resolveParameter(parameterContext, extensionContext); } @@ -183,7 +174,7 @@ public Object resolveParameter(ParameterContext parameterContext, ExtensionConte } else if (ConnectorConfig.class.equals(type)) { return providerConfig; } else if (ConnectorRemote.class.equals(type)) { - return newConnectorRemote(providerParticipantId, providerConfig); + return newConnectorRemote(config.getProviderParticipantId(), providerConfig); } else { return providerExtension.resolveParameter(parameterContext, extensionContext); } diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfig.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfig.java new file mode 100644 index 000000000..9aeca378a --- /dev/null +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfig.java @@ -0,0 +1,40 @@ +/* + * 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.extension.e2e.connector.config.ConnectorConfig; +import lombok.Builder; +import lombok.Getter; + +import java.util.function.Consumer; + +@Builder(toBuilder = true) +@Getter +public class E2eTestExtensionConfig { + private String moduleName; + @Builder.Default + private String consumerParticipantId = "consumer"; + @Builder.Default + private String providerParticipantId = "provider"; + @Builder.Default + private Consumer configCustomizer = (it) -> { + }; + @Builder.Default + private Consumer consumerConfigCustomizer = (it) -> { + }; + @Builder.Default + private Consumer providerConfigCustomizer = (it) -> { + }; +} diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfigFactory.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfigFactory.java new file mode 100644 index 000000000..5f18915de --- /dev/null +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfigFactory.java @@ -0,0 +1,28 @@ +/* + * 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 lombok.experimental.UtilityClass; + +@UtilityClass +public class E2eTestExtensionConfigFactory { + public static E2eTestExtensionConfig.E2eTestExtensionConfigBuilder defaultBuilder() { + return E2eTestExtensionConfig.builder().moduleName(":launchers:connectors:sovity-dev"); + } + + public static E2eTestExtensionConfig.E2eTestExtensionConfigBuilder withModule(String module) { + return defaultBuilder().moduleName(module); + } +} diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java new file mode 100644 index 000000000..d7c8c2d74 --- /dev/null +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java @@ -0,0 +1,26 @@ +/* + * 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 lombok.experimental.UtilityClass; + +import static de.sovity.edc.extension.e2e.extension.E2eTestExtensionConfigFactory.withModule; + +@UtilityClass +public class Helpers { + public static E2eTestExtension defaultE2eTestExtension() { + return new E2eTestExtension(withModule(":launchers:connectors:sovity-dev").build()); + } +} From 4f89ee15f1b69e8fadf2955af1e4ef6e053437d2 Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Mon, 29 Jul 2024 09:21:22 +0200 Subject: [PATCH 2/3] Formatting --- .../de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java | 2 +- .../java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java | 2 +- ...figFactory.java => CeE2eTestExtensionConfigFactory.java} | 3 ++- .../edc/extension/e2e/extension/E2eTestExtensionConfig.java | 6 ++++++ .../java/de/sovity/edc/extension/e2e/extension/Helpers.java | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) rename utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/{E2eTestExtensionConfigFactory.java => CeE2eTestExtensionConfigFactory.java} (94%) diff --git a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java index baad46494..ccf0da7de 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java @@ -11,7 +11,7 @@ import org.mockserver.integration.ClientAndServer; import static de.sovity.edc.e2e.AlwaysTrueMigrationTest.testTransfer; -import static de.sovity.edc.extension.e2e.extension.E2eTestExtensionConfigFactory.defaultBuilder; +import static de.sovity.edc.extension.e2e.extension.CeE2eTestExtensionConfigFactory.defaultBuilder; class AlwaysTrueMigrationReversedTest { diff --git a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java index 3d25b38f1..f48f0a628 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java @@ -37,7 +37,7 @@ import java.util.Map; -import static de.sovity.edc.extension.e2e.extension.E2eTestExtensionConfigFactory.withModule; +import static de.sovity.edc.extension.e2e.extension.CeE2eTestExtensionConfigFactory.withModule; import static org.assertj.core.api.Assertions.assertThat; class AlwaysTrueMigrationTest { diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfigFactory.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/CeE2eTestExtensionConfigFactory.java similarity index 94% rename from utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfigFactory.java rename to utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/CeE2eTestExtensionConfigFactory.java index 5f18915de..3142798f7 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfigFactory.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/CeE2eTestExtensionConfigFactory.java @@ -17,7 +17,8 @@ import lombok.experimental.UtilityClass; @UtilityClass -public class E2eTestExtensionConfigFactory { +public class CeE2eTestExtensionConfigFactory { + public static E2eTestExtensionConfig.E2eTestExtensionConfigBuilder defaultBuilder() { return E2eTestExtensionConfig.builder().moduleName(":launchers:connectors:sovity-dev"); } diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfig.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfig.java index 9aeca378a..1bb12cea1 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfig.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/E2eTestExtensionConfig.java @@ -23,17 +23,23 @@ @Builder(toBuilder = true) @Getter public class E2eTestExtensionConfig { + private String moduleName; + @Builder.Default private String consumerParticipantId = "consumer"; + @Builder.Default private String providerParticipantId = "provider"; + @Builder.Default private Consumer configCustomizer = (it) -> { }; + @Builder.Default private Consumer consumerConfigCustomizer = (it) -> { }; + @Builder.Default private Consumer providerConfigCustomizer = (it) -> { }; diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java index d7c8c2d74..ea02d4cc7 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java @@ -16,7 +16,7 @@ import lombok.experimental.UtilityClass; -import static de.sovity.edc.extension.e2e.extension.E2eTestExtensionConfigFactory.withModule; +import static de.sovity.edc.extension.e2e.extension.CeE2eTestExtensionConfigFactory.withModule; @UtilityClass public class Helpers { From 84f2442d4d3399e827df412e036f126396bd6d75 Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Mon, 29 Jul 2024 09:51:22 +0200 Subject: [PATCH 3/3] Remove Builder reference --- .../sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java | 2 +- .../java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java | 2 +- .../e2e/extension/CeE2eTestExtensionConfigFactory.java | 8 ++++---- .../de/sovity/edc/extension/e2e/extension/Helpers.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java index ccf0da7de..525e5669d 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationReversedTest.java @@ -17,7 +17,7 @@ class AlwaysTrueMigrationReversedTest { @RegisterExtension private static final E2eTestExtension E2E_TEST_EXTENSION = new E2eTestExtension( - defaultBuilder() + defaultBuilder().toBuilder() .consumerConfigCustomizer(config -> config.getProperties() .put("edc.flyway.additional.migration.locations", "classpath:db/additional-test-data/always-true-policy-legacy")) .providerConfigCustomizer(config -> config.getProperties() diff --git a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java index f48f0a628..e1d08fabd 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java @@ -44,7 +44,7 @@ class AlwaysTrueMigrationTest { @RegisterExtension private static final E2eTestExtension E2E_TEST_EXTENSION = new E2eTestExtension( - withModule(":launchers:connectors:sovity-dev") + withModule(":launchers:connectors:sovity-dev").toBuilder() .consumerConfigCustomizer(config -> config.getProperties() .put("edc.flyway.additional.migration.locations", "classpath:db/additional-test-data/always-true-policy-migrated")) .providerConfigCustomizer(config -> config.getProperties() diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/CeE2eTestExtensionConfigFactory.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/CeE2eTestExtensionConfigFactory.java index 3142798f7..e096e2895 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/CeE2eTestExtensionConfigFactory.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/CeE2eTestExtensionConfigFactory.java @@ -19,11 +19,11 @@ @UtilityClass public class CeE2eTestExtensionConfigFactory { - public static E2eTestExtensionConfig.E2eTestExtensionConfigBuilder defaultBuilder() { - return E2eTestExtensionConfig.builder().moduleName(":launchers:connectors:sovity-dev"); + public static E2eTestExtensionConfig defaultBuilder() { + return E2eTestExtensionConfig.builder().moduleName(":launchers:connectors:sovity-dev").build(); } - public static E2eTestExtensionConfig.E2eTestExtensionConfigBuilder withModule(String module) { - return defaultBuilder().moduleName(module); + public static E2eTestExtensionConfig withModule(String module) { + return defaultBuilder().toBuilder().moduleName(module).build(); } } diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java index ea02d4cc7..4fa3ae399 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/extension/Helpers.java @@ -21,6 +21,6 @@ @UtilityClass public class Helpers { public static E2eTestExtension defaultE2eTestExtension() { - return new E2eTestExtension(withModule(":launchers:connectors:sovity-dev").build()); + return new E2eTestExtension(withModule(":launchers:connectors:sovity-dev")); } }