use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class SplitTest method test_TDP_876.
@Test
public void test_TDP_876() {
// given
final DataSetRow row = //
builder().with(//
value("lorem bacon").type(Type.STRING)).with(//
value("Bacon ipsum dolor amet swine leberkas pork belly").type(Type.STRING)).with(//
value("01/01/2015").type(Type.STRING)).build();
// when
//
ActionTestWorkbench.test(//
Collections.singletonList(row), // Test requires some analysis in asserts
analyzerService, actionRegistry, factory.create(action, parameters));
// then
final RowMetadata actual = row.getRowMetadata();
Statistics originalStats = actual.getById("0001").getStatistics();
final List<PatternFrequency> originalPatterns = originalStats.getPatternFrequencies();
assertFalse(originalPatterns.equals(actual.getById("0003").getStatistics().getPatternFrequencies()));
assertFalse(originalPatterns.equals(actual.getById("0004").getStatistics().getPatternFrequencies()));
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class SplitTest method should_split_underscore.
@Test
public void should_split_underscore() {
// given
final DataSetRow row = getRow("lorem bacon", "Bacon_ipsum", "01/01/2015");
parameters.put(Split.SEPARATOR_PARAMETER, Split.OTHER_STRING);
parameters.put(Split.MANUAL_SEPARATOR_PARAMETER_STRING, "_");
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("0000", "lorem bacon");
expectedValues.put("0001", "Bacon_ipsum");
expectedValues.put("0003", "Bacon");
expectedValues.put("0004", "ipsum");
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 SplitTest method should_split_row_no_separator.
@Test
public void should_split_row_no_separator() {
// 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 SplitTest method test_split_on_regex2.
@Test
public void test_split_on_regex2() {
// given
final DataSetRow row = getRow("lorem bacon", "Je vais bien (tout va bien)", "01/01/2015");
parameters.put(Split.SEPARATOR_PARAMETER, Split.OTHER_REGEX);
parameters.put(Split.MANUAL_SEPARATOR_PARAMETER_REGEX, "bien|fff");
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("0000", "lorem bacon");
expectedValues.put("0001", "Je vais bien (tout va bien)");
expectedValues.put("0003", "Je vais ");
expectedValues.put("0004", " (tout va bien)");
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 SplitTest method test_TDP_831_invalid_pattern.
@Test
public void test_TDP_831_invalid_pattern() {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "lorem bacon");
values.put("0001", "Je vais bien (tout va bien)");
values.put("0002", "01/01/2015");
final DataSetRow row = new DataSetRow(values);
parameters.put(Split.SEPARATOR_PARAMETER, Split.OTHER_REGEX);
parameters.put(Split.MANUAL_SEPARATOR_PARAMETER_STRING, "(");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(values, row.values());
}
Aggregations