use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class DeleteEmptyTest method should_not_delete_because_value_set_of_float.
@Test
public void should_not_delete_because_value_set_of_float() {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "David Bowie");
values.put("0001", "0.001");
final DataSetRow row = new DataSetRow(values);
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertFalse(row.isDeleted());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class DeleteEmptyTest method should_delete_because_empty.
@Test
public void should_delete_because_empty() {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "David Bowie");
values.put("0001", "");
final DataSetRow row = new DataSetRow(values);
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertTrue(row.isDeleted());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class DeleteEmptyTest method should_not_delete_because_value_set_of_negative_boolean.
@Test
public void should_not_delete_because_value_set_of_negative_boolean() {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "David Bowie");
values.put("0001", "-12");
final DataSetRow row = new DataSetRow(values);
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertFalse(row.isDeleted());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class MakeLineHeaderTest method should_use_mask_on_empty_cell.
@Test
public void should_use_mask_on_empty_cell() {
// given
long rowId = 120;
// row 1
Map<String, String> rowContent = new HashMap<>();
rowContent.put("0000", "David");
rowContent.put("0001", "Bowie");
final DataSetRow row1 = new DataSetRow(rowContent);
row1.setTdpId(rowId++);
// row 2
rowContent = new HashMap<>();
rowContent.put("0000", "John");
rowContent.put("0001", "");
final DataSetRow row2 = new DataSetRow(rowContent);
row2.setTdpId(rowId++);
// row 3
rowContent = new HashMap<>();
rowContent.put("0000", "John");
rowContent.put("0001", "Lennon");
final DataSetRow row3 = new DataSetRow(rowContent);
row3.setTdpId(rowId++);
final Map<String, String> parameters = new HashMap<>();
parameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "line");
parameters.put("row_id", row2.getTdpId().toString());
assertFalse(row1.isDeleted());
assertFalse(row2.isDeleted());
assertFalse(row3.isDeleted());
// when
ActionTestWorkbench.test(Arrays.asList(row1, row2, row3), actionRegistry, factory.create(action, parameters));
// then
assertTrue(row1.isDeleted());
assertTrue(row2.isDeleted());
assertFalse(row3.isDeleted());
assertEquals("John", row2.getRowMetadata().getById("0000").getName());
assertEquals("Col 2", row2.getRowMetadata().getById("0001").getName());
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class MakeLineHeaderTest method should_keep_header_after_modifications.
@Test
public void should_keep_header_after_modifications() {
// given
Long rowId = 0L;
// row 1
Map<String, String> rowContent = new HashMap<>();
rowContent.put("0000", "David");
rowContent.put("0001", "Bowie");
final DataSetRow row1 = new DataSetRow(rowContent);
row1.setTdpId(rowId++);
// row 2
rowContent = new HashMap<>();
rowContent.put("0000", "John");
rowContent.put("0001", "Lennon");
final DataSetRow row2 = new DataSetRow(rowContent);
row2.setTdpId(rowId++);
// row 3
rowContent = new HashMap<>();
rowContent.put("0000", "Johnny");
rowContent.put("0001", "Lennon");
final DataSetRow row3 = new DataSetRow(rowContent);
row3.setTdpId(rowId++);
// when
final Map<String, String> makeHeaderParameters = new HashMap<>();
makeHeaderParameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "line");
makeHeaderParameters.put("row_id", row2.getTdpId().toString());
final RunnableAction makeHeader = factory.create(action, makeHeaderParameters);
final Map<String, String> upperCaseParameters = new HashMap<>();
upperCaseParameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "column");
upperCaseParameters.put(ImplicitParameters.COLUMN_ID.getKey().toLowerCase(), "0000");
final RunnableAction upperCase = factory.create(new UpperCase(), upperCaseParameters);
ActionTestWorkbench.test(Arrays.asList(row1, row2, row3), actionRegistry, makeHeader, upperCase);
// then
assertEquals("John", row1.getRowMetadata().getById("0000").getName());
assertEquals("Lennon", row1.getRowMetadata().getById("0001").getName());
assertEquals("John", row2.getRowMetadata().getById("0000").getName());
assertEquals("Lennon", row2.getRowMetadata().getById("0001").getName());
assertEquals("John", row3.getRowMetadata().getById("0000").getName());
assertEquals("Lennon", row3.getRowMetadata().getById("0001").getName());
}
Aggregations