use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class CompareDatesTest method simple_not_greater_result_with_constant.
@Test
public void simple_not_greater_result_with_constant() throws Exception {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "02/01/2012");
RowMetadata rowMetadata = new RowMetadata();
rowMetadata.addColumn(createMetadata("0000", "last update", Type.DATE, "statistics_MM_dd_yyyy.json"));
final DataSetRow row = new DataSetRow(rowMetadata, values);
parameters.put(CompareDates.CONSTANT_VALUE, "02/02/2012");
parameters.put(CompareDates.MODE_PARAMETER, OtherColumnParameters.CONSTANT_MODE);
parameters.put(CompareDates.COMPARE_MODE, CompareDates.GT);
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
//
Assertions.assertThat(row.values()).hasSize(//
2).containsExactly(//
MapEntry.entry("0000", "02/01/2012"), MapEntry.entry("0001", "false"));
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class CompareDatesTest method compare_empty_with_empty_should_have_empty_result.
@Test
public void compare_empty_with_empty_should_have_empty_result() throws Exception {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "");
values.put("0001", "");
RowMetadata rowMetadata = new RowMetadata();
rowMetadata.addColumn(createMetadata("0000", "last update", Type.DATE, "statistics_MM_dd_yyyy.json"));
rowMetadata.addColumn(createMetadata("0001", "first update", Type.DATE, "statistics_MM_dd_yyyy.json"));
final DataSetRow row = new DataSetRow(rowMetadata, values);
parameters.put(CompareDates.MODE_PARAMETER, OtherColumnParameters.OTHER_COLUMN_MODE);
parameters.put(OtherColumnParameters.SELECTED_COLUMN_PARAMETER, "0001");
parameters.put(CompareDates.COMPARE_MODE, CompareDates.EQ);
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
//
Assertions.assertThat(row.values()).hasSize(//
3).containsExactly(//
MapEntry.entry("0000", ""), //
MapEntry.entry("0001", ""), MapEntry.entry("0002", ""));
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class CompareDatesTest method simple_greater_result_with_constant_with_invalid_dates_row.
@Test
public void simple_greater_result_with_constant_with_invalid_dates_row() throws Exception {
// given
final Map<String, String> firstRowValues = new HashMap<>();
firstRowValues.put("0000", "02/01/2012");
RowMetadata rowMetadata = new RowMetadata();
rowMetadata.addColumn(createMetadata("0000", "last update", Type.DATE, "statistics_MM_dd_yyyy.json"));
parameters.put(CompareDates.CONSTANT_VALUE, "02/21/2008");
parameters.put(CompareDates.MODE_PARAMETER, OtherColumnParameters.CONSTANT_MODE);
parameters.put(CompareDates.COMPARE_MODE, CompareDates.GT);
final Map<String, String> secondRowvalues = new HashMap<>();
secondRowvalues.put("0000", "Beer");
final Map<String, String> thirdRowvalues = new HashMap<>();
thirdRowvalues.put("0000", "02/01/2001");
List<DataSetRow> rows = //
Arrays.asList(//
new DataSetRow(rowMetadata, firstRowValues), //
new DataSetRow(rowMetadata, secondRowvalues), new DataSetRow(rowMetadata, thirdRowvalues));
// when
ActionTestWorkbench.test(rows, actionRegistry, factory.create(action, parameters));
// then
//
Assertions.assertThat(rows.get(0).values()).hasSize(//
2).containsExactly(//
MapEntry.entry("0000", "02/01/2012"), MapEntry.entry("0001", "true"));
//
Assertions.assertThat(rows.get(1).values()).hasSize(//
2).containsExactly(//
MapEntry.entry("0000", "Beer"), MapEntry.entry("0001", ""));
//
Assertions.assertThat(rows.get(2).values()).hasSize(//
2).containsExactly(//
MapEntry.entry("0000", "02/01/2001"), MapEntry.entry("0001", "false"));
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class CompareDatesTest method simple_greater_result_with_constant.
@Test
public void simple_greater_result_with_constant() throws Exception {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "02/01/2012");
RowMetadata rowMetadata = new RowMetadata();
rowMetadata.addColumn(createMetadata("0000", "last update", Type.DATE, "statistics_MM_dd_yyyy.json"));
final DataSetRow row = new DataSetRow(rowMetadata, values);
parameters.put(CompareDates.CONSTANT_VALUE, "02/21/2008");
parameters.put(CompareDates.MODE_PARAMETER, OtherColumnParameters.CONSTANT_MODE);
parameters.put(CompareDates.COMPARE_MODE, CompareDates.GT);
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
//
Assertions.assertThat(row.values()).hasSize(//
2).containsExactly(//
MapEntry.entry("0000", "02/01/2012"), MapEntry.entry("0001", "true"));
final ColumnMetadata expected = ColumnMetadata.Builder.column().id(1).name("last update_gt_02/21/2008?").type(Type.BOOLEAN).build();
ColumnMetadata actual = row.getRowMetadata().getById("0001");
assertEquals(expected, actual);
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class DomainChangeTest method init.
@Before
public void init() {
final Map<String, String> values = new HashMap<>();
values.put("0000", "David Bowie");
values.put("0001", "");
values.put("0002", "Something");
row = new DataSetRow(values);
final RowMetadata rowMetadata = row.getRowMetadata();
ColumnMetadata columnMetadata = rowMetadata.getById("0002");
columnMetadata.setType(Type.INTEGER.getName());
columnMetadata.setDomain("FR_BEER");
columnMetadata.setDomainFrequency(1);
columnMetadata.setDomainLabel("French Beer");
parameters = new HashMap<>();
parameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "column");
parameters.put(ImplicitParameters.COLUMN_ID.getKey().toLowerCase(), "0002");
parameters.put(NEW_DOMAIN_ID_PARAMETER_KEY, "AUS_BEER");
parameters.put(NEW_DOMAIN_LABEL_PARAMETER_KEY, "Australian Beer");
}
Aggregations