Search in sources :

Example 26 with Preparation

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

the class SortAndOrderHelperTest method createPreparation.

private Preparation createPreparation(String name, String author, long creation, long modification, long size, String dsId) {
    Preparation firstPrep = new Preparation();
    firstPrep.setDataSetId(dsId);
    firstPrep.setName(name);
    firstPrep.setAuthor(new Owner("1234", author, "").getDisplayName());
    firstPrep.setCreationDate(creation);
    firstPrep.setLastModificationDate(modification);
    List<Step> steps = new ArrayList<>();
    for (int i = 0; i < size; i++) {
        steps.add(null);
    }
    firstPrep.setSteps(steps);
    return firstPrep;
}
Also used : Owner(org.talend.dataprep.api.share.Owner) Preparation(org.talend.dataprep.api.preparation.Preparation) UserPreparation(org.talend.dataprep.preparation.service.UserPreparation) ArrayList(java.util.ArrayList) Step(org.talend.dataprep.api.preparation.Step)

Example 27 with Preparation

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

the class NoOpLockedResourceRepositoryTest method tryLock.

@Test
public void tryLock() throws Exception {
    // given
    String preparationId = "preparation id";
    Preparation preparationMock = mock(Preparation.class);
    when(preparationRepository.get(preparationId, Preparation.class)).thenReturn(preparationMock);
    // when
    Preparation preparation = noOpLockedResourceRepository.tryLock(preparationId, "Toto", "toto de Charleville-Mézières");
    // then
    assertEquals(preparationMock, preparation);
    verify(preparationRepository).get(preparationId, Preparation.class);
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) Test(org.junit.Test)

Example 28 with Preparation

use of org.talend.dataprep.api.preparation.Preparation 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 29 with Preparation

use of org.talend.dataprep.api.preparation.Preparation 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 30 with Preparation

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

the class InMemoryPreparationRepositoryTest method getPreparation.

/**
 * Helper method that only generates a preparation but simplify code.
 *
 * @param datasetId the preparation dataset id.
 * @param rootName root name for all the preparation attributes.
 * @return a new Preparation.
 */
private Preparation getPreparation(String datasetId, String rootName) {
    Preparation preparation = new Preparation(UUID.randomUUID().toString(), datasetId, getStep(rootName).id(), "1.0");
    preparation.setName(rootName + "_name");
    preparation.setAuthor(rootName + "_name");
    return preparation;
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation)

Aggregations

Preparation (org.talend.dataprep.api.preparation.Preparation)65 Test (org.junit.Test)44 Step (org.talend.dataprep.api.preparation.Step)18 List (java.util.List)14 ServiceBaseTest (org.talend.ServiceBaseTest)11 ArrayList (java.util.ArrayList)10 Action (org.talend.dataprep.api.preparation.Action)10 PreparationActions (org.talend.dataprep.api.preparation.PreparationActions)10 Response (com.jayway.restassured.response.Response)9 Arrays (java.util.Arrays)8 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)8 ExportParameters (org.talend.dataprep.api.export.ExportParameters)8 UserPreparation (org.talend.dataprep.preparation.service.UserPreparation)8 TransformationCacheKey (org.talend.dataprep.cache.TransformationCacheKey)7 PreparationRepository (org.talend.dataprep.preparation.store.PreparationRepository)7 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)6 Folder (org.talend.dataprep.api.folder.Folder)6 TDPException (org.talend.dataprep.exception.TDPException)6 PersistentStep (org.talend.dataprep.preparation.store.PersistentStep)6 PreparationRepositoryTest (org.talend.dataprep.preparation.store.PreparationRepositoryTest)6