use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ChangeNumberFormatTest method TDP_1361.
/**
* Format number does not work if there is a null or an invalid in the column.
* Values after a null or an invalid value (which is not a number) were not formatted by the transformation.
* Have look at https://jira.talendforge.org/browse/TDP-1361
*/
@Test
public void TDP_1361() throws Exception {
// given
final DataSetRow row1 = getRow("toto", "1.5E-11", "tata");
final DataSetRow row2 = getRow("titi", "azerty", "tata");
final DataSetRow row3 = getRow("tutu", "010", "tata");
Collection<DataSetRow> rows = Arrays.asList(row1, row2, row3);
parameters.put(FROM_SEPARATORS, US_SEPARATORS);
parameters.put(TARGET_PATTERN, SCIENTIFIC);
// when
ActionTestWorkbench.test(rows, actionRegistry, factory.create(action, parameters));
// then (values should now be compliant with scientific notation)
final DataSetRow expectedRow1 = getRow("toto", "1.5E-11", "tata");
final DataSetRow expectedRow2 = getRow("titi", "azerty", "tata");
final DataSetRow expectedRow3 = getRow("tutu", "1E1", "tata");
assertEquals(expectedRow1.values(), row1.values());
assertEquals(expectedRow2.values(), row2.values());
assertEquals(expectedRow3.values(), row3.values());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ChangeNumberFormatTest method should_process_row_to_CH.
@Test
public void should_process_row_to_CH() throws Exception {
// given
final DataSetRow row = getRow("toto", "1.012,50", "tata");
parameters.put(FROM_SEPARATORS, EU_SEPARATORS);
parameters.put(TARGET_PATTERN, CH_PATTERN);
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "1'012.5", "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_TDP_2354.
@Test
public void test_TDP_2354() throws Exception {
// given
final DataSetRow row = getRow("toto", "993,886", "tata");
parameters.put(FROM_SEPARATORS, US_SEPARATORS);
parameters.put(TARGET_PATTERN, EU_PATTERN);
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "993 886", "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_percentage.
@Test
public void should_process_row_alt_pattern_percentage() throws Exception {
// given
final DataSetRow row = getRow("toto", "0.12", "tata");
parameters.put(TARGET_PATTERN, CUSTOM);
parameters.put(TARGET_PATTERN + "_" + CUSTOM, "#%");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "12%", "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.
@Test
public void should_process_row_alt_pattern_alt_seps_empty() 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, "");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "1012/450", "tata");
assertEquals(expectedRow.values(), row.values());
}
Aggregations