diff --git a/.classpath b/.classpath index 7bd7856..28af2a9 100644 --- a/.classpath +++ b/.classpath @@ -12,15 +12,11 @@ - - - - - + diff --git a/pom.xml b/pom.xml index c198bf3..bd1c536 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,7 @@ 1.7 2.25.1 ${project.basedir}/distro + social-networking ${project.build.directory}/${project.build.finalName} distro UTF-8 @@ -38,9 +39,9 @@ - scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId} - scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId} - http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId} + scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/${gCubeSubsystem}/${project.artifactId} + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/${gCubeSubsystem}/${project.artifactId} + http://svn.d4science.research-infrastructures.eu/gcube/trunk/${gCubeSubsystem}/${project.artifactId} @@ -187,9 +188,6 @@ fully.qualified.MainClass - - - diff --git a/src/main/java/org/gcube/portal/social_networking_client_library/NotificationsClient.java b/src/main/java/org/gcube/portal/social_networking_client_library/NotificationsClient.java index e91751a..9daebf0 100644 --- a/src/main/java/org/gcube/portal/social_networking_client_library/NotificationsClient.java +++ b/src/main/java/org/gcube/portal/social_networking_client_library/NotificationsClient.java @@ -49,15 +49,14 @@ public class NotificationsClient extends BaseClient{ * @param notification * @return */ - @SuppressWarnings("unchecked") - public List sendJobNotification(JobNotificationBean notification){ + public void sendJobNotification(JobNotificationBean notification){ Validate.isTrue(notification != null, "Notification cannot be null"); logger.debug("Request for getting notifications"); String thisMethodSignature = "notify-job-status"; String request = getServiceEndpoint() + thisMethodSignature; - return HttpClient.post(new ArrayList(0).getClass(), request, SecurityTokenProvider.instance.get(), notification); + HttpClient.post(Void.class, request, SecurityTokenProvider.instance.get(), notification); } diff --git a/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java b/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java new file mode 100644 index 0000000..5d7ea51 --- /dev/null +++ b/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java @@ -0,0 +1,92 @@ +package org.gcube.portal.social_networking_client_library; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; +import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.portal.databook.shared.EnhancedFeed; +import org.gcube.portal.databook.shared.JobStatusType; +import org.gcube.portal.databook.shared.Notification; +import org.gcube.portal.socialnetworking.model.input.JobNotificationBean; +import org.gcube.portal.socialnetworking.model.input.MessageInputBean; +import org.gcube.portal.socialnetworking.model.input.Recipient; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestClientServices { + + private static Logger logger = LoggerFactory.getLogger(TestClientServices.class); + + @Before + public void setContextAndToken(){ + + ScopeProvider.instance.set("/gcube/devNext/NextNext"); + SecurityTokenProvider.instance.set("d423aed7-e9e2-424a-b9e7-2bbbd151d9c4-98187548"); + + } + + @Test + public void testSearch() throws Exception { + FullTextSearchClient search = new FullTextSearchClient(); + List result = search.search("looking for test", 0, 10); + + for (EnhancedFeed enhancedFeed : result) { + logger.debug("Returned feed " + enhancedFeed); + } + } + + @Test + public void testHashTags() throws Exception { + HashTagsClient hashtags = new HashTagsClient(); + Map hashtagsCount = hashtags.getHashtagsCount(); + logger.debug("Returned tags " + hashtagsCount); + } + + @Test + public void testMessages() throws Exception { + MessagesClient messagesClient = new MessagesClient(); + List receivedMessages = messagesClient.getReceivedMessages(); + + for (WorkspaceMessage workspaceMessage : receivedMessages) { + logger.debug("Received message " + workspaceMessage.toString()); + } + + List sentMessages = messagesClient.getSentMessages(); + for (WorkspaceMessage workspaceMessage : sentMessages) { + logger.debug("Sent message was " + workspaceMessage); + } + + logger.debug("Sending message "); + List rec = Arrays.asList(new Recipient("andrea.rossi")); + MessageInputBean input = new MessageInputBean("Test message", + "Sending message via client " + System.currentTimeMillis(), + new ArrayList(rec)); + String idMessage = messagesClient.writeMessage(input); + assert(idMessage != null); + } + + @Test + public void testNotifications() throws Exception { + NotificationsClient notificationsClient = new NotificationsClient(); + List latestNotifications = notificationsClient.getNotifications(0, 2000); + for (Notification notification : latestNotifications) { + logger.debug("Notification is " + notification); + } + } + + @Test + public void sendJobNotification() throws Exception { + NotificationsClient notificationsClient = new NotificationsClient(); + JobNotificationBean notification = new JobNotificationBean("costantino.perciante", UUID.randomUUID().toString(), "SmartExecutor Social Indexer", "SmartExecutor", + JobStatusType.SUCCEEDED, ""); + notificationsClient.sendJobNotification(notification); + logger.debug("Sent job notification and received "); + } +}