ahmedabu98 commented on code in PR #24918:
URL: https://github.com/apache/beam/pull/24918#discussion_r1065000676
##########
sdks/java/io/jdbc/src/test/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProviderTest.java:
##########
@@ -65,28 +65,68 @@ public static void beforeClass() throws Exception {
}
@Test
- public void testInvalidOptions() {
- JdbcReadSchemaTransformProvider provider = new
JdbcReadSchemaTransformProvider();
+ public void testInvalidReadSchemaOptions() {
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+
JdbcReadSchemaTransformProvider.JdbcReadSchemaTransformConfiguration.builder()
+ .setDriverClassName("")
+ .setJdbcUrl("")
+ .build()
+ .validate();
+ });
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+
JdbcReadSchemaTransformProvider.JdbcReadSchemaTransformConfiguration.builder()
+ .setDriverClassName("ClassName")
+ .setJdbcUrl("JdbcUrl")
+ .setLocation("Location")
+ .setReadQuery("Query")
+ .build()
+ .validate();
+ });
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+
JdbcReadSchemaTransformProvider.JdbcReadSchemaTransformConfiguration.builder()
+ .setDriverClassName("ClassName")
+ .setJdbcUrl("JdbcUrl")
+ .build()
+ .validate();
+ });
+ }
+ @Test
+ public void testInvalidWriteSchemaOptions() {
Review Comment:
Should this test be moved to `JdbcWriteSchemaTransformProviderTest`?
##########
sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProvider.java:
##########
@@ -164,6 +158,26 @@ public abstract static class
JdbcReadSchemaTransformConfiguration implements Ser
@Nullable
public abstract Boolean getOutputParallelization();
+ public void validate() throws IllegalArgumentException {
+ if ("".equals(getDriverClassName())) {
+ throw new IllegalArgumentException("JDBC Driver class name cannot be
blank.");
+ }
+ if ("".equals(getJdbcUrl())) {
+ throw new IllegalArgumentException("JDBC URL cannot be blank");
+ }
Review Comment:
Let's check for null values too (here and in write provider)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]