use of org.talend.dataprep.api.folder.FolderTreeNode in project data-prep by Talend.
the class FolderAPITest method shouldReturnEntireFolderTree.
@Test
public void shouldReturnEntireFolderTree() throws Exception {
// given
// HOME
// ___________|____________
// | |
// first second
// ____|____ |
// | | |
// first child 1 first child 2 second child
// |
// |
// second child child
createFolder("first", home.getId());
createFolder("second", home.getId());
final Folder firstFolder = getFolder(home.getId(), "first");
final Folder secondFolder = getFolder(home.getId(), "second");
createFolder("first child one", firstFolder.getId());
createFolder("first child two", firstFolder.getId());
createFolder("second child", secondFolder.getId());
final Folder secondChildFolder = getFolder(secondFolder.getId(), "second child");
createFolder("second child child", secondChildFolder.getId());
// when
final Response response = //
given().expect().statusCode(200).log().ifError().when().get("/folders/tree");
// then
final FolderTreeNode tree = mapper.readValue(response.asString(), new TypeReference<FolderTreeNode>() {
});
assertTree(tree, "/", new String[] { "/first", "/second" });
final FolderTreeNode firstFolderNode = getChild(tree, "first");
final FolderTreeNode secondFolderNode = getChild(tree, "second");
assertTree(firstFolderNode, "/first", new String[] { "/first/first child one", "/first/first child two" });
assertTree(secondFolderNode, "/second", new String[] { "/second/second child" });
final FolderTreeNode secondChildFolderNode = getChild(secondFolderNode, "second child");
assertTree(secondChildFolderNode, "/second/second child", new String[] { "/second/second child/second child child" });
}
use of org.talend.dataprep.api.folder.FolderTreeNode in project data-prep by Talend.
the class FolderServiceTest method shouldReturnEntireFolderTree.
@Test
public void shouldReturnEntireFolderTree() throws Exception {
// @formatter:off
// given
// HOME
// ___________|____________
// | |
// first second
// ____|____ |
// | | |
// first child 1 first child 2 second child
// |
// |
// second child child
// @formatter:on
createFolder(home.getId(), "first");
createFolder(home.getId(), "second");
final Folder firstFolder = getFolder(home.getId(), "first");
final Folder secondFolder = getFolder(home.getId(), "second");
createFolder(firstFolder.getId(), "first child one");
createFolder(firstFolder.getId(), "first child two");
createFolder(secondFolder.getId(), "second child");
final Folder secondChildFolder = getFolder(secondFolder.getId(), "second child");
createFolder(secondChildFolder.getId(), "second child child");
// when
final Response response = //
given().expect().statusCode(200).log().ifError().when().get("/folders/tree");
// then
final FolderTreeNode tree = mapper.readValue(response.asString(), new TypeReference<FolderTreeNode>() {
});
assertTree(tree, "/", new String[] { "/first", "/second" });
final FolderTreeNode firstFolderNode = getChild(tree, "first");
final FolderTreeNode secondFolderNode = getChild(tree, "second");
assertTree(firstFolderNode, "/first", new String[] { "/first/first child one", "/first/first child two" });
assertTree(secondFolderNode, "/second", new String[] { "/second/second child" });
final FolderTreeNode secondChildFolderNode = getChild(secondFolderNode, "second child");
assertTree(secondChildFolderNode, "/second/second child", new String[] { "/second/second child/second child child" });
}
Aggregations