Skip to content

Commit

Permalink
ci: fix tests (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt authored Nov 20, 2024
1 parent ceecdb6 commit decef6f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 89 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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();
}
}

0 comments on commit decef6f

Please sign in to comment.