Skip to content

Commit 21e7bf2

Browse files
committed
Test enum to select list conversion
1 parent 50a99ea commit 21e7bf2

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

dumper/app/src/test/java/com/google/edwmigration/dumper/application/dumper/connector/snowflake/AbstractSnowflakeConnectorTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.edwmigration.dumper.application.dumper.connector.snowflake;
1818

1919
import static java.util.Arrays.copyOf;
20+
import static org.junit.Assert.assertEquals;
2021
import static org.junit.Assert.assertThrows;
2122
import static org.junit.Assert.assertTrue;
2223

@@ -119,6 +120,18 @@ public void validate_mixedPrivateKeyAndPassword_fail() throws IOException {
119120
"Private key authentication method can't be used together with user password"));
120121
}
121122

123+
enum TestEnum {
124+
SomeValue
125+
}
126+
127+
@Test
128+
public void columnOf_success() {
129+
130+
String columnName = AbstractSnowflakeConnector.columnOf(TestEnum.SomeValue);
131+
132+
assertEquals("SOME_VALUE", columnName);
133+
}
134+
122135
@Test
123136
public void validate_assessmentEnabledWithDatabaseFilter_throwsUsageException()
124137
throws IOException {

dumper/app/src/test/java/com/google/edwmigration/dumper/application/dumper/connector/snowflake/SnowflakeLogsConnectorTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@
1818

1919
import static com.google.common.base.Predicates.alwaysTrue;
2020
import static com.google.edwmigration.dumper.application.dumper.connector.snowflake.SnowflakeLogsConnector.earliestTimestamp;
21+
import static com.google.edwmigration.dumper.application.dumper.connector.snowflake.SnowflakeLogsConnector.formatPrefix;
2122
import static com.google.edwmigration.dumper.application.dumper.connector.snowflake.SnowflakeLogsConnector.overrideableQuery;
2223
import static org.junit.Assert.assertEquals;
2324
import static org.junit.Assert.assertFalse;
25+
import static org.junit.Assert.assertThrows;
2426
import static org.junit.Assert.assertTrue;
2527

2628
import com.google.edwmigration.dumper.application.dumper.ConnectorArguments;
2729
import com.google.edwmigration.dumper.application.dumper.MetadataDumperUsageException;
2830
import com.google.edwmigration.dumper.test.TestUtils;
2931
import java.io.File;
3032
import java.io.IOException;
31-
import org.junit.Assert;
3233
import org.junit.Test;
3334
import org.junit.runner.RunWith;
3435
import org.junit.runners.JUnit4;
@@ -79,6 +80,20 @@ public void earliestTimestamp_provided_resultMatches() throws IOException {
7980
assertTrue(result, result.endsWith("\n"));
8081
}
8182

83+
enum TestEnum {
84+
FirstValue,
85+
SecondValue;
86+
};
87+
88+
@Test
89+
public void formatPrefix_success() {
90+
91+
String result = formatPrefix(TestEnum.class, "TASK_HISTORY");
92+
93+
assertEquals(
94+
"SELECT FIRST_VALUE, SECOND_VALUE FROM SNOWFLAKE.ACCOUNT_USAGE.TASK_HISTORY", result);
95+
}
96+
8297
@Test
8398
public void overrideableQuery_overrideAbsent_defaultUsed() throws IOException {
8499
String defaultSql = "SELECT event_name, query_id FROM WAREHOUSE_EVENTS_HISTORY";
@@ -119,6 +134,6 @@ public void validate_unsupportedOption_throwsException() throws IOException {
119134
"--" + ConnectorArguments.OPT_QUERY_LOG_EARLIEST_TIMESTAMP,
120135
"2024");
121136

122-
Assert.assertThrows(MetadataDumperUsageException.class, () -> connector.validate(arguments));
137+
assertThrows(MetadataDumperUsageException.class, () -> connector.validate(arguments));
123138
}
124139
}

0 commit comments

Comments
 (0)