use of org.talend.dataprep.api.dataset.statistics.PatternFrequency in project data-prep by Talend.
the class TrailingSpaceRuleTest method setUp.
@Before
public void setUp() throws Exception {
trailingSpaceRule = StringRules.trailingSpaceRule();
stringColumn.getStatistics().getPatternFrequencies().add(new PatternFrequency("AaaA", 10));
stringWithSpacesColumn.getStatistics().getPatternFrequencies().add(new PatternFrequency(" Aaa ", 10));
}
use of org.talend.dataprep.api.dataset.statistics.PatternFrequency in project data-prep by Talend.
the class UpperCaseRuleTest method setUp.
@Before
public void setUp() throws Exception {
upperCaseRule = StringRules.upperCaseRule();
stringColumn.getStatistics().getPatternFrequencies().add(new PatternFrequency("aaaa", 10));
stringUpperCaseColumn.getStatistics().getPatternFrequencies().add(new PatternFrequency("AAAA", 10));
}
use of org.talend.dataprep.api.dataset.statistics.PatternFrequency in project data-prep by Talend.
the class DateCalendarConverterTest method testConversion.
private void testConversion(String from, DateCalendarConverter.CalendarUnit fromUnit, String fromPattern, String expected, DateCalendarConverter.CalendarUnit toUnit) {
// given
Map<String, String> rowContent = new HashMap<>();
rowContent.put("0000", "David");
rowContent.put("0001", from);
final DataSetRow row1 = new DataSetRow(rowContent);
row1.getRowMetadata().getColumns().get(1).getStatistics().getPatternFrequencies().add(new PatternFrequency(fromPattern, 1));
// row 2
rowContent = new HashMap<>();
rowContent.put("0000", "John");
rowContent.put("0001", "foo");
final DataSetRow row2 = new DataSetRow(rowContent);
final Map<String, String> parameters = new HashMap<>();
parameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "column");
parameters.put(COLUMN_ID.getKey(), "0001");
parameters.put(FROM_CALENDAR_TYPE_PARAMETER, fromUnit.name());
parameters.put(TO_CALENDAR_TYPE_PARAMETER, toUnit.name());
// when
ActionTestWorkbench.test(Arrays.asList(row1, row2), actionRegistry, factory.create(action, parameters));
// then
assertEquals(expected, row1.get("0001"));
assertEquals("foo", row2.get("0001"));
}
use of org.talend.dataprep.api.dataset.statistics.PatternFrequency in project data-prep by Talend.
the class DateCalendarConverterTest method testConversionJapaneseToISO_ValidDateWithEra.
@Test
public void testConversionJapaneseToISO_ValidDateWithEra() {
// given
Map<String, String> rowContent = new HashMap<>();
rowContent.put("0000", "David");
rowContent.put("0001", "0008/10/29 平成");
final DataSetRow row = new DataSetRow(rowContent);
row.getRowMetadata().getColumns().get(1).getStatistics().getPatternFrequencies().add(new PatternFrequency("yyyy/MM/dd G", 1));
final Map<String, String> parameters = new HashMap<>();
parameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "column");
parameters.put(COLUMN_ID.getKey(), "0001");
parameters.put(FROM_CALENDAR_TYPE_PARAMETER, DateCalendarConverter.CalendarUnit.JAPANESE.name());
parameters.put(TO_CALENDAR_TYPE_PARAMETER, DateCalendarConverter.CalendarUnit.ISO.name());
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
// While using ResolverStyle.STRICT, date pattern of input data on Japanese calendar must contain era 'G'
assertEquals("1996/10/29 AD", row.get("0001"));
}
use of org.talend.dataprep.api.dataset.statistics.PatternFrequency in project data-prep by Talend.
the class DateCalendarConverterTest method testChronologyToJulianDaySameInstance.
/**
* row1 and row2 should use one instance DateCalendarConverter.Just cover the test code and no assert the Mpa 'dateCalendarConverterMap'.
* Because the Map is private.
*/
@Test
public void testChronologyToJulianDaySameInstance() {
Map<String, String> rowContent = new HashMap<>();
// row1
rowContent.put("0000", "David");
rowContent.put("0001", "1970-01-01");
final DataSetRow row1 = new DataSetRow(rowContent);
row1.getRowMetadata().getColumns().get(1).getStatistics().getPatternFrequencies().add(new PatternFrequency("yyyy-MM-dd", 1));
// row 2
rowContent = new HashMap<>();
rowContent.put("0000", "John");
rowContent.put("0001", "0001-01-01");
final DataSetRow row2 = new DataSetRow(rowContent);
final Map<String, String> parameters = new HashMap<>();
parameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "column");
parameters.put(COLUMN_ID.getKey(), "0001");
parameters.put(FROM_CALENDAR_TYPE_PARAMETER, DateCalendarConverter.CalendarUnit.ISO.name());
parameters.put(TO_CALENDAR_TYPE_PARAMETER, DateCalendarConverter.CalendarUnit.JULIAN_DAY.name());
// when
ActionTestWorkbench.test(Arrays.asList(row1, row2), actionRegistry, factory.create(action, parameters));
// then
assertEquals("2440588", row1.get("0001"));
assertEquals("1721426", row2.get("0001"));
}
Aggregations