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);
}
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());
}
}
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);
}
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);
}
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);
}
Aggregations