use of org.talend.dataprep.api.preparation.PreparationActions in project data-prep by Talend.
the class FileSystemPreparationRepositoryTest method shouldListActionThatWasAdded.
@Test
public void shouldListActionThatWasAdded() {
final List<Action> actions = PreparationTest.getSimpleAction("uppercase", "column_name", "lastname");
PreparationActions expected = new PreparationActions(actions, versionService.version().getVersionId());
repository.add(expected);
final PreparationActions actual = repository.get(expected.id(), PreparationActions.class);
assertEquals(expected, actual);
}
use of org.talend.dataprep.api.preparation.PreparationActions in project data-prep by Talend.
the class PreparationCleanerTest method removeOrphanSteps_should_remove_orphan_step_content.
@Test
public void removeOrphanSteps_should_remove_orphan_step_content() {
// given
final String version = "1.2.3";
final PreparationActions content = new PreparationActions();
content.setAppVersion(version);
when(repository.list(PreparationActions.class)).thenReturn(Stream.of(content));
when(repository.get(content.id(), PreparationActions.class)).thenReturn(content);
final Step step = new Step(Step.ROOT_STEP.id(), content.id(), version);
when(repository.list(eq(Step.class))).thenReturn(Stream.of(step));
when(repository.list(eq(PersistentStep.class))).thenReturn(Stream.of(step).map(s -> {
final PersistentStep persistentStep = new PersistentStep();
persistentStep.setId(s.id());
persistentStep.setContent(s.getContent());
return persistentStep;
}));
when(repository.list(eq(Preparation.class))).thenReturn(Stream.empty());
// when
cleaner.removeOrphanSteps();
// then
verify(repository, times(1)).remove(eq(content));
}
use of org.talend.dataprep.api.preparation.PreparationActions in project data-prep by Talend.
the class PreparationTest method stepsWithAppend.
@Test
public void stepsWithAppend() {
final String version = versionService.version().getVersionId();
final List<Action> actions = getSimpleAction("uppercase", "column_name", "lastname");
final PreparationActions newContent1 = PreparationActions.ROOT_ACTIONS.append(actions);
repository.add(newContent1);
final PreparationActions newContent2 = newContent1.append(actions);
repository.add(newContent2);
// Steps
final Step s1 = new Step(Step.ROOT_STEP.id(), newContent1.id(), version);
repository.add(s1);
final Step s2 = new Step(s1.id(), newContent2.id(), version);
repository.add(s2);
// Preparation
final Preparation preparation = new Preparation("#54258728", "1234", s2.id(), version);
preparation.setCreationDate(0L);
repository.add(preparation);
assertThat(preparation.id(), Is.is("#54258728"));
}
use of org.talend.dataprep.api.preparation.PreparationActions in project data-prep by Talend.
the class PreparationTest method initialStep.
@Test
public void initialStep() {
final String version = versionService.version().getVersionId();
final List<Action> actions = getSimpleAction("uppercase", "column_name", "lastname");
final PreparationActions newContent = new PreparationActions(actions, version);
repository.add(newContent);
final Step s = new Step(Step.ROOT_STEP.id(), newContent.id(), version);
repository.add(s);
Preparation preparation = new Preparation("#48368", "1234", s.id(), version);
preparation.setCreationDate(0L);
repository.add(preparation);
assertThat(preparation.id(), Is.is("#48368"));
}
use of org.talend.dataprep.api.preparation.PreparationActions 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);
}
Aggregations