Search in sources :

Example 56 with DataSetRow

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

the class ChangeNumberFormatTest method should_process_row_alt_pattern_alt_seps.

@Test
public void should_process_row_alt_pattern_alt_seps() throws Exception {
    // given
    final DataSetRow row = getRow("toto", "1012.45", "tata");
    parameters.put(TARGET_PATTERN, CUSTOM);
    parameters.put(TARGET_PATTERN + "_" + CUSTOM, "#,##0.000");
    parameters.put(TARGET + DECIMAL + SEPARATOR, "/");
    parameters.put(TARGET + GROUPING + SEPARATOR, "_");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    final DataSetRow expectedRow = getRow("toto", "1_012/450", "tata");
    assertEquals(expectedRow.values(), row.values());
}
Also used : DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 57 with DataSetRow

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

the class ChangeNumberFormatTest method should_process_row_when_value_is_empty.

@Test
public void should_process_row_when_value_is_empty() throws Exception {
    // given
    DataSetRow row = getRow("toto", "", "tata");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then (values should be unchanged)
    final DataSetRow expectedRow = getRow("toto", "", "tata");
    assertEquals(expectedRow.values(), row.values());
}
Also used : DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 58 with DataSetRow

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

the class ChangeNumberFormatTest method test_TDP_1108_empty_pattern.

@Test
public void test_TDP_1108_empty_pattern() throws Exception {
    // given
    final DataSetRow row = getRow("toto", "012.50", "tata");
    parameters.put(TARGET_PATTERN, "custom");
    parameters.put(TARGET_PATTERN + "_" + CUSTOM, "");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    final DataSetRow expectedRow = getRow("toto", "12.5", "tata");
    assertEquals(expectedRow.values(), row.values());
}
Also used : DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 59 with DataSetRow

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

the class ChangeNumberFormatTest method should_process_row_percentage.

@Test
public void should_process_row_percentage() throws Exception {
    // given
    final DataSetRow row = getRow("toto", "12.50%", "tata");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    final DataSetRow expectedRow = getRow("toto", "0.12", "tata");
    assertEquals(expectedRow.values(), row.values());
}
Also used : DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 60 with DataSetRow

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

the class CompareNumbersTest method should_set_new_column_name_constant.

@Test
public void should_set_new_column_name_constant() {
    // given
    final DataSetRow row = // 
    builder().with(// 
    value("5").type(Type.STRING).name("source")).with(// 
    value("3").type(Type.STRING).name("selected")).with(// 
    value("Done !").type(Type.STRING)).build();
    parameters.put(CompareNumbers.MODE_PARAMETER, CompareNumbers.CONSTANT_MODE);
    parameters.put(CompareNumbers.CONSTANT_VALUE, "3");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    final ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("source_eq_3?").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) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Aggregations

DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)729 Test (org.junit.Test)688 AbstractMetadataBaseTest (org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)518 HashMap (java.util.HashMap)235 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)111 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)81 LinkedHashMap (java.util.LinkedHashMap)45 RunnableAction (org.talend.dataprep.transformation.actions.common.RunnableAction)21 ActionContext (org.talend.dataprep.transformation.api.action.context.ActionContext)16 TransformationContext (org.talend.dataprep.transformation.api.action.context.TransformationContext)16 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)14 ArrayList (java.util.ArrayList)13 ChangeDatePatternTest (org.talend.dataprep.transformation.actions.date.ChangeDatePatternTest)13 ByteArrayOutputStream (java.io.ByteArrayOutputStream)12 AbstractTransformerWriterTest (org.talend.dataprep.transformation.api.transformer.AbstractTransformerWriterTest)12 List (java.util.List)11 PatternFrequency (org.talend.dataprep.api.dataset.statistics.PatternFrequency)11 DataSet (org.talend.dataprep.api.dataset.DataSet)10 Stream (java.util.stream.Stream)6 TDPException (org.talend.dataprep.exception.TDPException)6