diff --git a/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/DataPlaneBigQueryExtensionTest.java b/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/DataPlaneBigQueryExtensionTest.java deleted file mode 100644 index 771b173..0000000 --- a/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/DataPlaneBigQueryExtensionTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2024 Google LLC - * - * 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: - * Google LLC - * - */ - -package org.eclipse.edc.connector.dataplane.gcp.bigquery; - -import org.eclipse.edc.connector.controlplane.api.client.spi.transferprocess.TransferProcessApiClient; -import org.eclipse.edc.connector.dataplane.spi.pipeline.PipelineService; -import org.eclipse.edc.gcp.bigquery.service.BigQueryServiceSchema; -import org.eclipse.edc.junit.extensions.EdcExtension; -import org.eclipse.edc.keys.spi.LocalPublicKeyService; -import org.eclipse.edc.keys.spi.PrivateKeyResolver; -import org.eclipse.edc.spi.query.CriterionOperatorRegistry; -import org.eclipse.edc.spi.types.TypeManager; -import org.eclipse.edc.spi.types.domain.DataAddress; -import org.eclipse.edc.spi.types.domain.transfer.DataFlowStartMessage; -import org.eclipse.edc.validator.spi.DataAddressValidatorRegistry; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import java.util.Map; -import java.util.UUID; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -@ExtendWith(EdcExtension.class) -class DataPlaneBigQueryExtensionTest { - private static final String TEST_PROJECT = "test-project"; - private static final String TEST_QUERY = "select * from table;"; - private static final String TEST_TABLE = "test-table"; - private static final String TEST_DATASET = "test-dataset"; - - @BeforeEach - void setup(EdcExtension extension) { - var config = Map.ofEntries( - Map.entry("edc.transfer.proxy.token.verifier.publickey.alias", "test"), - Map.entry("edc.transfer.proxy.token.signer.privatekey.alias", "test") - ); - extension.setConfiguration(config); - extension.registerServiceMock(TransferProcessApiClient.class, mock(TransferProcessApiClient.class)); - extension.registerServiceMock(TypeManager.class, mock(TypeManager.class)); - extension.registerServiceMock(CriterionOperatorRegistry.class, mock(CriterionOperatorRegistry.class)); - extension.registerServiceMock(DataAddressValidatorRegistry.class, mock(DataAddressValidatorRegistry.class)); - extension.registerServiceMock(LocalPublicKeyService.class, mock(LocalPublicKeyService.class)); - extension.registerServiceMock(PrivateKeyResolver.class, mock(PrivateKeyResolver.class)); - } - - @Test - void pipelineServiceValidateSucceeds(PipelineService pipelineService) { - var message = DataFlowStartMessage.Builder.newInstance() - .processId(UUID.randomUUID().toString()) - .sourceDataAddress(getSourceDataAddress()) - .destinationDataAddress(getDestinationDataAddress()) - .build(); - - assertThat(pipelineService.validate(message).succeeded()).isTrue(); - } - - private static DataAddress getSourceDataAddress() { - return DataAddress.Builder.newInstance() - .type(BigQueryServiceSchema.BIGQUERY_DATA) - .property(BigQueryServiceSchema.QUERY, TEST_QUERY) - .build(); - } - - private static DataAddress getDestinationDataAddress() { - return DataAddress.Builder.newInstance() - .type(BigQueryServiceSchema.BIGQUERY_DATA) - .property(BigQueryServiceSchema.DATASET, TEST_DATASET) - .property(BigQueryServiceSchema.TABLE, TEST_TABLE) - .build(); - } -} diff --git a/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/pipeline/BigQueryDataSinkFactoryTest.java b/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/pipeline/BigQueryDataSinkFactoryTest.java index 0bebffb..11068ad 100644 --- a/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/pipeline/BigQueryDataSinkFactoryTest.java +++ b/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/pipeline/BigQueryDataSinkFactoryTest.java @@ -26,9 +26,11 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.util.UUID; import java.util.concurrent.ExecutorService; import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -48,15 +50,29 @@ public class BigQueryDataSinkFactoryTest { private final Vault vault = mock(); private final IamService iamService = mock(); + private final BigQueryDataSinkFactory factory = new BigQueryDataSinkFactory(bigQueryConfiguration, executorService, + monitor, vault, typeManager, new BigQueryRequestParamsProvider(), iamService); + @BeforeEach void setup() { when(monitor.withPrefix(any(String.class))).thenReturn(monitor); } + @Test + void shouldValidateRequest() { + var message = DataFlowStartMessage.Builder.newInstance() + .processId(UUID.randomUUID().toString()) + .sourceDataAddress(getSourceDataAddress()) + .destinationDataAddress(getDestinationDataAddress()) + .build(); + + var result = factory.validateRequest(message); + + assertThat(result).isSucceeded(); + } + @Test void testCreateSink() { - var provider = new BigQueryRequestParamsProvider(); - var factory = new BigQueryDataSinkFactory(bigQueryConfiguration, executorService, monitor, vault, typeManager, provider, iamService); var bqDataFlowRequest = getDataFlowRequest(BigQueryServiceSchema.BIGQUERY_DATA); @@ -81,4 +97,19 @@ private DataFlowStartMessage getDataFlowRequest(String type) { .destinationDataAddress(dataAddress) .build(); } + + private DataAddress getSourceDataAddress() { + return DataAddress.Builder.newInstance() + .type(BigQueryServiceSchema.BIGQUERY_DATA) + .property(BigQueryServiceSchema.QUERY, "select * from table;") + .build(); + } + + private DataAddress getDestinationDataAddress() { + return DataAddress.Builder.newInstance() + .type(BigQueryServiceSchema.BIGQUERY_DATA) + .property(BigQueryServiceSchema.DATASET, TEST_DATASET) + .property(BigQueryServiceSchema.TABLE, TEST_TABLE) + .build(); + } } diff --git a/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/pipeline/BigQueryDataSourceFactoryTest.java b/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/pipeline/BigQueryDataSourceFactoryTest.java index 6e38308..799f604 100644 --- a/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/pipeline/BigQueryDataSourceFactoryTest.java +++ b/extensions/data-plane/data-plane-google-bigquery/src/test/java/org/eclipse/edc/connector/dataplane/gcp/bigquery/pipeline/BigQueryDataSourceFactoryTest.java @@ -25,10 +25,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -47,16 +49,29 @@ public class BigQueryDataSourceFactoryTest { private final BigQueryConfiguration configuration = new BigQueryConfiguration(gcpConfiguration, "testEndpoint", null, 0); private final Monitor monitor = mock(); private final IamService iamService = mock(); + private final BigQueryDataSourceFactory factory = new BigQueryDataSourceFactory(configuration, monitor, + new BigQueryRequestParamsProvider(), executionPool, iamService); @BeforeEach void setup() { when(monitor.withPrefix(any(String.class))).thenReturn(monitor); } + @Test + void shouldValidateRequest() { + var message = DataFlowStartMessage.Builder.newInstance() + .processId(UUID.randomUUID().toString()) + .sourceDataAddress(getSourceDataAddress()) + .destinationDataAddress(getDestinationDataAddress()) + .build(); + + var result = factory.validateRequest(message); + + assertThat(result).isSucceeded(); + } + @Test void testCreateSource() { - var provider = new BigQueryRequestParamsProvider(); - var factory = new BigQueryDataSourceFactory(configuration, monitor, provider, executionPool, iamService); var bqDataFlowRequest = getDataFlowRequest(BigQueryServiceSchema.BIGQUERY_DATA); var bqSource = factory.createSource(bqDataFlowRequest); @@ -82,4 +97,20 @@ private DataFlowStartMessage getDataFlowRequest(String type) { .destinationDataAddress(dataAddress) .build(); } + + + private DataAddress getSourceDataAddress() { + return DataAddress.Builder.newInstance() + .type(BigQueryServiceSchema.BIGQUERY_DATA) + .property(BigQueryServiceSchema.QUERY, "select * from table;") + .build(); + } + + private DataAddress getDestinationDataAddress() { + return DataAddress.Builder.newInstance() + .type(BigQueryServiceSchema.BIGQUERY_DATA) + .property(BigQueryServiceSchema.DATASET, TEST_DATASET) + .property(BigQueryServiceSchema.TABLE, TEST_TABLE) + .build(); + } }