use of org.talend.dataprep.transformation.api.action.context.ActionContext in project data-prep by Talend.
the class ReplaceCellValueTest method should_not_compile_no_replacement_value.
@Test
public void should_not_compile_no_replacement_value() throws Exception {
// given
ActionContext context = getActionContext(new SimpleEntry<>(ROW_ID.getKey(), "2"));
// when
action.compile(context);
// then
assertEquals(CANCELED, context.getActionStatus());
}
use of org.talend.dataprep.transformation.api.action.context.ActionContext in project data-prep by Talend.
the class ReplaceCellValueTest method getActionContext.
@SafeVarargs
private final ActionContext getActionContext(SimpleEntry<String, String>... entries) {
Map<String, String> parameters = new HashMap<>();
for (SimpleEntry<String, String> entry : entries) {
parameters.put(entry.getKey(), entry.getValue());
}
ActionContext context = new ActionContext(new TransformationContext());
context.setParameters(parameters);
return context;
}
use of org.talend.dataprep.transformation.api.action.context.ActionContext in project data-prep by Talend.
the class ReplaceCellValueTest method should_not_compile_invalid_row_value.
@Test
public void should_not_compile_invalid_row_value() throws Exception {
// given
ActionContext context = getActionContext(//
new SimpleEntry<>(NEW_VALUE_PARAMETER, "toto"), //
new SimpleEntry<>(ROW_ID.getKey(), "toto"));
// when
action.compile(context);
// then
assertEquals(CANCELED, context.getActionStatus());
}
use of org.talend.dataprep.transformation.api.action.context.ActionContext in project data-prep by Talend.
the class TransformationService method applyActionsOnMetadata.
private void applyActionsOnMetadata(RowMetadata metadata, String actionsAsJson) {
List<RunnableAction> actions = actionParser.parse(actionsAsJson);
TransformationContext transformationContext = new TransformationContext();
try {
for (RunnableAction action : actions) {
final ActionContext actionContext = transformationContext.create(action.getRowAction(), metadata);
action.getRowAction().compile(actionContext);
}
} finally {
// cleanup the transformation context is REALLY important as it can close open http connections
transformationContext.cleanup();
}
}
Aggregations