Search in sources :

Example 1 with CommandLineParser

use of com.datastax.oss.dsbulk.runner.cli.CommandLineParser in project dsbulk by datastax.

the class DataStaxBulkLoaderTest method should_not_add_quote_if_already_quoted.

@Test
void should_not_add_quote_if_already_quoted() throws Exception {
    // double quotes should be provided escaped as valid HOCON
    Config result = new CommandLineParser("load", "--connector.csv.delimiter", "\"\\t\"").parse().getConfig();
    assertThat(result.getString("dsbulk.connector.csv.delimiter")).isEqualTo("\t");
}
Also used : Config(com.typesafe.config.Config) CommandLineParser(com.datastax.oss.dsbulk.runner.cli.CommandLineParser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with CommandLineParser

use of com.datastax.oss.dsbulk.runner.cli.CommandLineParser in project dsbulk by datastax.

the class DataStaxBulkLoaderTest method should_not_accept_parse_error.

@Test
void should_not_accept_parse_error() {
    ParseException error = catchThrowableOfType(() -> new CommandLineParser("load", "--codec.booleanStrings", "[a,b").parse(), ParseException.class);
    assertThat(error).hasMessageContaining("Invalid value for dsbulk.codec.booleanStrings, expecting LIST, got: '[a,b'").hasCauseInstanceOf(IllegalArgumentException.class);
    assertThat(error.getCause()).hasMessageContaining("h");
}
Also used : ParseException(com.datastax.oss.dsbulk.runner.cli.ParseException) CommandLineParser(com.datastax.oss.dsbulk.runner.cli.CommandLineParser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with CommandLineParser

use of com.datastax.oss.dsbulk.runner.cli.CommandLineParser in project dsbulk by datastax.

the class DataStaxBulkLoaderTest method should_process_csv_short_options.

@ParameterizedTest
@MethodSource
void should_process_csv_short_options(String shortOptionName, String shortOptionValue, String setting, Object expected) throws Exception {
    Config result = new CommandLineParser("load", shortOptionName, shortOptionValue).parse().getConfig();
    assertThat(result.getAnyRef(setting)).isEqualTo(expected);
}
Also used : Config(com.typesafe.config.Config) CommandLineParser(com.datastax.oss.dsbulk.runner.cli.CommandLineParser) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with CommandLineParser

use of com.datastax.oss.dsbulk.runner.cli.CommandLineParser in project dsbulk by datastax.

the class DataStaxBulkLoaderTest method should_process_short_options.

@ParameterizedTest
@MethodSource
void should_process_short_options(String shortOptionName, String shortOptionValue, String setting, Object expected) throws Exception {
    Config result = new CommandLineParser("load", shortOptionName, shortOptionValue).parse().getConfig();
    assertThat(result.getAnyRef(setting)).isEqualTo(expected);
}
Also used : Config(com.typesafe.config.Config) CommandLineParser(com.datastax.oss.dsbulk.runner.cli.CommandLineParser) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 5 with CommandLineParser

use of com.datastax.oss.dsbulk.runner.cli.CommandLineParser in project dsbulk by datastax.

the class DataStaxBulkLoaderTest method should_process_long_options.

@ParameterizedTest
@MethodSource
void should_process_long_options(String settingName, String settingValue, Object expected) throws Exception {
    Config result = new CommandLineParser("load", "--" + settingName, settingValue).parse().getConfig();
    assertThat(result.getAnyRef(settingName)).isEqualTo(expected);
}
Also used : Config(com.typesafe.config.Config) CommandLineParser(com.datastax.oss.dsbulk.runner.cli.CommandLineParser) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

CommandLineParser (com.datastax.oss.dsbulk.runner.cli.CommandLineParser)14 Config (com.typesafe.config.Config)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 Test (org.junit.jupiter.api.Test)7 MethodSource (org.junit.jupiter.params.provider.MethodSource)6 GlobalHelpRequestException (com.datastax.oss.dsbulk.runner.cli.GlobalHelpRequestException)1 ParseException (com.datastax.oss.dsbulk.runner.cli.ParseException)1 ParsedCommandLine (com.datastax.oss.dsbulk.runner.cli.ParsedCommandLine)1 SectionHelpRequestException (com.datastax.oss.dsbulk.runner.cli.SectionHelpRequestException)1 VersionRequestException (com.datastax.oss.dsbulk.runner.cli.VersionRequestException)1 Workflow (com.datastax.oss.dsbulk.workflow.api.Workflow)1 NonNull (edu.umd.cs.findbugs.annotations.NonNull)1 BufferedWriter (java.io.BufferedWriter)1 OutputStreamWriter (java.io.OutputStreamWriter)1 PrintWriter (java.io.PrintWriter)1