Search in sources :

Example 51 with ColumnMetadata

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

the class SinTest method assertColumnWithResultCreated.

private void assertColumnWithResultCreated(DataSetRow row) {
    ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("0000_sin").type(Type.DOUBLE).build();
    ColumnMetadata actual = row.getRowMetadata().getById("0003");
    assertEquals(expected, actual);
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata)

Example 52 with ColumnMetadata

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

the class SquareRootTest method assertColumnWithResultCreated.

private void assertColumnWithResultCreated(DataSetRow row) {
    ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("0000_square_root").type(Type.DOUBLE).build();
    ColumnMetadata actual = row.getRowMetadata().getById("0003");
    assertEquals(expected, actual);
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata)

Example 53 with ColumnMetadata

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

the class ExtractEmailDomainTest method should_not_accept_column.

@Test
public void should_not_accept_column() {
    assertFalse(action.acceptField(getColumn(Type.STRING)));
    assertFalse(action.acceptField(getColumn(Type.DATE)));
    assertFalse(action.acceptField(getColumn(Type.BOOLEAN)));
    assertFalse(action.acceptField(getColumn(Type.NUMERIC)));
    assertFalse(action.acceptField(getColumn(Type.INTEGER)));
    assertFalse(action.acceptField(getColumn(Type.DOUBLE)));
    assertFalse(action.acceptField(getColumn(Type.FLOAT)));
    ColumnMetadata column = getColumn(Type.STRING);
    column.setDomain("not an email");
    assertFalse(action.acceptField(column));
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 54 with ColumnMetadata

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

the class ExtractEmailDomainTest method should_accept_column.

@Test
public void should_accept_column() {
    ColumnMetadata column = getColumn(Type.STRING);
    column.setDomain("email");
    assertTrue(action.acceptField(column));
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 55 with ColumnMetadata

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

the class ExtractEmailDomainTest method test_metadata.

@Test
public void test_metadata() {
    // given
    final List<ColumnMetadata> input = new ArrayList<>();
    input.add(createMetadata("0000", "recipe"));
    input.add(createMetadata("0001", "email"));
    input.add(createMetadata("0002", "last update"));
    final DataSetRow row = new DataSetRow(new RowMetadata(input));
    final List<ColumnMetadata> expected = new ArrayList<>();
    expected.add(createMetadata("0000", "recipe"));
    expected.add(createMetadata("0001", "email"));
    expected.add(createMetadata("0003", "email_local"));
    expected.add(createMetadata("0004", "email_domain"));
    expected.add(createMetadata("0002", "last update"));
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(expected, row.getRowMetadata().getColumns());
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Aggregations

ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)320 Test (org.junit.Test)217 AbstractMetadataBaseTest (org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)115 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)86 DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)80 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)48 InputStream (java.io.InputStream)25 Type (org.talend.dataprep.api.type.Type)23 DataSetBaseTest (org.talend.dataprep.dataset.DataSetBaseTest)22 ArrayList (java.util.ArrayList)19 HashMap (java.util.HashMap)17 IOException (java.io.IOException)14 TDPException (org.talend.dataprep.exception.TDPException)14 Schema (org.talend.dataprep.schema.Schema)14 Autowired (org.springframework.beans.factory.annotation.Autowired)13 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 SemanticDomain (org.talend.dataprep.api.dataset.statistics.SemanticDomain)12 DataSetServiceTest (org.talend.dataprep.dataset.service.DataSetServiceTest)11 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)10