Search in sources :

Example 1 with Step

use of org.talend.dataprep.api.preparation.Step in project data-prep by Talend.

the class FileSystemPreparationRepositoryTest method shouldGetStepThatWasAdded.

@Test
public void shouldGetStepThatWasAdded() {
    final Step expected = new Step(Step.ROOT_STEP.id(), "684fdqs638", versionService.version().getVersionId());
    repository.add(expected);
    final Step actual = repository.get(expected.id(), Step.class);
    assertEquals(expected, actual);
}
Also used : Step(org.talend.dataprep.api.preparation.Step) PreparationTest(org.talend.dataprep.preparation.PreparationTest) PreparationRepositoryTest(org.talend.dataprep.preparation.store.PreparationRepositoryTest) Test(org.junit.Test)

Example 2 with Step

use of org.talend.dataprep.api.preparation.Step in project data-prep by Talend.

the class FileSystemPreparationRepositoryTest method shouldListOnlyPreparationsExactlyMatchingGivenName.

@Test
public void shouldListOnlyPreparationsExactlyMatchingGivenName() {
    final List<Integer> ids = Arrays.asList(1, 12, 3);
    // store preparations
    final List<Preparation> preparations = // 
    ids.stream().map(// 
    i -> getPreparation(String.valueOf(i))).collect(Collectors.toList());
    preparations.forEach(prep -> repository.add(prep));
    // and some steps to add some noise
    // 
    ids.stream().map(i -> new Step(Step.ROOT_STEP.id(), "step" + i, versionService.version().getVersionId())).forEach(step -> repository.add(step));
    // get some preparation by dataset id
    final Preparation expected = preparations.get(0);
    final Collection<Preparation> actual = repository.list(Preparation.class, eq("name", "prep-1")).collect(Collectors.toList());
    assertEquals(1, actual.size());
    assertTrue(actual.contains(expected));
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) Arrays(java.util.Arrays) PreparationTest(org.talend.dataprep.preparation.PreparationTest) PreparationRepositoryTest(org.talend.dataprep.preparation.store.PreparationRepositoryTest) Collection(java.util.Collection) TqlBuilder.contains(org.talend.tql.api.TqlBuilder.contains) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) TestPropertySource(org.springframework.test.context.TestPropertySource) Step(org.talend.dataprep.api.preparation.Step) PreparationRepository(org.talend.dataprep.preparation.store.PreparationRepository) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) TqlBuilder.eq(org.talend.tql.api.TqlBuilder.eq) List(java.util.List) After(org.junit.After) VersionService(org.talend.dataprep.api.service.info.VersionService) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) Assert(org.junit.Assert) Action(org.talend.dataprep.api.preparation.Action) Preparation(org.talend.dataprep.api.preparation.Preparation) Step(org.talend.dataprep.api.preparation.Step) PreparationTest(org.talend.dataprep.preparation.PreparationTest) PreparationRepositoryTest(org.talend.dataprep.preparation.store.PreparationRepositoryTest) Test(org.junit.Test)

Example 3 with Step

use of org.talend.dataprep.api.preparation.Step in project data-prep by Talend.

the class FileSystemPreparationRepositoryTest method shouldGetOnlyWantedClass.

@Test
public void shouldGetOnlyWantedClass() {
    final Step expected = new Step(Step.ROOT_STEP.id(), "8rq4868", versionService.version().getVersionId());
    repository.add(expected);
    assertNull(repository.get(expected.id(), Preparation.class));
    assertNull(repository.get(expected.id(), PreparationActions.class));
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) Step(org.talend.dataprep.api.preparation.Step) PreparationTest(org.talend.dataprep.preparation.PreparationTest) PreparationRepositoryTest(org.talend.dataprep.preparation.store.PreparationRepositoryTest) Test(org.junit.Test)

Example 4 with Step

use of org.talend.dataprep.api.preparation.Step in project data-prep by Talend.

the class FileSystemPreparationRepositoryTest method shouldListOnlyPreparationsContainingGivenName.

@Test
public void shouldListOnlyPreparationsContainingGivenName() {
    final List<Integer> ids = Arrays.asList(1, 12, 3);
    // store preparations
    final List<Preparation> preparations = // 
    ids.stream().map(// 
    i -> getPreparation(String.valueOf(i))).collect(Collectors.toList());
    preparations.forEach(prep -> repository.add(prep));
    // and some steps to add some noise
    // 
    ids.stream().map(i -> new Step(Step.ROOT_STEP.id(), "step" + i, versionService.version().getVersionId())).forEach(step -> repository.add(step));
    // get some preparation by dataset id
    final Preparation expected1 = preparations.get(0);
    final Preparation expected2 = preparations.get(1);
    final Collection<Preparation> actual = repository.list(Preparation.class, contains("name", "1")).collect(Collectors.toList());
    assertEquals(2, actual.size());
    assertTrue(actual.contains(expected1));
    assertTrue(actual.contains(expected2));
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) Arrays(java.util.Arrays) PreparationTest(org.talend.dataprep.preparation.PreparationTest) PreparationRepositoryTest(org.talend.dataprep.preparation.store.PreparationRepositoryTest) Collection(java.util.Collection) TqlBuilder.contains(org.talend.tql.api.TqlBuilder.contains) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) TestPropertySource(org.springframework.test.context.TestPropertySource) Step(org.talend.dataprep.api.preparation.Step) PreparationRepository(org.talend.dataprep.preparation.store.PreparationRepository) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) TqlBuilder.eq(org.talend.tql.api.TqlBuilder.eq) List(java.util.List) After(org.junit.After) VersionService(org.talend.dataprep.api.service.info.VersionService) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) Assert(org.junit.Assert) Action(org.talend.dataprep.api.preparation.Action) Preparation(org.talend.dataprep.api.preparation.Preparation) Step(org.talend.dataprep.api.preparation.Step) PreparationTest(org.talend.dataprep.preparation.PreparationTest) PreparationRepositoryTest(org.talend.dataprep.preparation.store.PreparationRepositoryTest) Test(org.junit.Test)

Example 5 with Step

use of org.talend.dataprep.api.preparation.Step in project data-prep by Talend.

the class UpdatedStepVisitor method visitStepNode.

@Override
public void visitStepNode(StepNode stepNode) {
    stepNode.getEntryNode().accept(new Visitor() {

        @Override
        public void visitAction(ActionNode actionNode) {
            final ActionContext.ActionStatus status = actionNode.getActionContext().getActionStatus();
            final Step step = stepNode.getStep();
            switch(status) {
                case NOT_EXECUTED:
                case CANCELED:
                    LOGGER.debug("Not updating metadata for {} (action ended with status {}).", step.getId(), status);
                    step.setRowMetadata(null);
                    break;
                case OK:
                case DONE:
                    LOGGER.debug("Keeping metadata {} (action ended with status {}).", step.getId(), status);
                    break;
            }
            preparationUpdater.update(step.id(), actionNode.getActionContext().getRowMetadata());
        }
    });
    super.visitStepNode(stepNode);
}
Also used : Visitor(org.talend.dataprep.transformation.pipeline.Visitor) ActionNode(org.talend.dataprep.transformation.pipeline.node.ActionNode) Step(org.talend.dataprep.api.preparation.Step)

Aggregations

Step (org.talend.dataprep.api.preparation.Step)28 Test (org.junit.Test)19 Preparation (org.talend.dataprep.api.preparation.Preparation)19 PreparationActions (org.talend.dataprep.api.preparation.PreparationActions)16 ArrayList (java.util.ArrayList)11 Action (org.talend.dataprep.api.preparation.Action)11 List (java.util.List)9 Arrays (java.util.Arrays)8 PersistentStep (org.talend.dataprep.preparation.store.PersistentStep)8 PreparationRepository (org.talend.dataprep.preparation.store.PreparationRepository)8 BaseMaintenanceTest (org.talend.dataprep.maintenance.BaseMaintenanceTest)7 Collections (java.util.Collections)6 Stream (java.util.stream.Stream)6 InjectMocks (org.mockito.InjectMocks)6 Mock (org.mockito.Mock)6 Mockito (org.mockito.Mockito)6 TqlBuilder (org.talend.tql.api.TqlBuilder)6 OutputStream (java.io.OutputStream)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 ExportParameters (org.talend.dataprep.api.export.ExportParameters)4