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);
}
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);
}
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 !");
}
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);
}
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);
}
Aggregations