Search in sources :

Example 66 with ColumnMetadata

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

the class PaddingTest method test_apply_in_newcolumn.

@Test
public void test_apply_in_newcolumn() {
    // given
    final Map<String, String> values = new HashMap<>();
    values.put("0000", "Vincent");
    values.put("0001", "10");
    values.put("0002", "May 20th 2015");
    final DataSetRow row = new DataSetRow(values);
    final Map<String, Object> expectedValues = new HashMap<>();
    expectedValues.put("0000", "Vincent");
    expectedValues.put("0001", "10");
    expectedValues.put("0002", "May 20th 2015");
    expectedValues.put("0003", "0010");
    parameters.put(CREATE_NEW_COLUMN, "true");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(expectedValues, row.values());
    ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("0000_padded").type(Type.STRING).build();
    ColumnMetadata actual = row.getRowMetadata().getById("0003");
    assertEquals(expected, actual);
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) HashMap(java.util.HashMap) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 67 with ColumnMetadata

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

the class ProperCaseTest 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 68 with ColumnMetadata

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

the class ProperCaseTest method test_apply_in_newcolumn.

@Test
public void test_apply_in_newcolumn() {
    // given
    final Map<String, String> values = new LinkedHashMap<>();
    values.put("0000", "jimi HENDRIX experience");
    values.put("0001", "experience");
    values.put("0002", "May 20th 2015");
    final DataSetRow row = new DataSetRow(values);
    final Map<String, Object> expectedValues = new LinkedHashMap<>();
    expectedValues.put("0000", "jimi HENDRIX experience");
    expectedValues.put("0001", "experience");
    expectedValues.put("0002", "May 20th 2015");
    expectedValues.put("0003", "Jimi Hendrix Experience");
    parameters.put(ActionsUtils.CREATE_NEW_COLUMN, "true");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(expectedValues, row.values());
    ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("0000_title").type(Type.STRING).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) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 69 with ColumnMetadata

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

the class LogarithmTest method assertColumnWithResultCreated.

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

Example 70 with ColumnMetadata

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

the class MinTest method assertColumnWithResultCreated.

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

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