use of org.talend.dataprep.transformation.actions.common.ActionsUtils.CREATE_NEW_COLUMN in project data-prep by Talend.
the class ChangeDatePatternTest method should_set_new_pattern_as_most_used_one_newcolumn.
@Test
public void should_set_new_pattern_as_most_used_one_newcolumn() 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(CREATE_NEW_COLUMN, "true");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final List<PatternFrequency> patternFrequencies = //
row.getRowMetadata().getById(//
"0003").getStatistics().getPatternFrequencies();
String newPattern = parameters.get("new_pattern");
final Optional<PatternFrequency> newPatternSet = //
patternFrequencies.stream().filter(//
p -> StringUtils.equals(newPattern, p.getPattern())).findFirst();
assertTrue(newPatternSet.isPresent());
assertEquals(newPatternSet.get().getOccurrences(), 48);
}
Aggregations