Search in sources :

Example 76 with DataSetMetadata

use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.

the class CompositeFormatDetectorTest method guess_html_format_fail.

@Test
public void guess_html_format_fail() throws Exception {
    String fileName = "html/foo.html";
    DataSetMetadata datasetMetadata = ioTestUtils.getSimpleDataSetMetadata();
    datasetMetadata.setEncoding("UTF-16");
    Format actual = formatDetector.detect(this.getClass().getResourceAsStream(fileName));
    assertFalse(actual.getFormatFamily() instanceof HtmlFormatFamily);
}
Also used : HtmlFormatFamily(org.talend.dataprep.schema.html.HtmlFormatFamily) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Test(org.junit.Test)

Example 77 with DataSetMetadata

use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.

the class CompositeFormatDetectorTest method guess_html_format_success.

@Test
public void guess_html_format_success() throws Exception {
    String fileName = "html/sales-force.xls";
    DataSetMetadata datasetMetadata = ioTestUtils.getSimpleDataSetMetadata();
    datasetMetadata.setEncoding("UTF-16");
    Charset charset = new HtmlEncodingDetector().detect(this.getClass().getResourceAsStream(fileName), new Metadata());
    Format actual = formatDetector.detect(this.getClass().getResourceAsStream(fileName));
    assertTrue(actual.getFormatFamily() instanceof HtmlFormatFamily);
    assertTrue(StringUtils.equals("UTF-16", actual.getEncoding()));
}
Also used : Metadata(org.apache.tika.metadata.Metadata) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) HtmlFormatFamily(org.talend.dataprep.schema.html.HtmlFormatFamily) Charset(java.nio.charset.Charset) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) HtmlEncodingDetector(org.apache.tika.parser.html.HtmlEncodingDetector) Test(org.junit.Test)

Example 78 with DataSetMetadata

use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.

the class IoTestUtils method getDataSetMetadata.

/**
 * @return a ready to use dataset.
 */
public DataSetMetadata getDataSetMetadata() {
    DataSetMetadata datasetMetadata = metadataBuilder.metadata().id("123456789").build();
    datasetMetadata.getContent().addParameter(CSVFormatFamily.SEPARATOR_PARAMETER, ";");
    return datasetMetadata;
}
Also used : DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata)

Example 79 with DataSetMetadata

use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.

the class CSVSchemaParserTest method should_not_accept_xls_update.

@Test
public void should_not_accept_xls_update() throws Exception {
    final DataSetMetadata metadata = metadataBuilder.metadata().id("tata").formatFamilyId("formatGuess#xls").build();
    assertFalse(csvSchemaParser.accept(metadata));
}
Also used : DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Test(org.junit.Test)

Example 80 with DataSetMetadata

use of org.talend.dataprep.api.dataset.DataSetMetadata in project data-prep by Talend.

the class CSVSchemaParserTest 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(csvSchemaParser.accept(metadata));
}
Also used : DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Test(org.junit.Test)

Aggregations

DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)192 Test (org.junit.Test)126 DataSetBaseTest (org.talend.dataprep.dataset.DataSetBaseTest)63 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)48 InputStream (java.io.InputStream)45 Matchers.containsString (org.hamcrest.Matchers.containsString)28 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)28 TDPException (org.talend.dataprep.exception.TDPException)26 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)20 DataSetServiceTest (org.talend.dataprep.dataset.service.DataSetServiceTest)20 ApiOperation (io.swagger.annotations.ApiOperation)18 DataSet (org.talend.dataprep.api.dataset.DataSet)18 Type (org.talend.dataprep.api.type.Type)17 Timed (org.talend.dataprep.metrics.Timed)17 DistributedLock (org.talend.dataprep.lock.DistributedLock)16 Autowired (org.springframework.beans.factory.annotation.Autowired)14 DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)14 IOException (java.io.IOException)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ArrayList (java.util.ArrayList)12