started adding junit tests
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/social-networking/social-networking-client-library@157528 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2e7b88f4dd
commit
e6c711f5d8
|
@ -12,15 +12,11 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
10
pom.xml
10
pom.xml
|
@ -31,6 +31,7 @@
|
|||
<java-version>1.7</java-version>
|
||||
<version.jersey>2.25.1</version.jersey>
|
||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||
<gCubeSubsystem>social-networking</gCubeSubsystem>
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -38,9 +39,9 @@
|
|||
</properties>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</connection>
|
||||
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</developerConnection>
|
||||
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</url>
|
||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/${gCubeSubsystem}/${project.artifactId}</connection>
|
||||
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/${gCubeSubsystem}/${project.artifactId}</developerConnection>
|
||||
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/${gCubeSubsystem}/${project.artifactId}</url>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
|
@ -187,9 +188,6 @@
|
|||
<mainClass>fully.qualified.MainClass</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<!-- <descriptorRefs> -->
|
||||
<!-- <descriptorRef>jar-with-dependencies</descriptorRef> -->
|
||||
<!-- </descriptorRefs> -->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
|
|
@ -49,15 +49,14 @@ public class NotificationsClient extends BaseClient{
|
|||
* @param notification
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Notification> 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<Notification>(0).getClass(), request, SecurityTokenProvider.instance.get(), notification);
|
||||
HttpClient.post(Void.class, request, SecurityTokenProvider.instance.get(), notification);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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<EnhancedFeed> 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<String, Integer> hashtagsCount = hashtags.getHashtagsCount();
|
||||
logger.debug("Returned tags " + hashtagsCount);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessages() throws Exception {
|
||||
MessagesClient messagesClient = new MessagesClient();
|
||||
List<WorkspaceMessage> receivedMessages = messagesClient.getReceivedMessages();
|
||||
|
||||
for (WorkspaceMessage workspaceMessage : receivedMessages) {
|
||||
logger.debug("Received message " + workspaceMessage.toString());
|
||||
}
|
||||
|
||||
List<WorkspaceMessage> sentMessages = messagesClient.getSentMessages();
|
||||
for (WorkspaceMessage workspaceMessage : sentMessages) {
|
||||
logger.debug("Sent message was " + workspaceMessage);
|
||||
}
|
||||
|
||||
logger.debug("Sending message ");
|
||||
List<Recipient> rec = Arrays.asList(new Recipient("andrea.rossi"));
|
||||
MessageInputBean input = new MessageInputBean("Test message",
|
||||
"Sending message via client " + System.currentTimeMillis(),
|
||||
new ArrayList<Recipient>(rec));
|
||||
String idMessage = messagesClient.writeMessage(input);
|
||||
assert(idMessage != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotifications() throws Exception {
|
||||
NotificationsClient notificationsClient = new NotificationsClient();
|
||||
List<Notification> 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 ");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue