use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class RemoveRepeatedCharsTest method should_remove_custom_value.
@Test
public void should_remove_custom_value() {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "haand");
final DataSetRow row = new DataSetRow(values);
initParameterCustom("a");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals("hand", row.get("0000"));
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class RemoveRepeatedCharsTest method test_apply_in_newcolumn.
@Test
public void test_apply_in_newcolumn() {
// given
final Map<String, String> values = new LinkedHashMap<>();
values.put("0000", "ab c d");
values.put("0001", "tagadaa");
values.put("0002", "May 20th 2015");
final DataSetRow row = new DataSetRow(values);
final Map<String, Object> expectedValues = new LinkedHashMap<>();
expectedValues.put("0000", "ab c d");
expectedValues.put("0003", "ab c d");
expectedValues.put("0001", "tagadaa");
expectedValues.put("0002", "May 20th 2015");
initParametersWhitespace();
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_without_consecutive").type(Type.STRING).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 ReplaceCellValueTest method test_apply_inplace.
@Test
public void test_apply_inplace() {
// given
final Long rowId = 1L;
final String joe = "Joe";
final DataSetRow row = getRow(joe);
row.setTdpId(rowId);
final Map<String, String> parameters = getParameters(rowId, joe, "Jimmy");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertThat(row.get("0000"), is("Jimmy"));
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ReplaceOnValueTest method test_TDP_1204.
@Test
public void test_TDP_1204() {
// given
final String columnId = "0000";
final Map<String, String> values = new HashMap<>();
values.put(columnId, "");
final DataSetRow row = new DataSetRow(values);
final Map<String, String> parameters = new HashMap<>();
parameters.put(CELL_VALUE_PARAMETER, generateJson("", ReplaceOnValueHelper.EQUALS_MODE));
parameters.put(REPLACE_VALUE_PARAMETER, "Jimmy");
parameters.put(REPLACE_ENTIRE_CELL_PARAMETER, "true");
parameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "column");
parameters.put(ImplicitParameters.COLUMN_ID.getKey().toLowerCase(), columnId);
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertThat(row.get(columnId), is("Jimmy"));
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ReplaceOnValueTest method test_apply_inplace.
@Test
public void test_apply_inplace() {
// given
final String columnId = "0000";
final Map<String, String> values = new HashMap<>();
values.put(columnId, "James Hetfield");
final DataSetRow row = new DataSetRow(values);
final Map<String, String> parameters = new HashMap<>();
parameters.put(CELL_VALUE_PARAMETER, generateJson("James", ReplaceOnValueHelper.STARTS_WITH_MODE));
parameters.put(REPLACE_VALUE_PARAMETER, "Jimmy");
parameters.put(REPLACE_ENTIRE_CELL_PARAMETER, "true");
parameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "column");
parameters.put(ImplicitParameters.COLUMN_ID.getKey().toLowerCase(), columnId);
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertThat(row.get(columnId), is("Jimmy"));
}
Aggregations