From c70d574f45ed7283d0b89b6be4cb1a2f6cd50e3d Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Tue, 26 Jun 2018 15:31:07 +0000 Subject: [PATCH] added junit test git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@169463 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../WorkspaceStorageHubClientService.java | 11 ------- .../server/tohl/Workspace.java | 10 ------ src/test/java/WorkspaceInstance.java | 32 ++++++++++++++++++- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java index 21513fd..fe1811d 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java @@ -597,17 +597,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{ return null; } - /* (non-Javadoc) - * @see org.gcube.portal.storagehubwrapper.shared.Workspace#find(java.lang.String) - */ - @Override - public WorkspaceItem find(String path) - throws InternalErrorException { - - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) * @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByName(java.lang.String, java.lang.String) */ diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java b/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java index fc47e4d..68bbe2a 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java @@ -344,16 +344,6 @@ public interface Workspace{ public WorkspaceItem copy(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, WorkspaceFolderNotFoundException; - /** - * Find an item using the specified path. - * - * @param path the item path. - * @return the item if the item is found, null otherwise. - * @throws InternalErrorException if an error occurs. - */ - public WorkspaceItem find(String path) throws InternalErrorException; - - /** * Search by Name. * diff --git a/src/test/java/WorkspaceInstance.java b/src/test/java/WorkspaceInstance.java index fdae7ce..fcd03e9 100644 --- a/src/test/java/WorkspaceInstance.java +++ b/src/test/java/WorkspaceInstance.java @@ -9,6 +9,7 @@ import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder; import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem; import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException; import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException; +import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongItemTypeException; import org.gcube.common.storagehubwrapper.shared.tohl.impl.FileItem; import org.gcube.common.storagehubwrapper.shared.tohl.impl.ImageFile; import org.gcube.common.storagehubwrapper.shared.tohl.impl.PDFFile; @@ -32,6 +33,10 @@ public class WorkspaceInstance { public static String SCOPE = "/gcube"; public static String TOKEN = "0e2c7963-8d3e-4ea6-a56d-ffda530dd0fa-98187548"; + public static String FIND_FILE_NAME = "francesco"; + + public static String rootId = null; + StorageHubWrapper storageHubWrapper = null; //Workspace workspace = null; @@ -57,6 +62,7 @@ public class WorkspaceInstance { WorkspaceFolder root; try { root = storageHubWrapper.getWorkspace().getRoot(); + rootId = root.getId(); System.out.println(root); } catch (InternalErrorException e) { @@ -89,7 +95,7 @@ public class WorkspaceInstance { @Test public void getWorkspaceId() { - System.out.println("Getting the workspaceId"); + System.out.println("Getting the workspaceId test"); try { Workspace workspace = storageHubWrapper.getWorkspace(); if(workspace!=null){ @@ -159,4 +165,28 @@ public class WorkspaceInstance { } } + + @Test + public void findFileName() throws InternalErrorException{ + System.out.println("Find file name test"); + getRoot(); + try { + List foundItems = storageHubWrapper.getWorkspace().find(FIND_FILE_NAME,rootId); + + if(foundItems==null || foundItems.size()==0){ + System.out.println("No Items found with name: "+FIND_FILE_NAME+ " in the parent: "+rootId); + return; + } + + System.out.println("Items found with name: "+FIND_FILE_NAME+ " in the parent: "+rootId +" are:"); + for (WorkspaceItem workspaceItem : foundItems) { + System.out.println(workspaceItem); + } + } + catch (ItemNotFoundException | WrongItemTypeException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } }