diff --git a/pom.xml b/pom.xml index 218b502..c2997f3 100644 --- a/pom.xml +++ b/pom.xml @@ -202,7 +202,8 @@ maven-surefire-plugin 2.16 - true + **/GwtTest*.java + @@ -222,6 +223,7 @@ + test resources diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java index eb330ef..eaaf00f 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java @@ -62,6 +62,17 @@ public interface TDGWTService extends RemoteService { */ public TabResource getTabResourceInformation() throws TDGWTServiceException; + + /** + * Get informations on tabular resource + * + * @return + * @throws TDGWTServiceException + */ + public TabResource getTabResourceInformation(TRId trId) throws TDGWTServiceException; + + + /** * Set current tabular resource * diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java index ede238b..03d2609 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java @@ -11,6 +11,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor; import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor; @@ -48,6 +49,8 @@ public interface TDGWTServiceAsync { void getTabResourceInformation(AsyncCallback callback); + void getTabResourceInformation(TRId trId,AsyncCallback callback); + void setTabResource(TabResource tabResource, AsyncCallback callback); void getTabularResources(AsyncCallback> callback); diff --git a/src/test/java/org/gcube/portlets/user/td/gwtservice/client/GwtTestTDGWTService.java b/src/test/java/org/gcube/portlets/user/td/gwtservice/client/GwtTestTDGWTService.java index e74b226..4b4f67c 100644 --- a/src/test/java/org/gcube/portlets/user/td/gwtservice/client/GwtTestTDGWTService.java +++ b/src/test/java/org/gcube/portlets/user/td/gwtservice/client/GwtTestTDGWTService.java @@ -1,22 +1,29 @@ package org.gcube.portlets.user.td.gwtservice.client; +import java.util.ArrayList; + import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTService; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; import com.google.gwt.core.client.GWT; + import com.google.gwt.junit.client.GWTTestCase; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.ServiceDefTarget; /** * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * */ public class GwtTestTDGWTService extends GWTTestCase { + // protected static final Logger logger= + // LoggerFactory.getLogger(GwtTestTDGWTService.class); /** * Must refer to a valid module that sources this class. */ @@ -28,7 +35,9 @@ public class GwtTestTDGWTService extends GWTTestCase { /** * This test will send a request to the server */ - public void testCreateTabResource() { + public void testListTabularResource() { + System.out.println("---------TEST List Tabular Resource--------"); + // Create the service that we will test. TDGWTServiceAsync tdGWTService = GWT.create(TDGWTService.class); ServiceDefTarget target = (ServiceDefTarget) tdGWTService; @@ -40,34 +49,35 @@ public class GwtTestTDGWTService extends GWTTestCase { // wait // up to 7 seconds before timing out. delayTestFinish(7000); - TabResource tabResource=new TabResource(); - tabResource.setName("TestTabularResource"); - tabResource.setAgency("FAO"); - tabResource.setDescription("Tabular Resource Test"); - tabResource.setRight(""); - + // Send a request to the server. - TDGWTServiceAsync.INSTANCE.createTabularResource(tabResource,new AsyncCallback() { + TDGWTServiceAsync.INSTANCE + .getTabularResources(new AsyncCallback>() { - @Override - public void onFailure(Throwable caught) { - // The request resulted in an unexpected error. - fail("Request failure: " + caught.getMessage()); - - } + @Override + public void onFailure(Throwable caught) { + // The request resulted in an unexpected error. + fail("Request failure: " + caught.getMessage()); - @Override - public void onSuccess(TabResource result) { - assertTrue(result != null); - System.out.println(result); - finishTest(); - - } + } + + @Override + public void onSuccess(ArrayList result) { + assertTrue(result != null); + System.out.println(""); + if (result.size() <= 0) { + System.out.println("----------------->No tabular Resources for this user."); + } else { + for (TabResource tr : result) { + System.out.println("--------------->TR: " + tr); + } + } + finishTest(); + + } + + }); - }); - } } - - diff --git a/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestService.java b/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestService.java index 9d1dcf7..15449d0 100644 --- a/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestService.java +++ b/src/test/java/org/gcube/portlets/user/td/gwtservice/client/TestService.java @@ -200,4 +200,7 @@ public class TestService { System.out.println("TabularResource:" + tr.getId()); } } + + + }