use of org.talend.dataprep.transformation.actions.date.DateCalendarConverter in project data-prep by Talend.
the class DateCalendarConverterTest method testCompileShouldComputeToAndFromInternalContextParameters.
@Test
public void testCompileShouldComputeToAndFromInternalContextParameters() {
// Given
final DateCalendarConverter calendarConverter = new DateCalendarConverter();
final DataSetRow row = builder().with(value("toto").type(Type.STRING).name("recipe")).with(value("10/29/1996").type(Type.DATE).name("last update").statistics(getDateTestJsonAsStream("statistics_MM_dd_yyyy.json"))).with(//
value("tata").type(Type.STRING).name("who")).build();
final ActionContext context = new ActionContext(new TransformationContext(), row.getRowMetadata());
context.setActionStatus(ActionContext.ActionStatus.OK);
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, CalendarUnit.JULIAN_DAY.name());
context.setParameters(parameters);
// When
calendarConverter.compile(context);
// Then
assertTrue(context.get(IS_FROM_CHRONOLOGY_INTERNAL_KEY));
assertFalse(context.get(IS_TO_CHRONOLOGY_INTERNAL_KEY));
}
Aggregations