use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ChangeNumberFormatTest method test_TDP_1108_invalid_pattern.
@Test
public void test_TDP_1108_invalid_pattern() throws Exception {
// given
final DataSetRow row = getRow("toto", "012.50", "tata");
parameters.put(TARGET_PATTERN, "custom");
parameters.put(TARGET_PATTERN + "_" + CUSTOM, "# ##0,#");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "012.50", "tata");
assertEquals(expectedRow.values(), row.values());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ChangeNumberFormatTest method should_process_row_SCIENTIFIC.
@Test
public void should_process_row_SCIENTIFIC() throws Exception {
// given
final DataSetRow row = getRow("toto", "1.23E+3", "tata");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "1,230", "tata");
assertEquals(expectedRow.values(), row.values());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ChangeNumberFormatTest method should_do_nothing_from_wrong_pattern.
@Test
public void should_do_nothing_from_wrong_pattern() throws Exception {
// given
final DataSetRow row = getRow("toto", "1'012.50", "tata");
parameters.put(TARGET_PATTERN, "wrong_pattern");
// when --> IllegalArgumentException
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "1'012.50", "tata");
assertEquals(expectedRow.values(), row.values());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ChangeNumberFormatTest method should_process_row_alt_pattern_alt_seps_empty_custom.
@Test
public void should_process_row_alt_pattern_alt_seps_empty_custom() throws Exception {
// given
final DataSetRow row = getRow("toto", "1012.45", "tata");
parameters.put(TARGET_PATTERN, CUSTOM);
parameters.put(TARGET_PATTERN + "_" + CUSTOM, "#,##0.000");
parameters.put(TARGET + DECIMAL + SEPARATOR, "/");
parameters.put(TARGET + GROUPING + SEPARATOR, CUSTOM);
parameters.put(TARGET + GROUPING + SEPARATOR + "_" + CUSTOM, "");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "1012/450", "tata");
assertEquals(expectedRow.values(), row.values());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ChangeNumberFormatTest method test_apply_in_newcolumn_with_empty_value.
@Test
public void test_apply_in_newcolumn_with_empty_value() throws Exception {
// given
final DataSetRow row = getRow("toto", "", "tata");
parameters.put(ActionsUtils.CREATE_NEW_COLUMN, "true");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "", "tata", "");
assertEquals(expectedRow.values(), row.values());
ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("0001_formatted").type(Type.STRING).build();
ColumnMetadata actual = row.getRowMetadata().getById("0003");
assertEquals(expected, actual);
}
Aggregations