Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public AbstractSnowflakeConnector(@Nonnull String name) {
@Override
public Handle open(@Nonnull ConnectorArguments arguments)
throws MetadataDumperUsageException, SQLException {
validateArguments(arguments);
String url = arguments.getUri() != null ? arguments.getUri() : getUrlFromArguments(arguments);
String databaseName =
arguments.getDatabases().isEmpty()
Expand All @@ -101,8 +100,10 @@ public Handle open(@Nonnull ConnectorArguments arguments)
return jdbcHandle;
}

private void validateArguments(@Nonnull ConnectorArguments arguments)
throws MetadataDumperUsageException {
@Override
public void validate(ConnectorArguments arguments) {
super.validate(arguments);

ArrayList<String> messages = new ArrayList<>();
MetadataDumperUsageException exception = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.sql.SQLException;
import java.time.Clock;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
Expand All @@ -49,9 +50,6 @@ public SnowflakeLiteConnector() {
@Nonnull
public Handle open(ConnectorArguments arguments)
throws MetadataDumperUsageException, SQLException {
if (!arguments.isAssessment()) {
throw noAssessmentException();
}
return super.open(arguments);
}

Expand All @@ -74,6 +72,16 @@ public final void addTasksTo(List<? super Task<?>> out, ConnectorArguments argum
out.addAll(planner.generateLiteSpecificQueries());
}

@Override
public final void validate(@Nullable ConnectorArguments arguments) {
super.validate(arguments);

Objects.requireNonNull(arguments);
if (!arguments.isAssessment()) {
throw noAssessmentException();
}
}

private static MetadataDumperUsageException noAssessmentException() {
String message =
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void openConnection_failsForVeryLongInput() throws IOException {
}

@Test
public void openConnection_failsForMalformedInput() throws IOException {
public void open_malformedInput_fail() throws IOException {
ConnectorArguments arguments =
makeArguments(
"--connector",
Expand All @@ -75,13 +75,14 @@ public void openConnection_failsForMalformedInput() throws IOException {
}

@Test
public void openConnection_failsForMixedPrivateKeyAndPassword() throws IOException {
public void validate_mixedPrivateKeyAndPassword_fail() throws IOException {
ConnectorArguments arguments =
makeArguments(
"--connector", metadataConnector.getName(), "--private-key-file", "/path/to/file.r8");

MetadataDumperUsageException e =
assertThrows(MetadataDumperUsageException.class, () -> metadataConnector.open(arguments));
assertThrows(
MetadataDumperUsageException.class, () -> metadataConnector.validate(arguments));

assertTrue(
e.getMessage(),
Expand All @@ -91,12 +92,14 @@ public void openConnection_failsForMixedPrivateKeyAndPassword() throws IOExcepti
}

@Test
public void open_assessmentEnabledWithDatabaseFilter_throwsUsageException() throws IOException {
public void validate_assessmentEnabledWithDatabaseFilter_throwsUsageException()
throws IOException {
ConnectorArguments arguments =
makeArguments("--connector", "snowflake", "--database", "SNOWFLAKE", "--assessment");

MetadataDumperUsageException e =
assertThrows(MetadataDumperUsageException.class, () -> metadataConnector.open(arguments));
assertThrows(
MetadataDumperUsageException.class, () -> metadataConnector.validate(arguments));

assertTrue(
e.getMessage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
public class SnowflakeLiteConnectorTest {

@Test
public void open_noAssessmentFlag_throwsUsageException() throws Exception {
public void validate_noAssessmentFlag_throwsUsageException() throws Exception {
ConnectorArguments noFlagArguments = new ConnectorArguments("--connector", "snowflake-lite");
SnowflakeLiteConnector connector = new SnowflakeLiteConnector();

assertThrows(MetadataDumperUsageException.class, () -> connector.open(noFlagArguments));
assertThrows(MetadataDumperUsageException.class, () -> connector.validate(noFlagArguments));
}
}
Loading