Skip to content

Commit 2ddbd87

Browse files
minor refactoring.
1 parent 157262e commit 2ddbd87

2 files changed

Lines changed: 24 additions & 26 deletions

File tree

v2/sourcedb-to-spanner/src/main/java/com/google/cloud/teleport/v2/templates/SourceDbToSpanner.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,30 @@ protected static SourceDbToSpannerOptions getSourceDbToSpannerOptions(String[] a
9393
return options;
9494
}
9595

96+
/**
97+
* Validates the provided pipeline options. TODO: move this to source connector.
98+
*
99+
* @param options The execution parameters to the pipeline.
100+
* @param sourceConnectionConfig Parsed source connection config.
101+
* @throws IllegalArgumentException if the provided options are invalid for the pipeline.
102+
*/
103+
@VisibleForTesting
104+
static void validateOptions(
105+
SourceDbToSpannerOptions options, SourceConnectionConfig sourceConnectionConfig) {
106+
if (SourceDbToSpannerOptions.PG_SOURCE_DIALECT.equals(options.getSourceDbDialect())) {
107+
Preconditions.checkArgument(
108+
(sourceConnectionConfig instanceof JdbcShardConfig),
109+
"Postgresql dialect should have JDBC source config.");
110+
for (Shard shard : ((JdbcShardConfig) sourceConnectionConfig).getShardConfigs()) {
111+
if (StringUtils.isNotBlank(shard.getNamespace())
112+
&& !shard.getNamespace().equals("public")) {
113+
throw new IllegalArgumentException(
114+
"Non-public namespaces are currently unsupported for PostgreSQL migrations.");
115+
}
116+
}
117+
}
118+
}
119+
96120
/**
97121
* Create the pipeline with the supplied options.
98122
*
@@ -132,28 +156,4 @@ static SpannerConfig createSpannerConfig(SourceDbToSpannerOptions options) {
132156
}
133157
return spannerConfig;
134158
}
135-
136-
/**
137-
* Validates the provided pipeline options.
138-
*
139-
* @param options The execution parameters to the pipeline.
140-
* @param sourceConnectionConfig Parsed source connection config.
141-
* @throws IllegalArgumentException if the provided options are invalid for the pipeline.
142-
*/
143-
@VisibleForTesting
144-
static void validateOptions(
145-
SourceDbToSpannerOptions options, SourceConnectionConfig sourceConnectionConfig) {
146-
if (SourceDbToSpannerOptions.PG_SOURCE_DIALECT.equals(options.getSourceDbDialect())) {
147-
Preconditions.checkArgument(
148-
(sourceConnectionConfig instanceof JdbcShardConfig),
149-
"Postgresql dialect should have JDBC source config.");
150-
for (Shard shard : ((JdbcShardConfig) sourceConnectionConfig).getShardConfigs()) {
151-
if (StringUtils.isNotBlank(shard.getNamespace())
152-
&& !shard.getNamespace().equals("public")) {
153-
throw new IllegalArgumentException(
154-
"Non-public namespaces are currently unsupported for PostgreSQL migrations.");
155-
}
156-
}
157-
}
158-
}
159159
}

v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/source/cassandra/reader/io/cassandra/iowrapper/CassandraIOWrapperFactoryTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
@RunWith(MockitoJUnitRunner.class)
6161
public class CassandraIOWrapperFactoryTest {
6262
private MockedStatic<CassandraIOWrapperHelper> mockCassandraIoWrapperHelper;
63-
private static final String TEST_BUCKET_CASSANDRA_CONFIG_CONF =
64-
"gs://smt-test-bucket/cassandraConfig.conf";
6563
private static final ImmutableList<String> TABLES_TO_READ =
6664
ImmutableList.of(BASIC_TEST_TABLE, PRIMITIVE_TYPES_TABLE);
6765
@Mock SourceSchema mockSourceSchema;

0 commit comments

Comments
 (0)