Search in sources :

Example 16 with RowMetadata

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

the class SplitTest method should_update_metadata_twice.

@Test
public void should_update_metadata_twice() {
    // given
    final List<ColumnMetadata> input = new ArrayList<>();
    input.add(createMetadata("0000", "recipe"));
    input.add(createMetadata("0001", "steps"));
    input.add(createMetadata("0002", "last update"));
    final RowMetadata rowMetadata = new RowMetadata(input);
    final List<ColumnMetadata> expected = new ArrayList<>();
    expected.add(createMetadata("0000", "recipe"));
    expected.add(createMetadata("0001", "steps"));
    expected.add(createMetadata("0005", "steps_split_1"));
    expected.add(createMetadata("0006", "steps_split_2"));
    expected.add(createMetadata("0003", "steps_split_1"));
    expected.add(createMetadata("0004", "steps_split_2"));
    expected.add(createMetadata("0002", "last update"));
    // when
    ActionTestWorkbench.test(rowMetadata, actionRegistry, factory.create(action, parameters), factory.create(action, parameters));
    assertEquals(expected, rowMetadata.getColumns());
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) ArrayList(java.util.ArrayList) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Example 17 with RowMetadata

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

the class SubstringTest method should_update_metadata_twice.

@Test
public void should_update_metadata_twice() {
    // given
    final List<ColumnMetadata> input = new ArrayList<>();
    input.add(createMetadata("0000", "recipe"));
    input.add(createMetadata("0001", "steps"));
    input.add(createMetadata("0002", "last update"));
    final RowMetadata rowMetadata = new RowMetadata(input);
    final DataSetRow row = new DataSetRow(rowMetadata);
    final List<ColumnMetadata> expected = new ArrayList<>();
    expected.add(createMetadata("0000", "recipe"));
    expected.add(createMetadata("0001", "steps"));
    expected.add(createMetadata("0004", "steps_substring"));
    expected.add(createMetadata("0003", "steps_substring"));
    expected.add(createMetadata("0002", "last update"));
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters), 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)

Example 18 with RowMetadata

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

the class SubstringTest method should_update_metadata.

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

Example 19 with RowMetadata

use of org.talend.dataprep.api.dataset.RowMetadata 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)

Example 20 with RowMetadata

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

the class ExtractStringTokensTest method should_update_metadata_twice.

@Test
public void should_update_metadata_twice() {
    // given
    final List<ColumnMetadata> input = new ArrayList<>();
    input.add(createMetadata("0000", "recipe"));
    input.add(createMetadata("0001", "steps"));
    input.add(createMetadata("0002", "last update"));
    final RowMetadata rowMetadata = new RowMetadata(input);
    final List<ColumnMetadata> expected = new ArrayList<>();
    expected.add(createMetadata("0000", "recipe"));
    expected.add(createMetadata("0001", "steps"));
    expected.add(createMetadata("0005", "steps_part_1"));
    expected.add(createMetadata("0006", "steps_part_2"));
    expected.add(createMetadata("0003", "steps_part_1"));
    expected.add(createMetadata("0004", "steps_part_2"));
    expected.add(createMetadata("0002", "last update"));
    // when
    ActionTestWorkbench.test(rowMetadata, actionRegistry, factory.create(action, parameters), factory.create(action, parameters));
    assertEquals(expected, rowMetadata.getColumns());
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Aggregations

RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)199 Test (org.junit.Test)130 DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)112 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)87 AbstractMetadataBaseTest (org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)68 HashMap (java.util.HashMap)48 ActionContext (org.talend.dataprep.transformation.api.action.context.ActionContext)21 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)20 RunnableAction (org.talend.dataprep.transformation.actions.common.RunnableAction)19 TransformationContext (org.talend.dataprep.transformation.api.action.context.TransformationContext)18 ArrayList (java.util.ArrayList)16 DataSet (org.talend.dataprep.api.dataset.DataSet)11 List (java.util.List)9 Statistics (org.talend.dataprep.api.dataset.statistics.Statistics)9 Before (org.junit.Before)7 SemanticDomain (org.talend.dataprep.api.dataset.statistics.SemanticDomain)6 Preparation (org.talend.dataprep.api.preparation.Preparation)6 Response (com.jayway.restassured.response.Response)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Logger (org.slf4j.Logger)5