use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class SplitTest method should_split_row_with_separator_at_the_end.
@Test
public void should_split_row_with_separator_at_the_end() {
// given
final DataSetRow row = getRow("lorem bacon", "Bacon ", "01/01/2015");
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("0000", "lorem bacon");
expectedValues.put("0001", "Bacon ");
expectedValues.put("0003", "Bacon");
expectedValues.put("0004", "");
expectedValues.put("0002", "01/01/2015");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expectedValues, row.values());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class SubstringTest method should_substring_to_the_beginning_when_end_index_is_negative.
@Test
public void should_substring_to_the_beginning_when_end_index_is_negative() {
// given
parameters.put(TO_INDEX_PARAMETER, "-1");
final Map<String, String> values = new HashMap<>();
values.put("0000", "lorem bacon");
values.put("0001", "Bac");
values.put("0002", "01/01/2015");
final DataSetRow row = new DataSetRow(values);
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("0000", "lorem bacon");
expectedValues.put("0001", "Bac");
expectedValues.put("0003", "");
expectedValues.put("0002", "01/01/2015");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expectedValues, row.values());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class SubstringTest method should_substring_n_before_end_3.
@Test
public void should_substring_n_before_end_3() throws IOException {
// given
parameters.put(FROM_MODE_PARAMETER, Substring.FROM_INDEX_PARAMETER);
parameters.put(FROM_INDEX_PARAMETER, "6");
parameters.put(TO_MODE_PARAMETER, Substring.TO_N_BEFORE_END_PARAMETER);
parameters.put(TO_N_BEFORE_END_PARAMETER, "1");
final Map<String, String> values = new HashMap<>();
values.put("0000", "lorem bacon");
values.put("0001", "Bacon ipsum");
values.put("0002", "01/01/2015");
final DataSetRow row = new DataSetRow(values);
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("0000", "lorem bacon");
expectedValues.put("0001", "Bacon ipsum");
expectedValues.put("0003", "ipsu");
expectedValues.put("0002", "01/01/2015");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expectedValues, row.values());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class SubstringTest method should_substring_to_the_end_when_end_index_is_too_big_and_out_of_bound.
@Test
public void should_substring_to_the_end_when_end_index_is_too_big_and_out_of_bound() {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "lorem bacon");
values.put("0001", "Bacon ip");
values.put("0002", "01/01/2015");
final DataSetRow row = new DataSetRow(values);
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("0000", "lorem bacon");
expectedValues.put("0001", "Bacon ip");
expectedValues.put("0003", " ip");
expectedValues.put("0002", "01/01/2015");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expectedValues, row.values());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class SubstringTest method should_substring_to_the_beginning_when_n_before_end_is_too_big.
@Test
public void should_substring_to_the_beginning_when_n_before_end_is_too_big() throws IOException {
// given
parameters.put(FROM_INDEX_PARAMETER, "1");
parameters.put(TO_MODE_PARAMETER, Substring.TO_N_BEFORE_END_PARAMETER);
parameters.put(TO_N_BEFORE_END_PARAMETER, "15");
final Map<String, String> values = new HashMap<>();
values.put("0000", "lorem bacon");
values.put("0001", "Bacon");
values.put("0002", "01/01/2015");
final DataSetRow row = new DataSetRow(values);
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("0000", "lorem bacon");
expectedValues.put("0001", "Bacon");
expectedValues.put("0003", "");
expectedValues.put("0002", "01/01/2015");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expectedValues, row.values());
}
Aggregations