Search in sources :

Example 41 with Preparation

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

the class PreparationAPITest method shouldMovePreparation.

@Test
public void shouldMovePreparation() throws Exception {
    // given
    final Folder source = folderRepository.addFolder(home.getId(), "source");
    final String id = testClient.createPreparationFromFile("dataset/dataset.csv", "great_preparation", source.getId());
    final Folder destination = folderRepository.addFolder(home.getId(), "destination");
    // when
    final Response response = // 
    given().queryParam("folder", // 
    source.getId()).queryParam("destination", // 
    destination.getId()).queryParam("newName", // 
    "NEW great preparation").when().expect().statusCode(200).log().ifError().put("api/preparations/{id}/move", id);
    // then
    assertEquals(200, response.getStatusCode());
    // check the folder entry
    final List<FolderEntry> entries = getEntries(destination.getId());
    assertThat(entries.size(), greaterThan(0));
    final FolderEntry entry = entries.get(0);
    assertEquals(entry.getContentId(), id);
    // check the name
    final Preparation actual = preparationRepository.get(id, Preparation.class);
    assertEquals("NEW great preparation", actual.getName());
}
Also used : Response(com.jayway.restassured.response.Response) StandalonePreparation(org.talend.dataprep.StandalonePreparation) EnrichedPreparation(org.talend.dataprep.api.service.api.EnrichedPreparation) Preparation(org.talend.dataprep.api.preparation.Preparation) UserPreparation(org.talend.dataprep.preparation.service.UserPreparation) FolderEntry(org.talend.dataprep.api.folder.FolderEntry) Folder(org.talend.dataprep.api.folder.Folder) Test(org.junit.Test)

Example 42 with Preparation

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

the class PreparationRepositoryTest method findOneByDataset_should_return_a_preparation_that_use_dataset.

@Test
public void findOneByDataset_should_return_a_preparation_that_use_dataset() {
    // given
    final String dataSetId = "789b61f3128a9bc24a684";
    final Preparation prep1 = new Preparation();
    prep1.setDataSetId("other_dataset");
    final Preparation prep2 = new Preparation();
    prep2.setDataSetId(dataSetId);
    getRepository().add(prep1);
    getRepository().add(prep2);
    // when
    final boolean result = getRepository().exist(Preparation.class, eq("dataSetId", dataSetId));
    // then
    assertThat(result, is(true));
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) ServiceBaseTest(org.talend.ServiceBaseTest) Test(org.junit.Test)

Example 43 with Preparation

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

the class PreparationRepositoryTest method shouldListOnlyPreparationsForDatasets.

@Test
public void shouldListOnlyPreparationsForDatasets() {
    List<Integer> ids = Arrays.asList(1, 2, 3);
    // store preparations
    final List<Preparation> preparations = // 
    ids.stream().map(// 
    i -> getPreparation(String.valueOf(i))).collect(Collectors.toList());
    preparations.forEach(prep -> getRepository().add(prep));
    // get preparation by name
    final Preparation expected = preparations.get(1);
    final Collection<Preparation> actual = getRepository().list(Preparation.class, eq("dataSetId", expected.getDataSetId())).collect(Collectors.toList());
    assertEquals(1, actual.size());
    assertTrue(actual.contains(expected));
}
Also used : TqlBuilder.eq(org.talend.tql.api.TqlBuilder.eq) Preparation(org.talend.dataprep.api.preparation.Preparation) Arrays(java.util.Arrays) List(java.util.List) ServiceBaseTest(org.talend.ServiceBaseTest) Collection(java.util.Collection) Matchers.is(org.hamcrest.Matchers.is) Test(org.junit.Test) Assert(org.junit.Assert) Collectors(java.util.stream.Collectors) Preparation(org.talend.dataprep.api.preparation.Preparation) ServiceBaseTest(org.talend.ServiceBaseTest) Test(org.junit.Test)

Example 44 with Preparation

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

the class FileSystemPreparationRepositoryTest method shouldRemove.

@Test
public void shouldRemove() {
    final Preparation preparation = getPreparation("id#8486343");
    repository.add(preparation);
    repository.remove(preparation);
    assertNull(repository.get(preparation.id(), Preparation.class));
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) PreparationTest(org.talend.dataprep.preparation.PreparationTest) PreparationRepositoryTest(org.talend.dataprep.preparation.store.PreparationRepositoryTest) Test(org.junit.Test)

Example 45 with Preparation

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

the class FileSystemPreparationRepositoryTest method shouldOverwriteContent.

@Test
public void shouldOverwriteContent() {
    Preparation expected = getPreparation("khdgf");
    expected.setName("old name");
    repository.add(expected);
    expected.setName("new name");
    repository.add(expected);
    final Preparation actual = repository.get(expected.id(), Preparation.class);
    assertEquals(expected, actual);
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) PreparationTest(org.talend.dataprep.preparation.PreparationTest) PreparationRepositoryTest(org.talend.dataprep.preparation.store.PreparationRepositoryTest) Test(org.junit.Test)

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