Search in sources :

Example 46 with Preparation

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

the class PreparationTest method testTimestamp.

@Test
public void testTimestamp() throws Exception {
    Preparation preparation = new Preparation("#584284", "1234", Step.ROOT_STEP.id(), versionService.version().getVersionId());
    final long time0 = preparation.getLastModificationDate();
    TimeUnit.MILLISECONDS.sleep(50);
    preparation.updateLastModificationDate();
    final long time1 = preparation.getLastModificationDate();
    assertThat(time0, lessThan(time1));
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) Test(org.junit.Test) ServiceBaseTest(org.talend.ServiceBaseTest)

Example 47 with Preparation

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

the class PreparationTest method should_merge_from_other.

@Test
public void should_merge_from_other() {
    Preparation source = new Preparation("#4837", versionService.version().getVersionId());
    Preparation theOtherOne = new Preparation("#4837", versionService.version().getVersionId());
    theOtherOne.setAuthor("Joss Stone");
    theOtherOne.setCreationDate(source.getCreationDate() - 1000);
    theOtherOne.setDataSetId("ds#123456");
    theOtherOne.setLastModificationDate(theOtherOne.getCreationDate() + 12345682);
    theOtherOne.setName("my preparation name");
    theOtherOne.setHeadId(Step.ROOT_STEP.id());
    Preparation actual = source.merge(theOtherOne);
    assertEquals(actual, theOtherOne);
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) Test(org.junit.Test) ServiceBaseTest(org.talend.ServiceBaseTest)

Example 48 with Preparation

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

the class PreparationTest method testDefaultPreparation.

@Test
public void testDefaultPreparation() throws Exception {
    final Preparation preparation = new Preparation("#123", "12345", Step.ROOT_STEP.id(), versionService.version().getVersionId());
    preparation.setCreationDate(0L);
    assertThat(preparation.id(), is("#123"));
    assertThat(preparation.getHeadId(), is(Step.ROOT_STEP.id()));
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) Test(org.junit.Test) ServiceBaseTest(org.talend.ServiceBaseTest)

Example 49 with Preparation

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

the class PreparationTest method testId_withName.

@Test
public void testId_withName() throws Exception {
    // Preparation id with name
    Preparation preparation = new Preparation("#87374", "1234", Step.ROOT_STEP.id(), versionService.version().getVersionId());
    preparation.setName("My Preparation");
    preparation.setCreationDate(0L);
    final String id0 = preparation.getId();
    assertThat(id0, is("#87374"));
    // Same preparation (but with empty name): id must remain same
    preparation.setName("");
    final String id1 = preparation.getId();
    assertThat(id1, is("#87374"));
    // Same preparation (but with null name, null and empty names should be treated all the same): id must remain same
    preparation.setName(null);
    final String id2 = preparation.getId();
    assertThat(id2, is("#87374"));
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) Test(org.junit.Test) ServiceBaseTest(org.talend.ServiceBaseTest)

Example 50 with Preparation

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

the class PreparationTest method should_merge_from_source.

@Test
public void should_merge_from_source() {
    Preparation theOtherOne = new Preparation("#23874", versionService.version().getVersionId());
    Preparation source = new Preparation("#158387", versionService.version().getVersionId());
    source.setAuthor("Bloc Party");
    source.setCreationDate(theOtherOne.getCreationDate() - 1000);
    source.setDataSetId("ds#65478");
    source.setLastModificationDate(source.getCreationDate() + 2658483);
    source.setName("banquet");
    source.setHeadId(Step.ROOT_STEP.id());
    Preparation actual = source.merge(theOtherOne);
    assertEquals(actual, source);
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) Test(org.junit.Test) ServiceBaseTest(org.talend.ServiceBaseTest)

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