use of com.datastax.oss.dsbulk.connectors.api.DefaultIndexedField in project dsbulk by datastax.
the class CSVConnectorTest method should_honor_ignoreLeadingWhitespacesInQuotes_and_ignoreTrailingWhitespacesInQuotes2.
@Test
void should_honor_ignoreLeadingWhitespacesInQuotes_and_ignoreTrailingWhitespacesInQuotes2() throws Exception {
Path file = Files.createTempFile("test", ".csv");
Files.write(file, Collections.singleton("\" foo \""));
CSVConnector connector = new CSVConnector();
Config settings = TestConfigUtils.createTestConfig("dsbulk.connector.csv", "url", StringUtils.quoteJson(file), "ignoreLeadingWhitespacesInQuotes", true, "ignoreTrailingWhitespacesInQuotes", true, "header", false);
connector.configure(settings, true, true);
connector.init();
List<Record> records = Flux.merge(connector.read()).collectList().block();
assertThat(records).hasSize(1);
assertThat(records.get(0).getFieldValue(new DefaultIndexedField(0))).isEqualTo("foo");
connector.close();
}
use of com.datastax.oss.dsbulk.connectors.api.DefaultIndexedField in project dsbulk by datastax.
the class CSVConnectorTest method should_honor_nullValue_when_reading.
@ParameterizedTest
@MethodSource
void should_honor_nullValue_when_reading(String nullValue, String expected) throws Exception {
Path file = Files.createTempFile("test", ".csv");
Files.write(file, Collections.singleton(","));
CSVConnector connector = new CSVConnector();
Config settings = TestConfigUtils.createTestConfig("dsbulk.connector.csv", "url", StringUtils.quoteJson(file), "nullValue", StringUtils.quoteJson(nullValue), "header", false);
connector.configure(settings, true, true);
connector.init();
List<Record> records = Flux.merge(connector.read()).collectList().block();
assertThat(records).hasSize(1);
assertThat(records.get(0).getFieldValue(new DefaultIndexedField(0))).isEqualTo(expected);
connector.close();
}
use of com.datastax.oss.dsbulk.connectors.api.DefaultIndexedField in project dsbulk by datastax.
the class CSVConnectorTest method should_honor_ignoreLeadingWhitespaces_and_ignoreTrailingWhitespaces_when_reading2.
@Test
void should_honor_ignoreLeadingWhitespaces_and_ignoreTrailingWhitespaces_when_reading2() throws Exception {
Path file = Files.createTempFile("test", ".csv");
Files.write(file, Collections.singleton(" foo "));
CSVConnector connector = new CSVConnector();
Config settings = TestConfigUtils.createTestConfig("dsbulk.connector.csv", "url", StringUtils.quoteJson(file), "ignoreLeadingWhitespaces", true, "ignoreTrailingWhitespaces", true, "header", false);
connector.configure(settings, true, true);
connector.init();
List<Record> records = Flux.merge(connector.read()).collectList().block();
assertThat(records).hasSize(1);
assertThat(records.get(0).getFieldValue(new DefaultIndexedField(0))).isEqualTo("foo");
connector.close();
}
use of com.datastax.oss.dsbulk.connectors.api.DefaultIndexedField in project dsbulk by datastax.
the class CSVConnectorTest method should_honor_ignoreLeadingWhitespacesInQuotes_and_ignoreTrailingWhitespacesInQuotes.
@Test
void should_honor_ignoreLeadingWhitespacesInQuotes_and_ignoreTrailingWhitespacesInQuotes() throws Exception {
Path file = Files.createTempFile("test", ".csv");
Files.write(file, Collections.singleton("\" foo \""));
CSVConnector connector = new CSVConnector();
Config settings = TestConfigUtils.createTestConfig("dsbulk.connector.csv", "url", StringUtils.quoteJson(file), "ignoreLeadingWhitespacesInQuotes", false, "ignoreTrailingWhitespacesInQuotes", false, "header", false);
connector.configure(settings, true, true);
connector.init();
List<Record> records = Flux.merge(connector.read()).collectList().block();
assertThat(records).hasSize(1);
assertThat(records.get(0).getFieldValue(new DefaultIndexedField(0))).isEqualTo(" foo ");
connector.close();
}
use of com.datastax.oss.dsbulk.connectors.api.DefaultIndexedField in project dsbulk by datastax.
the class CSVConnectorTest method should_honor_emptyValue_when_reading.
@ParameterizedTest
@MethodSource
void should_honor_emptyValue_when_reading(String quote, String emptyValue, String expected) throws Exception {
Path file = Files.createTempFile("test", ".csv");
Files.write(file, Collections.singleton(Strings.repeat(quote, 2)));
CSVConnector connector = new CSVConnector();
Config settings = TestConfigUtils.createTestConfig("dsbulk.connector.csv", "url", StringUtils.quoteJson(file), "quote", StringUtils.quoteJson(quote), "emptyValue", StringUtils.quoteJson(emptyValue), "header", false);
connector.configure(settings, true, true);
connector.init();
List<Record> records = Flux.merge(connector.read()).collectList().block();
assertThat(records).hasSize(1);
assertThat(records.get(0).getFieldValue(new DefaultIndexedField(0))).isEqualTo(expected);
connector.close();
}
Aggregations