Search in sources :

Example 56 with ColumnMetadata

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

the class ExtractUrlTokensTest method should_accept_column.

@Test
public void should_accept_column() {
    ColumnMetadata column = getColumn(Type.STRING);
    column.setDomain("url");
    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 57 with ColumnMetadata

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

the class ExtractUrlTokensTest 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 url");
    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 58 with ColumnMetadata

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

the class ExtractUrlTokensTest method testAdapt.

@Test
public void testAdapt() throws Exception {
    assertThat(action.adapt((ColumnMetadata) null), is(action));
    ColumnMetadata column = column().name("myColumn").id(0).type(Type.STRING).build();
    assertThat(action.adapt(column), is(action));
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 59 with ColumnMetadata

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

the class FormatPhoneNumberTest method test_apply_in_newcolumn.

@Test
public void test_apply_in_newcolumn() {
    // given
    parameters.put(FormatPhoneNumber.REGIONS_PARAMETER_CONSTANT_MODE, "FR");
    parameters.put(FormatPhoneNumber.FORMAT_TYPE_PARAMETER, FormatPhoneNumber.TYPE_INTERNATIONAL);
    parameters.put(OtherColumnParameters.MODE_PARAMETER, OtherColumnParameters.CONSTANT_MODE);
    parameters.put(ActionsUtils.CREATE_NEW_COLUMN, "true");
    Map<String, String> values = new HashMap<>();
    values.put("0000", "+33656965822");
    DataSetRow row = new DataSetRow(values);
    Map<String, Object> expectedValues = new LinkedHashMap<>();
    expectedValues.put("0000", "+33656965822");
    expectedValues.put("0001", "+33 6 56 96 58 22");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(expectedValues, row.values());
    ColumnMetadata expected = ColumnMetadata.Builder.column().id(1).name("0000_formatted").type(Type.STRING).build();
    ColumnMetadata actual = row.getRowMetadata().getById("0001");
    assertEquals(expected, actual);
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) LinkedHashMap(java.util.LinkedHashMap) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Example 60 with ColumnMetadata

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

the class ContainsTest method should_set_new_column_name_column_mode.

@Test
public void should_set_new_column_name_column_mode() {
    // given
    final DataSetRow row = // 
    builder().with(// 
    value("first").type(Type.STRING).name("source")).with(// 
    value("second").type(Type.STRING).name("name")).with(// 
    value("Done !").type(Type.STRING)).build();
    parameters.put(Contains.MODE_PARAMETER, Contains.OTHER_COLUMN_MODE);
    parameters.put(Contains.SELECTED_COLUMN_PARAMETER, "0000");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    final ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("name_contains_source").type(Type.BOOLEAN).build();
    ColumnMetadata actual = row.getRowMetadata().getById("0003");
    assertEquals(expected, actual);
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) 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