Search in sources :

Example 1 with PreparationActions

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);
}
Also used : Action(org.talend.dataprep.api.preparation.Action) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) PreparationTest(org.talend.dataprep.preparation.PreparationTest) PreparationRepositoryTest(org.talend.dataprep.preparation.store.PreparationRepositoryTest) Test(org.junit.Test)

Example 2 with PreparationActions

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));
}
Also used : InjectMocks(org.mockito.InjectMocks) Preparation(org.talend.dataprep.api.preparation.Preparation) Arrays(java.util.Arrays) TqlBuilder(org.talend.tql.api.TqlBuilder) Mock(org.mockito.Mock) BaseMaintenanceTest(org.talend.dataprep.maintenance.BaseMaintenanceTest) PersistentStep(org.talend.dataprep.preparation.store.PersistentStep) Test(org.junit.Test) Step(org.talend.dataprep.api.preparation.Step) PreparationRepository(org.talend.dataprep.preparation.store.PreparationRepository) ArrayList(java.util.ArrayList) Mockito(org.mockito.Mockito) List(java.util.List) Stream(java.util.stream.Stream) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) Action(org.talend.dataprep.api.preparation.Action) Collections(java.util.Collections) PersistentStep(org.talend.dataprep.preparation.store.PersistentStep) Preparation(org.talend.dataprep.api.preparation.Preparation) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) PersistentStep(org.talend.dataprep.preparation.store.PersistentStep) Step(org.talend.dataprep.api.preparation.Step) BaseMaintenanceTest(org.talend.dataprep.maintenance.BaseMaintenanceTest) Test(org.junit.Test)

Example 3 with PreparationActions

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"));
}
Also used : Action(org.talend.dataprep.api.preparation.Action) Preparation(org.talend.dataprep.api.preparation.Preparation) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) Step(org.talend.dataprep.api.preparation.Step) Test(org.junit.Test) ServiceBaseTest(org.talend.ServiceBaseTest)

Example 4 with PreparationActions

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"));
}
Also used : Action(org.talend.dataprep.api.preparation.Action) Preparation(org.talend.dataprep.api.preparation.Preparation) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) Step(org.talend.dataprep.api.preparation.Step) Test(org.junit.Test) ServiceBaseTest(org.talend.ServiceBaseTest)

Example 5 with PreparationActions

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);
}
Also used : StepNode(org.talend.dataprep.transformation.pipeline.node.StepNode) StepNode(org.talend.dataprep.transformation.pipeline.node.StepNode) ActionNode(org.talend.dataprep.transformation.pipeline.node.ActionNode) Node(org.talend.dataprep.transformation.pipeline.Node) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) Step(org.talend.dataprep.api.preparation.Step) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test)

Aggregations

PreparationActions (org.talend.dataprep.api.preparation.PreparationActions)17 Test (org.junit.Test)14 Action (org.talend.dataprep.api.preparation.Action)13 Step (org.talend.dataprep.api.preparation.Step)11 ArrayList (java.util.ArrayList)8 PersistentStep (org.talend.dataprep.preparation.store.PersistentStep)8 PreparationRepository (org.talend.dataprep.preparation.store.PreparationRepository)8 Preparation (org.talend.dataprep.api.preparation.Preparation)7 List (java.util.List)5 Stream (java.util.stream.Stream)5 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4 InjectMocks (org.mockito.InjectMocks)4 Mock (org.mockito.Mock)4 Mockito (org.mockito.Mockito)4 BaseMaintenanceTest (org.talend.dataprep.maintenance.BaseMaintenanceTest)4 TqlBuilder (org.talend.tql.api.TqlBuilder)4 ServiceBaseTest (org.talend.ServiceBaseTest)3 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)2 DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)2