use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class CSVSchemaParserTest method should_accept_csv_update.
@Test
public void should_accept_csv_update() throws Exception {
final DataSetMetadata metadata = metadataBuilder.metadata().id("toto").formatFamilyId("formatGuess#csv").build();
assertTrue(csvSchemaParser.accept(metadata));
}
use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class CSVSerializerTest method should_use_custom_import_parameters_default_empty_escape.
// https://jira.talendforge.org/browse/TDP-4602
@Test
public void should_use_custom_import_parameters_default_empty_escape() throws IOException {
// given (text escape char is |)
InputStream inputStream = this.getClass().getResourceAsStream("tdp-4602_custom_param_csv_import.csv");
DataSetMetadata datasetMetadata = getSimpleDataSetMetadata("column1", "column2");
datasetMetadata.getContent().addParameter(SEPARATOR_PARAMETER, ",");
datasetMetadata.getContent().addParameter(TEXT_ENCLOSURE_CHAR, "+");
// when
InputStream input = serializer.serialize(inputStream, datasetMetadata, -1);
String actual = IOUtils.toString(input, UTF_8);
// then
final String expected = IOUtils.toString(this.getClass().getResourceAsStream("tdp-4602_custom_param_csv_import_default_escape.json"), UTF_8);
JSONAssert.assertEquals(expected, actual, false);
}
use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class CSVSerializerTest method should_serialize_csv_with_additional_values.
@Test
public void should_serialize_csv_with_additional_values() throws IOException {
InputStream inputStream = this.getClass().getResourceAsStream("additional_values.csv");
DataSetMetadata datasetMetadata = getSimpleDataSetMetadata("name", "email");
InputStream input = serializer.serialize(inputStream, datasetMetadata, -1);
String actual = IOUtils.toString(input, UTF_8);
InputStream expected = this.getClass().getResourceAsStream("additional_values.csv_expected.json");
Assert.assertThat(actual, sameJSONAsFile(expected));
}
use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class CSVSerializerTest method should_use_custom_import_parameters_backslash_escape.
// https://jira.talendforge.org/browse/TDP-4602
@Test
public void should_use_custom_import_parameters_backslash_escape() throws IOException {
// given (text escape char is |)
InputStream inputStream = this.getClass().getResourceAsStream("tdp-4602_custom_param_csv_import.csv");
DataSetMetadata datasetMetadata = getSimpleDataSetMetadata("column1", "column2");
datasetMetadata.getContent().addParameter(SEPARATOR_PARAMETER, ",");
datasetMetadata.getContent().addParameter(ESCAPE_CHAR, "\\");
datasetMetadata.getContent().addParameter(TEXT_ENCLOSURE_CHAR, "+");
// when
InputStream input = serializer.serialize(inputStream, datasetMetadata, -1);
String actual = IOUtils.toString(input, UTF_8);
// then
final String expected = IOUtils.toString(this.getClass().getResourceAsStream("tdp-4602_custom_param_csv_import_backslash_escape.json"), UTF_8);
JSONAssert.assertEquals(expected, actual, false);
}
use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class CSVSerializerTest method should_use_custom_import_parameters_double_quote.
// https://jira.talendforge.org/browse/TDP-4579
@Test
public void should_use_custom_import_parameters_double_quote() throws IOException {
// given (text escape char is |)
InputStream inputStream = this.getClass().getResourceAsStream("test_4579_doublequote_import.csv");
DataSetMetadata datasetMetadata = getSimpleDataSetMetadata("City", "code", "Description");
datasetMetadata.getContent().addParameter(SEPARATOR_PARAMETER, ",");
datasetMetadata.getContent().addParameter(ESCAPE_CHAR, "");
datasetMetadata.getContent().addParameter(TEXT_ENCLOSURE_CHAR, "");
// when
InputStream input = serializer.serialize(inputStream, datasetMetadata, -1);
String actual = IOUtils.toString(input, UTF_8);
// then
final String expected = IOUtils.toString(this.getClass().getResourceAsStream("test_4579_doublequote_import.json"), UTF_8);
JSONAssert.assertEquals(expected, actual, false);
}
Aggregations