410 lines
19 KiB
Java
410 lines
19 KiB
Java
package org.gcube.portal.social_networking_client_library;
|
|
|
|
import java.net.URL;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
|
|
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
import org.gcube.portal.databook.shared.EnhancedFeed;
|
|
import org.gcube.portal.databook.shared.Notification;
|
|
import org.gcube.portal.databook.shared.Post;
|
|
import org.gcube.social_networking.social_networking_client_library.FullTextSearchClient;
|
|
import org.gcube.social_networking.social_networking_client_library.HashTagClient;
|
|
import org.gcube.social_networking.social_networking_client_library.MessageClient;
|
|
import org.gcube.social_networking.social_networking_client_library.NotificationClient;
|
|
import org.gcube.social_networking.social_networking_client_library.PeopleClient;
|
|
import org.gcube.social_networking.social_networking_client_library.PostClient;
|
|
import org.gcube.social_networking.social_networking_client_library.TokenClient;
|
|
import org.gcube.social_networking.social_networking_client_library.UserClient;
|
|
import org.gcube.social_networking.social_networking_client_library.VREClient;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.ApplicationId;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.JobNotificationBean;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.JobStatusModelType;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.MessageInbox;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.MessageInputBean;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.MyVRE;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.PostInputBean;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.Recipient;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.UserProfile;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.UserProfileExtended;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.catalogue.CatalogueEvent;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.catalogue.CatalogueEventType;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.workspace.AddedItemEvent;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.workspace.DeletedItemEvent;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.workspace.FileItemBean;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.workspace.FolderBean;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.workspace.UpdatedItemEvent;
|
|
import org.gcube.social_networking.socialnetworking.model.beans.workspace.WorkspaceEvent;
|
|
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);
|
|
|
|
@SuppressWarnings("deprecation")
|
|
@Before
|
|
public void setContextAndToken(){
|
|
|
|
//ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/gCube");
|
|
//String umaToken = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJySUJPYjZZY3p2ZE4xNVpuNHFkUTRLdEQ5VUhyY1dwNWJCT3NaLXpYbXM0In0.eyJleHAiOjE2NjM2NjU2NTgsImlhdCI6MTY2MzY2NTM1OCwiYXV0aF90aW1lIjoxNjYzNjY0MTg1LCJqdGkiOiIxMjNhYmY0MS1lZmE1LTQ4ZjEtYmE2Zi03MjNkOWZjNDAwMWQiLCJpc3MiOiJodHRwczovL2FjY291bnRzLmQ0c2NpZW5jZS5vcmcvYXV0aC9yZWFsbXMvZDRzY2llbmNlIiwiYXVkIjoiJTJGZDRzY2llbmNlLnJlc2VhcmNoLWluZnJhc3RydWN0dXJlcy5ldSUyRmdDdWJlQXBwcyUyRmdDdWJlIiwic3ViIjoiMzM4OGQwZjgtM2E0OS00ZGEwLWE3OGUtN2I2MjI1OTI2M2U2IiwidHlwIjoiQmVhcmVy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
|
|
AccessTokenProvider.instance.set(umaToken);
|
|
SecurityTokenProvider.instance.set("");
|
|
}
|
|
|
|
|
|
@Test
|
|
public void testCatalogueEvents() throws Exception {
|
|
NotificationClient nc = new NotificationClient();
|
|
String[] idstoNotify = {"andrea.rossi"};
|
|
CatalogueEvent event =
|
|
new CatalogueEvent(
|
|
CatalogueEventType.ITEM_SUBMITTED,
|
|
idstoNotify,
|
|
"Submitted item RESTful Transaction Model",
|
|
"Giorgino Giorgetti created the item RESTful Transaction Model. You are kindly requested to review it and decide either to APPROVE or REJECT it. ",
|
|
new URL("https://data-dev.d4science.net/rU7T"));
|
|
nc.sendCatalogueEvent(event);
|
|
|
|
|
|
}
|
|
|
|
@Test
|
|
public void testWorkspaceItemEvents() throws Exception {
|
|
NotificationClient nc = new NotificationClient();
|
|
boolean vreFolder = false;
|
|
FolderBean folder = new FolderBean("217cbe15-6408-41e5-9fda-628f56b8e803", "folderName", "folderTitle","displayName",
|
|
"/Workspace/_shared attachments", "90b8da48-d363-441a-a0a2-6f614ae747b9", vreFolder);
|
|
FileItemBean fileItem = new FileItemBean("90b8da48-d363-441a-f0a2-4f413ae747d7", "updated item.pdf", "updated item.pdf",
|
|
"/Workspace/_shared attachments/test updated item from client", folder);
|
|
|
|
String[] idstoNotify = {"andrea.rossi"};
|
|
WorkspaceEvent event = new UpdatedItemEvent(idstoNotify, fileItem);
|
|
nc.sendWorkspaceEvent(event);
|
|
event = new AddedItemEvent(idstoNotify, fileItem);
|
|
nc.sendWorkspaceEvent(event);
|
|
event = new DeletedItemEvent(idstoNotify, "theDeletedFilenName.pdf", folder);
|
|
nc.sendWorkspaceEvent(event);
|
|
|
|
String[] contextIdstoNotify = {"/pred4s/preprod/preVRE"};
|
|
event = new UpdatedItemEvent(contextIdstoNotify, true, fileItem);
|
|
nc.sendWorkspaceEvent(event);
|
|
}
|
|
|
|
|
|
@Test
|
|
public void testSearch() throws Exception {
|
|
FullTextSearchClient search = new FullTextSearchClient();
|
|
ArrayList<EnhancedFeed> result = search.search("looking for test", 0, 10);
|
|
|
|
for (EnhancedFeed enhancedPost : result) {
|
|
logger.debug("Returned post " + enhancedPost);
|
|
}
|
|
}
|
|
|
|
//@Test
|
|
public void testSearchEmptyList() throws Exception {
|
|
FullTextSearchClient search = new FullTextSearchClient();
|
|
ArrayList<EnhancedFeed> result = search.search("tipiterotipirè", 0, 10);
|
|
|
|
for (EnhancedFeed enhancedFeed : result) {
|
|
logger.debug("Returned feed " + enhancedFeed);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testHashTags() throws Exception {
|
|
HashTagClient hashtags = new HashTagClient();
|
|
Map<String, Integer> hashtagsCount = hashtags.getHashtagsCount();
|
|
logger.debug("Returned tags " + hashtagsCount);
|
|
}
|
|
|
|
@Test
|
|
public void testMessagesReceived() throws Exception {
|
|
MessageClient messagesClient = new MessageClient();
|
|
List<MessageInbox> receivedMessages = messagesClient.getReceivedMessages();
|
|
System.out.println("Messages found # " + receivedMessages.size());
|
|
for (MessageInbox workspaceMessage : receivedMessages) {
|
|
logger.debug("Received message " + workspaceMessage.toString());
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testMessagesSent() throws Exception {
|
|
MessageClient messagesClient = new MessageClient();
|
|
List<MessageInbox> sentMessages = messagesClient.getSentMessages();
|
|
for (MessageInbox workspaceMessage : sentMessages) {
|
|
logger.debug("Sent message was " + workspaceMessage);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void sendMessage() throws Exception{
|
|
logger.debug("Sending message ");
|
|
MessageClient messagesClient = new MessageClient();
|
|
List<Recipient> rec = Arrays.asList(new Recipient("andrea.rossi"), new Recipient("giancarlo.panichi"));
|
|
MessageInputBean message = new MessageInputBean(
|
|
"Test message",
|
|
"Sending message via client " + System.currentTimeMillis(),
|
|
new ArrayList<Recipient>(rec));
|
|
String idMessage = messagesClient.writeMessage(message);
|
|
assert(idMessage != null);
|
|
}
|
|
|
|
@Test
|
|
public void markMessageRead() throws Exception{
|
|
logger.debug("markMessageRead message ");
|
|
MessageClient messagesClient = new MessageClient();
|
|
String idMessage = messagesClient.markMessageRead("a7b825c3-a0ca-42d7-b228-00b9e8f015e4", false);
|
|
assert(idMessage != null);
|
|
}
|
|
|
|
|
|
|
|
//@Test
|
|
public void testNotifications() throws Exception {
|
|
NotificationClient notificationsClient = new NotificationClient();
|
|
List<Notification> latestNotifications = notificationsClient.getNotifications(1, 2);
|
|
for (Notification notification : latestNotifications) {
|
|
logger.debug("Notification is " + notification);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void sendJobNotification() throws Exception {
|
|
NotificationClient notificationsClient = new NotificationClient();
|
|
JobNotificationBean notification = new JobNotificationBean(
|
|
"luca.frosini",
|
|
UUID.randomUUID().toString(),
|
|
"SmartExecutor Social Indexer",
|
|
"SmartExecutor",
|
|
JobStatusModelType.SUCCEEDED,
|
|
"all ok");
|
|
notificationsClient.sendJobNotification(notification);
|
|
logger.debug("Sent job notification ");
|
|
}
|
|
|
|
@Test
|
|
public void getProfile() throws Exception {
|
|
PeopleClient getProfile = new PeopleClient();
|
|
UserProfile profile = getProfile.getProfile();
|
|
logger.debug("Profile retrieved is " + profile);
|
|
}
|
|
|
|
//@Test
|
|
public void generateAppToken() throws Exception {
|
|
TokenClient tokenClient = new TokenClient();
|
|
String token = tokenClient.generateApplicationToken(new ApplicationId("org.gcube.datacatalogue.GRSFNotifier"));
|
|
logger.debug("Generated token is " + token);
|
|
}
|
|
|
|
//@Test
|
|
public void getMyVres() throws Exception{
|
|
VREClient myVresClient = new VREClient();
|
|
List<MyVRE> myVres = myVresClient.getMyVRES(false);
|
|
logger.debug("My Vres " + myVres);
|
|
}
|
|
|
|
@Test
|
|
public void TestUsersClient() throws Exception{
|
|
|
|
UserClient userClient = new UserClient();
|
|
Set<String> vreManagers = userClient.getAllUsernamesByRole("Data-Manager");
|
|
assert(vreManagers != null && !vreManagers.isEmpty());
|
|
System.out.println("Data Managers are " + vreManagers);
|
|
|
|
List<String> moderators = userClient.getAllUsernamesByLocalRole("VRE-Managers");
|
|
assert(moderators != null && !moderators.isEmpty());
|
|
System.out.println("Catalogue-Moderators are " + moderators);
|
|
|
|
|
|
|
|
String myEmail = userClient.getEmail();
|
|
|
|
assert(myEmail != null && !myEmail.isEmpty());
|
|
|
|
logger.debug("My email is " + myEmail);
|
|
|
|
String fullname = userClient.getFullName();
|
|
|
|
assert(fullname != null && !fullname.isEmpty());
|
|
|
|
logger.debug("My fullname is " + fullname);
|
|
|
|
String industry = userClient.getCustomAttribute("Industry");
|
|
|
|
//assert(industry != null && !industry.isEmpty());
|
|
|
|
logger.debug("My Industry is " + industry);
|
|
|
|
List<String> usernamesInThisContext = userClient.getAllUsernamesContext();
|
|
|
|
assert(usernamesInThisContext != null && !usernamesInThisContext.isEmpty());
|
|
|
|
logger.debug("List of usernames in this context is " + usernamesInThisContext);
|
|
|
|
Map<String, String> usernamesFullnameInThisContext = userClient.getAllUsernamesFullnamesContext();
|
|
|
|
assert(usernamesFullnameInThisContext != null && !usernamesFullnameInThisContext.isEmpty());
|
|
|
|
logger.debug("List of tuples usernames/fullnames in this context is " + usernamesFullnameInThisContext);
|
|
|
|
UserProfileExtended profile = userClient.getProfile();
|
|
|
|
assert(profile != null);
|
|
|
|
logger.debug("My wonderful profile is " + profile);
|
|
|
|
// Requires application token bound to the root context
|
|
// Boolean userExists = userClient.userExists("andrea.rossi");
|
|
//
|
|
// assert(userExists != null && userExists == true);
|
|
//
|
|
// logger.debug("does Andrea Rossi exist? " + userExists);
|
|
|
|
}
|
|
|
|
@Test
|
|
public void getUserPostsSinceDate() throws Exception{
|
|
|
|
PostClient postClient = new PostClient();
|
|
List<Post> sinceLastYearPost = postClient.getUserPostsSinceDate(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 12);
|
|
logger.debug("Posts are " + sinceLastYearPost);
|
|
|
|
}
|
|
|
|
@Test
|
|
public void getAllUserPosts() throws Exception{
|
|
|
|
PostClient postClient = new PostClient();
|
|
List<Post> allposts = postClient.getAllUserPosts();
|
|
logger.debug("All posts found:");
|
|
for (Post post : allposts) {
|
|
logger.debug(post.toString());
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Test
|
|
public void getUserPostsQuantity() throws Exception{
|
|
|
|
PostClient postClient = new PostClient();
|
|
List<Post> quantityPosts = postClient.getUserPostsQuantity(3);
|
|
logger.debug("Some posts are ");
|
|
logger.debug(quantityPosts + " posts found:");
|
|
for (Post post : quantityPosts) {
|
|
logger.debug(post.toString());
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void writeUserPost() throws Exception{
|
|
|
|
PostClient postClient = new PostClient();
|
|
PostInputBean postInputBean = new PostInputBean();
|
|
postInputBean.setText("Testing social networking rest client at " + new Date());
|
|
//Post post = postClient.writeApplicationPost(postInputBean);
|
|
PostInputBean post = new PostInputBean("Testing social networking rest client", null, null, null, null, null, false, null);
|
|
Post written = postClient.writeUserPost(postInputBean);
|
|
logger.debug("Written post is " + post);
|
|
|
|
}
|
|
|
|
//@Test
|
|
public void getAllApplicationPosts() throws Exception{
|
|
|
|
TokenClient tokenClient = new TokenClient();
|
|
String token = tokenClient.generateApplicationToken(new ApplicationId("org.gcube.datacatalogue.GRSFNotifier"));
|
|
logger.debug("Generated token is " + token);
|
|
|
|
String currentToken = SecurityTokenProvider.instance.get();
|
|
SecurityTokenProvider.instance.set(token);
|
|
|
|
PostClient postClient = new PostClient();
|
|
List<Post> applicationPosts = postClient.getAllApplicationPosts();
|
|
logger.debug("Application posts are " + applicationPosts);
|
|
|
|
SecurityTokenProvider.instance.set(currentToken);
|
|
|
|
}
|
|
|
|
//@Test
|
|
public void writeApplicationPost() throws Exception{
|
|
|
|
TokenClient tokenClient = new TokenClient();
|
|
String token = tokenClient.generateApplicationToken(new ApplicationId("org.gcube.datacatalogue.GRSFNotifier"));
|
|
logger.debug("Generated token is " + token);
|
|
|
|
String currentToken = SecurityTokenProvider.instance.get();
|
|
SecurityTokenProvider.instance.set(token);
|
|
|
|
PostClient postClient = new PostClient();
|
|
PostInputBean toWrite = new PostInputBean("Testing social networking rest client [via application token] #apptoken #rest #client #java", null, null, null, null, null, false, null);
|
|
Post written = postClient.writeApplicationPost(toWrite);
|
|
logger.debug("Written post is " + written);
|
|
|
|
SecurityTokenProvider.instance.set(currentToken);
|
|
|
|
}
|
|
|
|
@Test
|
|
public void getPostsVRE() throws Exception{
|
|
|
|
PostClient postClient = new PostClient();
|
|
List<Post> vrePosts = postClient.getVREPosts();
|
|
logger.debug("VRE posts : ");
|
|
for (Post post : vrePosts) {
|
|
logger.debug(post.toString());
|
|
}
|
|
|
|
}
|
|
|
|
//@Test
|
|
public void getHashtagPosts() throws Exception{
|
|
|
|
PostClient postClient = new PostClient();
|
|
List<Post> postsWithHashtag = postClient.getHashtagPosts("#connect");
|
|
logger.debug("Posts with hashtag #connect are " + postsWithHashtag);
|
|
|
|
}
|
|
|
|
@Test
|
|
public void getUserLikedPost() throws Exception{
|
|
|
|
PostClient postClient = new PostClient();
|
|
List<Post> postsLiked = postClient.getUserLikedPost();
|
|
logger.debug("Posts liked are " + postsLiked);
|
|
|
|
}
|
|
|
|
@Test
|
|
public void getUserLikedPostIds() throws Exception{
|
|
|
|
PostClient postClient = new PostClient();
|
|
List<String> postsLikedIds = postClient.getUserLikedPostIds();
|
|
logger.debug("Posts liked's ids are " + postsLikedIds);
|
|
|
|
}
|
|
|
|
|
|
//@After
|
|
public void reset(){
|
|
ScopeProvider.instance.reset();
|
|
SecurityTokenProvider.instance.reset();
|
|
}
|
|
}
|