Search in sources :

Example 61 with DataSetRow

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

the class CompareNumbersTest method should_apply_on_column_equals_constant_1.

@Test
public void should_apply_on_column_equals_constant_1() {
    // given
    DataSetRow row = getRow("05", "5", "Done !");
    parameters.put(CompareNumbers.MODE_PARAMETER, CompareNumbers.CONSTANT_MODE);
    parameters.put(CompareNumbers.CONSTANT_VALUE, "6");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    DataSetRow expected = getRow("05", "5", "Done !", "false");
    assertEquals(expected, row);
}
Also used : DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Example 62 with DataSetRow

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

the class CompareNumbersTest method test_apply_inplace.

@Test
public void test_apply_inplace() {
    // given
    DataSetRow row = getRow("5", "3", "Done !");
    // when
    parameters.put(ActionsUtils.CREATE_NEW_COLUMN, "false");
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    DataSetRow expected = getRow("false", "3", "Done !");
    assertEquals(expected, row);
}
Also used : DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Example 63 with DataSetRow

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

the class CompareNumbersTest method should_fail_constant_missing_operand.

@Test
public void should_fail_constant_missing_operand() {
    // given
    DataSetRow row = getRow("5", "3", "Done !");
    parameters.remove(NumericOperations.OPERAND_PARAMETER);
    parameters.put(NumericOperations.MODE_PARAMETER, NumericOperations.CONSTANT_MODE);
    parameters.put(ImplicitParameters.COLUMN_ID.getKey().toLowerCase(), "0000");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(row.get("0000"), "5");
    assertEquals(row.get("0001"), "3");
    assertEquals(row.get("0002"), "Done !");
}
Also used : DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Example 64 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.

@Test
public void should_set_new_column_name() {
    // 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();
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    final ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("source_eq_selected?").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)

Example 65 with DataSetRow

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

the class CompareNumbersTest method should_apply_on_column_not_valid.

@Test
public void should_apply_on_column_not_valid() {
    // given
    DataSetRow row = getRow("5", "Beer", "Done !");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    DataSetRow expected = getRow("5", "Beer", "Done !", "");
    assertEquals(expected, row);
}
Also used : 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