use of org.talend.dataprep.api.preparation.Step in project data-prep by Talend.
the class UpdatedStepVisitorTest method testUpdatedStepsWithKO.
@Test
public void testUpdatedStepsWithKO() throws Exception {
// Given
final Step step = new Step(ROOT_STEP.id(), new PreparationActions().id(), "0.0");
final RowMetadata stepRowMetadata = new RowMetadata();
final Node stepNode = NodeBuilder.from(new StepNode(step, stepRowMetadata, entryNode, new BasicNode())).to(new BasicNode()).build();
final UpdatedStepVisitor visitor = new UpdatedStepVisitor(stepMetadataRepository);
// Canceled action!
actionContext.setActionStatus(ActionContext.ActionStatus.CANCELED);
// When
stepNode.exec().receive(new DataSetRow(metadata), metadata);
// Then
stepNode.accept(visitor);
verify(stepMetadataRepository).update(step.id(), stepRowMetadata);
}
use of org.talend.dataprep.api.preparation.Step in project data-prep by Talend.
the class UpdatedStepVisitorTest method testUpdatedStepsWithOk.
@Test
public void testUpdatedStepsWithOk() throws Exception {
// Given
final Step step = new Step(ROOT_STEP.id(), new PreparationActions().id(), "0.0");
final RowMetadata stepRowMetadata = new RowMetadata();
final Node stepNode = NodeBuilder.from(new StepNode(step, stepRowMetadata, entryNode, new BasicNode())).to(new BasicNode()).build();
final UpdatedStepVisitor visitor = new UpdatedStepVisitor(stepMetadataRepository);
// OK action!
actionContext.setActionStatus(ActionContext.ActionStatus.OK);
// When
stepNode.exec().receive(new DataSetRow(metadata), metadata);
// Then
stepNode.accept(visitor);
verify(stepMetadataRepository).update(step.id(), stepRowMetadata);
}
use of org.talend.dataprep.api.preparation.Step in project data-prep by Talend.
the class OptimizedExportStrategy method getMatchingSteps.
/**
* Return the steps that are between the from and the to steps IDs.
*
* @param steps the steps to start from.
* @param fromId the from step id.
* @param toId the to step id.
* @return the steps that are between the from and the to steps IDs.
*/
private List<Step> getMatchingSteps(List<Step> steps, String fromId, String toId) {
List<Step> result = new ArrayList<>();
boolean addStep = false;
for (Step step : steps) {
// skip steps before the from
if (fromId.equals(step.id())) {
addStep = true;
} else if (addStep) {
// fromId should not be added, hence the else !
result.add(step);
}
// skip steps after
if (addStep && toId.equals(step.getId())) {
break;
}
}
LOGGER.debug("Matching steps from {} to {} are {}", fromId, toId, steps);
return result;
}
use of org.talend.dataprep.api.preparation.Step in project data-prep by Talend.
the class PreparationTest method initialStepWithAppend.
@Test
public void initialStepWithAppend() {
final String version = versionService.version().getVersionId();
final List<Action> actions = getSimpleAction("uppercase", "column_name", "lastname");
final PreparationActions newContent = PreparationActions.ROOT_ACTIONS.append(actions);
repository.add(newContent);
final Step s = new Step(Step.ROOT_STEP.id(), newContent.id(), version);
repository.add(s);
final Preparation preparation = new Preparation("#5438743", "1234", s.id(), version);
preparation.setCreationDate(0L);
repository.add(preparation);
assertThat(preparation.id(), Is.is("#5438743"));
}
use of org.talend.dataprep.api.preparation.Step in project data-prep by Talend.
the class APIPreparationConversionsTest method getPreparationMessage.
private PreparationMessage getPreparationMessage(String dataSetId) {
final PreparationMessage preparation = new PreparationMessage();
preparation.setDataSetId(dataSetId);
List<Step> steps = new ArrayList<>(12);
Step parentStep = preparation.getSteps().get(0);
for (int i = 0; i < 12; i++) {
final Step step = new Step(parentStep.id(), new PreparationActions().id(), "2.1");
steps.add(step);
parentStep = step;
}
preparation.setSteps(steps);
return preparation;
}
Aggregations