93 lines
3.3 KiB
Java
93 lines
3.3 KiB
Java
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 ");
|
|
}
|
|
}
|