use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ExtractDateTokensTest method test_TDP_1676.
@Test
public void test_TDP_1676() throws Exception {
// given
final DataSetRow row = //
builder().with(//
value("toto").type(Type.STRING)).with(value("Dec-17-2017").type(Type.DATE).statistics(//
getDateTestJsonAsStream("statistics_MM_dd_yyyy.json"))).with(//
value("tata").type(Type.STRING)).build();
parameters.put(ExtractDateTokens.DAY_LABEL, "true");
parameters.put(ExtractDateTokens.MONTH_LABEL, "true");
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("0000", "toto");
expectedValues.put("0001", "Dec-17-2017");
expectedValues.put("0008", "2017");
expectedValues.put("0007", "12");
expectedValues.put("0006", "December");
expectedValues.put("0005", "Sunday");
expectedValues.put("0004", "0");
expectedValues.put("0003", "0");
expectedValues.put("0002", "tata");
// 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 ExtractDateTokensTest method test_TDP_4494.
@Test
public void test_TDP_4494() throws Exception {
// given
final DataSetRow row = //
builder().with(//
value("toto").type(Type.STRING)).with(value("Dec-17-2017").type(Type.DATE).statistics(//
getDateTestJsonAsStream("statistics_MM_dd_yyyy.json"))).with(//
value("tata").type(Type.STRING)).build();
parameters.put(ExtractDateTokens.QUARTER, "true");
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("0000", "toto");
expectedValues.put("0001", "Dec-17-2017");
expectedValues.put("0007", "2017");
expectedValues.put("0006", "4");
expectedValues.put("0005", "12");
expectedValues.put("0004", "0");
expectedValues.put("0003", "0");
expectedValues.put("0002", "tata");
// 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 ExtractDateTokensTest method test_TDP_2480.
@Test
public void test_TDP_2480() throws Exception {
// given
final DataSetRow row = //
builder().with(//
value("toto").type(Type.STRING)).with(value("Apr-25-1999").type(Type.DATE).statistics(//
getDateTestJsonAsStream("statistics_MM_dd_yyyy.json"))).with(//
value("tata").type(Type.STRING)).build();
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("0000", "toto");
expectedValues.put("0001", "Apr-25-1999");
expectedValues.put("0006", "1999");
expectedValues.put("0005", "4");
expectedValues.put("0004", "0");
expectedValues.put("0003", "0");
expectedValues.put("0002", "tata");
// 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 ModifyDateTest method test_apply_in_newcolumn.
@Test
public void test_apply_in_newcolumn() throws Exception {
// given
final DataSetRow row1 = //
builder().with(//
value("toto").type(Type.STRING).name("recipe")).with(//
value("04/25/1999").type(Type.DATE).name("recipe").statistics(getDateTestJsonAsStream("statistics_MM_dd_yyyy.json"))).with(//
value("tata").type(Type.STRING).name("last update")).build();
final DataSetRow row2 = //
builder().with(//
value("tata mouche").type(Type.STRING).name("recipe")).with(//
value(" ").type(Type.DATE).name("recipe").statistics(getDateTestJsonAsStream("statistics_MM_dd_yyyy.json"))).with(//
value("toto pouche").type(Type.STRING).name("last update")).build();
final DataSetRow row3 = //
builder().with(//
value("titi louche").type(Type.STRING).name("recipe")).with(//
value("culbutoqué").type(Type.DATE).name("recipe").statistics(getDateTestJsonAsStream("statistics_MM_dd_yyyy.json"))).with(//
value("tutu couche").type(Type.STRING).name("last update")).build();
parameters.put(ActionsUtils.CREATE_NEW_COLUMN, "true");
// when
ActionTestWorkbench.test(row1, actionRegistry, factory.create(action, parameters));
ActionTestWorkbench.test(row2, actionRegistry, factory.create(action, parameters));
ActionTestWorkbench.test(row3, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow1 = getRow("toto", "04/25/1999", "tata", "04/25/2000");
assertEquals(expectedRow1.values(), row1.values());
ColumnMetadata expected1 = ColumnMetadata.Builder.column().id(3).name("recipe_modified").type(Type.STRING).build();
ColumnMetadata actual1 = row1.getRowMetadata().getById("0003");
assertEquals(expected1, actual1);
final DataSetRow expectedRow2 = getRow("tata mouche", " ", "toto pouche", " ");
assertEquals(expectedRow2.values(), row2.values());
ColumnMetadata expected2 = ColumnMetadata.Builder.column().id(3).name("recipe_modified").type(Type.STRING).build();
ColumnMetadata actual2 = row2.getRowMetadata().getById("0003");
assertEquals(expected2, actual2);
final DataSetRow expectedRow3 = getRow("titi louche", "culbutoqué", "tutu couche", "culbutoqué");
assertEquals(expectedRow3.values(), row3.values());
ColumnMetadata expected3 = ColumnMetadata.Builder.column().id(3).name("recipe_modified").type(Type.STRING).build();
ColumnMetadata actual3 = row3.getRowMetadata().getById("0003");
assertEquals(expected3, actual3);
}
use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.
the class ModifyDateTest method should_process_row_alternate_amount.
@Test
public void should_process_row_alternate_amount() throws Exception {
// given
final DataSetRow row = //
builder().with(//
value("toto").type(Type.STRING).name("recipe")).with(//
value("04/25/1999").type(Type.DATE).name("recipe").statistics(getDateTestJsonAsStream("statistics_MM_dd_yyyy.json"))).with(//
value("tata").type(Type.STRING).name("last update")).build();
parameters.put(CONSTANT_VALUE, "4");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final DataSetRow expectedRow = getRow("toto", "04/25/2003", "tata");
assertEquals(expectedRow.values(), row.values());
}
Aggregations