use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ModifyDateTest method should_process_row_other_column_float_number.
@Test
public void should_process_row_other_column_float_number() throws Exception {
// given
final DataSetRow row = //
builder().with(//
value("toto").type(Type.STRING).name("recipe")).with(//
value("04/25/1999").type(Type.DATE).name("recipe").statistics(getDateTestJsonAsStream("statistics_MM_dd_yyyy.json"))).with(//
value("5.0").type(Type.STRING).name("last update")).build();
parameters.put(MODE_PARAMETER, OTHER_COLUMN_MODE);
parameters.put(SELECTED_COLUMN_PARAMETER, "0002");
parameters.put(TIME_UNIT_PARAMETER, DAYS.name());
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "04/30/1999", "5.0");
assertEquals(expectedRow.values(), row.values());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ModifyDateTest method should_check_new_pattern_parameter_when_dealing_with_row_metadata.
@Test(expected = TalendRuntimeException.class)
public void should_check_new_pattern_parameter_when_dealing_with_row_metadata() {
// given
Map<String, String> missingParameters = new HashMap<>();
missingParameters.put("column_id", "0000");
missingParameters.put(ModifyDate.NEW_PATTERN, "toto");
// when
ActionTestWorkbench.test(new DataSetRow(Collections.emptyMap()), actionRegistry, factory.create(action, missingParameters));
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class TimestampToDateTest method test_apply_inplace.
@Test
public void test_apply_inplace() {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "lorem bacon");
values.put("0001", "0");
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", "01-01-1970");
expectedValues.put("0002", "01/01/2015");
parameters.put(ActionsUtils.CREATE_NEW_COLUMN, "false");
// 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 TimestampToDateTest method test_TDP_925.
/**
* Behavior of this case, originally defined TDP-925, has been changed with TDP-1108.
*/
@Test
public void test_TDP_925() {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "lorem bacon");
values.put("0001", "1441815638");
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", "1441815638");
expectedValues.put("0002", "01/01/2015");
parameters.put("new_pattern", "custom");
parameters.put("custom_date_pattern", "not a valid date pattern");
// 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 DeleteAllEmptyTest method should_not_delete_with_keep.
@Test
public void should_not_delete_with_keep() {
// given
// row 1
final DataSetRow row1 = getRow("David", "Bowie");
// row 2
final DataSetRow row2 = getRow("David", "Bowie");
// row 3
final DataSetRow row3 = getRow(" ", " ");
// row4
final DataSetRow row4 = getRow("", "");
// row 5
final DataSetRow row5 = getRow("", "\n\t");
parameters.put(DeleteAllEmpty.ACTION_PARAMETER, DeleteAllEmpty.KEEP);
// when
ActionTestWorkbench.test(Arrays.asList(row1, row2, row3, row4, row5), actionRegistry, factory.create(action, parameters));
// then
assertThat(row1.isDeleted(), is(false));
assertThat(row2.isDeleted(), is(false));
assertThat(row3.isDeleted(), is(false));
assertThat(row4.isDeleted(), is(true));
assertThat(row5.isDeleted(), is(false));
}
Aggregations