use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class CSVSerializerTest method should_use_custom_import_parameters_empty_enclosure.
// https://jira.talendforge.org/browse/TDP-4602
@Test
public void should_use_custom_import_parameters_empty_enclosure() 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_empty_enclosure.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_empty_escape.
// https://jira.talendforge.org/browse/TDP-4602
@Test
public void should_use_custom_import_parameters_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(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_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_backslash.
/**
* Please have a look at <a href="https://jira.talendforge.org/browse/TDP-1623>TDP-1623</a>
*/
@Test
public void should_serialize_csv_with_backslash() throws IOException {
InputStream inputStream = this.getClass().getResourceAsStream("tdp-1623_backslash_not_imported.csv");
DataSetMetadata datasetMetadata = getSimpleDataSetMetadata("City");
InputStream input = serializer.serialize(inputStream, datasetMetadata, -1);
String actual = IOUtils.toString(input, UTF_8);
String expected = "[{\"0000\":\"Carson City\\\\Seine\"}]";
Assert.assertEquals(expected, actual);
}
use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class CSVSerializerTest method shouldManageSpecificTextEnclosureChar.
/**
* Please, have a look at <a href="https://jira.talendforge.org/browse/TDP-2366">TDP-2366</a>
*/
@Test
public void shouldManageSpecificTextEnclosureChar() throws IOException {
// given (text enclosing separator is ¤ so that " in original CSV are ignored)
InputStream inputStream = this.getClass().getResourceAsStream("with_quote_in_text.csv");
DataSetMetadata datasetMetadata = getSimpleDataSetMetadata("City", "code", "Description");
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("with_quote_in_text.json"), UTF_8);
JSONAssert.assertEquals(expected, actual, false);
}
use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.
the class HtmlSchemaParserTest method should_not_accept_html_update.
@Test
public void should_not_accept_html_update() throws Exception {
final DataSetMetadata metadata = metadataBuilder.metadata().id("tata").formatFamilyId("formatGuess#html").build();
assertFalse(parser.accept(metadata));
}
Aggregations