Search in sources :

Example 61 with Folder

use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.

the class PreparationControllerTest method createInFolder.

@Test
public void createInFolder() throws Exception {
    // given
    final String path = "/test/create/preparation";
    final Folder folder = folderRepository.addFolder(home.getId(), path);
    final Iterator<FolderEntry> iterator;
    try (Stream<FolderEntry> folderEntriesStream = folderRepository.entries(folder.getId(), PREPARATION)) {
        iterator = folderEntriesStream.iterator();
        assertThat(iterator.hasNext(), is(false));
    }
    // when
    final String preparationId = clientTest.createPreparation(createTestPreparation("another_preparation", "75368"), folder.getId()).id();
    // then
    final FolderEntry entry = assertThatPreparationIsFirstInsideFolder(preparationId, folder.getId());
    assertThat(entry.getContentType(), is(PREPARATION));
}
Also used : FolderEntry(org.talend.dataprep.api.folder.FolderEntry) Folder(org.talend.dataprep.api.folder.Folder) BasePreparationTest(org.talend.dataprep.preparation.BasePreparationTest) Test(org.junit.Test)

Example 62 with Folder

use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.

the class PreparationControllerTest method test_TDP_2158.

@Test
public void test_TDP_2158() throws Exception {
    // given
    final Folder rootFolder = folderRepository.addFolder(home.getId(), "/root");
    final List<String> rootPreparations = new ArrayList<>(1);
    rootPreparations.add(clientTest.createPreparation(createTestPreparation("prep_2", "1234"), rootFolder.getId()).getId());
    final Folder threePrepsFolder = folderRepository.addFolder(rootFolder.getId(), "three_preps");
    final List<String> threePreparations = new ArrayList<>(3);
    threePreparations.add(clientTest.createPreparation(createTestPreparation("prep_2", "1234"), threePrepsFolder.getId()).getId());
    threePreparations.add(clientTest.createPreparation(createTestPreparation("prep_3", "1234"), threePrepsFolder.getId()).getId());
    threePreparations.add(clientTest.createPreparation(createTestPreparation("prep_4", "1234"), threePrepsFolder.getId()).getId());
    final Folder noPrepsFolder = folderRepository.addFolder(threePrepsFolder.getId(), "no_prep");
    List<String> noPreparations = new ArrayList<>();
    // then
    checkSearchFolder(rootFolder.getId(), rootPreparations, SortAndOrderHelper.Sort.CREATION_DATE.camelName());
    checkSearchFolder(threePrepsFolder.getId(), threePreparations, SortAndOrderHelper.Sort.NAME.camelName());
    checkSearchFolder(noPrepsFolder.getId(), noPreparations, SortAndOrderHelper.Sort.CREATION_DATE.camelName());
}
Also used : Folder(org.talend.dataprep.api.folder.Folder) BasePreparationTest(org.talend.dataprep.preparation.BasePreparationTest) Test(org.junit.Test)

Example 63 with Folder

use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.

the class PreparationControllerTest method shouldListByFolder.

@Test
public void shouldListByFolder() throws Exception {
    // given
    final Folder rootFolder = folderRepository.addFolder(home.getId(), "/root");
    final List<String> rootPreparations = new ArrayList<>(1);
    rootPreparations.add(clientTest.createPreparation(createTestPreparation("prep_1", "1234"), rootFolder.getId()).getId());
    final Folder threePrepsFolder = folderRepository.addFolder(rootFolder.getId(), "three_preps");
    final List<String> threePreparations = new ArrayList<>(3);
    threePreparations.add(clientTest.createPreparation(createTestPreparation("prep_2", "1234"), threePrepsFolder.getId()).getId());
    threePreparations.add(clientTest.createPreparation(createTestPreparation("prep_3", "1234"), threePrepsFolder.getId()).getId());
    threePreparations.add(clientTest.createPreparation(createTestPreparation("prep_4", "1234"), threePrepsFolder.getId()).getId());
    final Folder noPrepsFolder = folderRepository.addFolder(threePrepsFolder.getId(), "no_prep");
    List<String> noPreparations = new ArrayList<>();
    // then
    checkSearchFolder(rootFolder.getId(), rootPreparations, SortAndOrderHelper.Sort.CREATION_DATE.camelName());
    checkSearchFolder(threePrepsFolder.getId(), threePreparations, SortAndOrderHelper.Sort.CREATION_DATE.camelName());
    checkSearchFolder(noPrepsFolder.getId(), noPreparations, SortAndOrderHelper.Sort.CREATION_DATE.camelName());
}
Also used : Folder(org.talend.dataprep.api.folder.Folder) BasePreparationTest(org.talend.dataprep.preparation.BasePreparationTest) Test(org.junit.Test)

Example 64 with Folder

use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.

the class PreparationControllerTest method shouldReleaseALockAfterAMove.

@Test
public void shouldReleaseALockAfterAMove() throws Exception {
    // given
    final Folder fromFolder = folderRepository.addFolder(home.getId(), "from");
    final Folder toFolder = folderRepository.addFolder(home.getId(), "to");
    final String originalId = clientTest.createPreparation(createTestPreparation("yap", "7535"), fromFolder.getId()).getId();
    Preparation expected = repository.get(originalId, Preparation.class);
    // when
    final Response response = // 
    given().queryParam("folder", // 
    fromFolder.getId()).queryParam("destination", // 
    toFolder.getId()).when().expect().statusCode(200).log().ifError().put("/preparations/{id}/move", originalId);
    // then
    assertThat(response.getStatusCode(), is(200));
}
Also used : Response(com.jayway.restassured.response.Response) Folder(org.talend.dataprep.api.folder.Folder) BasePreparationTest(org.talend.dataprep.preparation.BasePreparationTest) Test(org.junit.Test)

Example 65 with Folder

use of org.talend.dataprep.api.folder.Folder in project data-prep by Talend.

the class PreparationControllerTest method shouldLocatePreparation.

@Test
public void shouldLocatePreparation() throws Exception {
    // given
    final Folder bar = folderRepository.addFolder(home.getId(), "/foo/bar");
    final String barEntry = clientTest.createPreparation(createTestPreparation("youpi", "4824"), bar.getId()).getId();
    // when
    final Response response = // 
    given().when().expect().statusCode(200).log().ifError().get("/preparations/{id}/folder", barEntry);
    // then
    assertThat(response.getStatusCode(), is(200));
    try (InputStream responseAsInputStream = response.asInputStream()) {
        final Folder actual = mapper.readValue(responseAsInputStream, Folder.class);
        assertEquals(bar.getId(), actual.getId());
    }
}
Also used : Response(com.jayway.restassured.response.Response) InputStream(java.io.InputStream) Folder(org.talend.dataprep.api.folder.Folder) BasePreparationTest(org.talend.dataprep.preparation.BasePreparationTest) Test(org.junit.Test)

Aggregations

Folder (org.talend.dataprep.api.folder.Folder)69 Test (org.junit.Test)36 Response (com.jayway.restassured.response.Response)25 BasePreparationTest (org.talend.dataprep.preparation.BasePreparationTest)21 ServiceBaseTest (org.talend.ServiceBaseTest)17 FolderEntry (org.talend.dataprep.api.folder.FolderEntry)16 TDPException (org.talend.dataprep.exception.TDPException)9 Collectors.toList (java.util.stream.Collectors.toList)7 List (java.util.List)6 Preparation (org.talend.dataprep.api.preparation.Preparation)6 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)5 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)5 FolderInfo (org.talend.dataprep.api.folder.FolderInfo)5 EnrichedPreparation (org.talend.dataprep.api.service.api.EnrichedPreparation)5 Stream (java.util.stream.Stream)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 PREPARATION (org.talend.dataprep.api.folder.FolderContentType.PREPARATION)4 ApiOperation (io.swagger.annotations.ApiOperation)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3