Search in sources :

Example 6 with FolderEntry

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

the class AbstractFolderTest method create_entry_then_copy.

/**
 * This test create two folders and a folder entry then copy it to the other folder
 */
@Test
public void create_entry_then_copy() throws Exception {
    // 2 folders /foo & /bar
    long sizeBefore = getFolderRepository().size();
    Folder foo = getFolderRepository().addFolder(homeFolderId, "foo");
    Folder bar = getFolderRepository().addFolder(homeFolderId, "bar");
    long sizeAfter = getFolderRepository().size();
    assertThat(sizeAfter).isEqualTo(sizeBefore + 2);
    assertChildrenSize(homeFolderId, 2);
    // bordeaux in /foo
    FolderEntry wineEntry = new FolderEntry(DATASET, "bordeaux");
    getFolderRepository().addFolderEntry(wineEntry, foo.getId());
    List<FolderEntry> entries = getDatasetsFromFolder(foo.getId());
    assertThat(entries).isNotNull().isNotEmpty().hasSize(1).contains(wineEntry);
    // copy bordeaux in /bar
    getFolderRepository().copyFolderEntry(wineEntry, bar.getId());
    entries = getDatasetsFromFolder(bar.getId());
    assertThat(entries).isNotNull().isNotEmpty().hasSize(1);
    assertFolderEntry(entries.get(0), "bordeaux", DATASET);
    // still in foo as it's a copy
    entries = getDatasetsFromFolder(foo.getId());
    assertThat(entries).isNotNull().isNotEmpty().hasSize(1).contains(wineEntry);
}
Also used : FolderEntry(org.talend.dataprep.api.folder.FolderEntry) Folder(org.talend.dataprep.api.folder.Folder) ServiceBaseTest(org.talend.ServiceBaseTest)

Example 7 with FolderEntry

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

the class AbstractFolderTest method create_child_with_two_entries_then_remove_expect_exception.

/**
 * This test create one child under root assert size, child list then create three folder entries then delete
 * expect exception
 */
@Test
public void create_child_with_two_entries_then_remove_expect_exception() throws Exception {
    long sizeBefore = getFolderRepository().size();
    Folder foo = getFolderRepository().addFolder(homeFolderId, "foo");
    Folder foobeer = getFolderRepository().addFolder(foo.getId(), "/beer");
    long sizeAfter = getFolderRepository().size();
    assertThat(sizeAfter).isEqualTo(sizeBefore + 2);
    assertChildrenSize(homeFolderId, 1);
    FolderEntry beerEntry = new FolderEntry(DATASET, "littlecreatures");
    FolderEntry wineEntry = new FolderEntry(DATASET, "bordeaux");
    getFolderRepository().addFolderEntry(beerEntry, foo.getId());
    getFolderRepository().addFolderEntry(wineEntry, foo.getId());
    wineEntry = new FolderEntry(DATASET, "bordeaux");
    getFolderRepository().addFolderEntry(wineEntry, foobeer.getId());
    assertThatFolderContainsExpectedNumberOfDatasets(foo.getId(), 2);
    assertThatExpectedNumberOfNamedDatasetIsFound("bordeaux", 2);
    assertThatExpectedNumberOfNamedDatasetIsFound("littlecreatures", 1);
    assertThatFolderContainsExpectedNumberOfDatasets(foo.getId(), 2);
    try {
        getFolderRepository().removeFolder(foo.getId());
        fail("Should throw exception because folder is not empty.");
    } catch (TDPException e) {
        assertEquals(FolderErrorCodes.FOLDER_NOT_EMPTY, e.getCode());
    }
}
Also used : TDPException(org.talend.dataprep.exception.TDPException) FolderEntry(org.talend.dataprep.api.folder.FolderEntry) Folder(org.talend.dataprep.api.folder.Folder) ServiceBaseTest(org.talend.ServiceBaseTest)

Example 8 with FolderEntry

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

the class AbstractFolderTest method create_entry_then_move.

/**
 * This test create two folders and a folder entry then move it to the other folder
 */
@Test
public void create_entry_then_move() throws Exception {
    // 2 folders /foo & /bar
    long sizeBefore = getFolderRepository().size();
    Folder foo = getFolderRepository().addFolder(homeFolderId, "foo");
    Folder bar = getFolderRepository().addFolder(homeFolderId, "bar");
    long sizeAfter = getFolderRepository().size();
    assertThat(sizeAfter).isEqualTo(sizeBefore + 2);
    assertChildrenSize(homeFolderId, 2);
    // bordeaux in /foo
    FolderEntry wineEntry = new FolderEntry(DATASET, "bordeaux");
    getFolderRepository().addFolderEntry(wineEntry, foo.getId());
    List<FolderEntry> entries = getDatasetsFromFolder(foo.getId());
    assertThat(entries).isNotNull().isNotEmpty().hasSize(1).contains(wineEntry);
    // move bordeaux to /bar
    getFolderRepository().moveFolderEntry(wineEntry, foo.getId(), bar.getId());
    entries = getDatasetsFromFolder(bar.getId());
    assertThat(entries).isNotNull().isNotEmpty().hasSize(1);
    assertFolderEntry(entries.get(0), "bordeaux", DATASET);
    // not in foo as it's a move
    assertThatFolderContainsExpectedNumberOfDatasets(foo.getId(), 0);
}
Also used : FolderEntry(org.talend.dataprep.api.folder.FolderEntry) Folder(org.talend.dataprep.api.folder.Folder) ServiceBaseTest(org.talend.ServiceBaseTest)

Example 9 with FolderEntry

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

the class AbstractFolderTest method rename_folder_with_entries_and_subfolders.

@Test
public void rename_folder_with_entries_and_subfolders() throws Exception {
    long sizeBefore = getFolderRepository().size();
    Folder foo = getFolderRepository().addFolder(homeFolderId, "foo");
    Folder foobeer = getFolderRepository().addFolder(foo.getId(), "beer");
    getFolderRepository().addFolder(foo.getId(), "bar");
    long sizeAfter = getFolderRepository().size();
    assertThat(sizeAfter).isEqualTo(sizeBefore + 3);
    assertChildrenSize(homeFolderId, 1);
    FolderEntry beerEntry = new FolderEntry(DATASET, "littlecreatures");
    getFolderRepository().addFolderEntry(beerEntry, foo.getId());
    FolderEntry wineEntry = new FolderEntry(DATASET, "bordeaux");
    getFolderRepository().addFolderEntry(wineEntry, foo.getId());
    wineEntry = new FolderEntry(DATASET, "bordeaux");
    getFolderRepository().addFolderEntry(wineEntry, foobeer.getId());
    assertThatFolderContainsExpectedNumberOfDatasets(foo.getId(), 2);
    assertThatExpectedNumberOfNamedDatasetIsFound("bordeaux", 2);
    assertThatExpectedNumberOfNamedDatasetIsFound("littlecreatures", 1);
    getFolderRepository().removeFolderEntry(foo.getId(), "littlecreatures", DATASET);
    assertThatFolderContainsExpectedNumberOfDatasets(foo.getId(), 1);
    assertChildrenSize(foo.getId(), 2);
    foo = getFolderRepository().renameFolder(foo.getId(), "wine");
    assertChildrenSize(foo.getId(), 2);
    // test FolderEntry moved as well
    assertThatFolderContainsExpectedNumberOfDatasets(foo.getId(), 1);
    getFolderRepository().removeFolderEntry(foo.getId(), "bordeaux", DATASET);
}
Also used : FolderEntry(org.talend.dataprep.api.folder.FolderEntry) Folder(org.talend.dataprep.api.folder.Folder) ServiceBaseTest(org.talend.ServiceBaseTest)

Example 10 with FolderEntry

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

the class AbstractFolderTest method create_child_with_two_entries_then_remove.

/**
 * This test create one child under root assert size, child list then create three folder entries then delete
 */
@Test
public void create_child_with_two_entries_then_remove() throws Exception {
    long sizeBefore = getFolderRepository().size();
    Folder foo = getFolderRepository().addFolder(homeFolderId, "foo");
    Folder foobeer = getFolderRepository().addFolder(foo.getId(), "beer");
    long sizeAfter = getFolderRepository().size();
    assertThat(sizeAfter).isEqualTo(sizeBefore + 2);
    assertChildrenSize(homeFolderId, 1);
    FolderEntry beerEntry = new FolderEntry(DATASET, "littlecreatures");
    FolderEntry wineEntry = new FolderEntry(DATASET, "bordeaux");
    getFolderRepository().addFolderEntry(beerEntry, foo.getId());
    getFolderRepository().addFolderEntry(wineEntry, foo.getId());
    wineEntry = new FolderEntry(DATASET, "bordeaux");
    getFolderRepository().addFolderEntry(wineEntry, foobeer.getId());
    assertThatFolderContainsExpectedNumberOfDatasets(foo.getId(), 2);
    assertThatExpectedNumberOfNamedDatasetIsFound("bordeaux", 2);
    assertThatExpectedNumberOfNamedDatasetIsFound("littlecreatures", 1);
    getFolderRepository().removeFolderEntry(foo.getId(), "littlecreatures", DATASET);
    getFolderRepository().removeFolderEntry(foo.getId(), "bordeaux", DATASET);
    getFolderRepository().removeFolderEntry(foobeer.getId(), "bordeaux", DATASET);
    assertThatFolderContainsExpectedNumberOfDatasets(foo.getId(), 0);
    getFolderRepository().removeFolder(foo.getId());
    sizeAfter = getFolderRepository().size();
    assertThat(sizeAfter).isEqualTo(sizeBefore);
    assertChildrenSize(homeFolderId, 0);
}
Also used : FolderEntry(org.talend.dataprep.api.folder.FolderEntry) Folder(org.talend.dataprep.api.folder.Folder) ServiceBaseTest(org.talend.ServiceBaseTest)

Aggregations

FolderEntry (org.talend.dataprep.api.folder.FolderEntry)25 Folder (org.talend.dataprep.api.folder.Folder)14 Test (org.junit.Test)10 ServiceBaseTest (org.talend.ServiceBaseTest)6 Response (com.jayway.restassured.response.Response)5 PreparationSearchCriterion.filterPreparation (org.talend.dataprep.preparation.service.PreparationSearchCriterion.filterPreparation)4 Properties (java.util.Properties)3 Preparation (org.talend.dataprep.api.preparation.Preparation)3 TDPException (org.talend.dataprep.exception.TDPException)3 StandalonePreparation (org.talend.dataprep.StandalonePreparation)2 EnrichedPreparation (org.talend.dataprep.api.service.api.EnrichedPreparation)2 BasePreparationTest (org.talend.dataprep.preparation.BasePreparationTest)2 UserPreparation (org.talend.dataprep.preparation.service.UserPreparation)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 FolderContentType (org.talend.dataprep.api.folder.FolderContentType)1