added test for getting notification preferences of a given type for every user

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@95332 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-05-05 16:52:22 +00:00
parent 750b9b0d4e
commit 08900dbc9b
3 changed files with 333 additions and 308 deletions

View File

@ -9,5 +9,5 @@ log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.logger.org.gcube=TRACE log4j.logger.org.gcube=TRACE
log4j.logger.org.gcube.application.framework.core.session=INFO log4j.logger.org.gcube.application.framework.core.session=INFO
log4j.logger.com.netflix.astyanax.connectionpool=ERROR log4j.logger.com.netflix.astyanax.connectionpool=ERROR
log4j.logger.org.gcube.portal.databook.server.DBCassandraAstyanaxImpl=TRACE log4j.logger.org.gcube.portal.databook.server.DBCassandraAstyanaxImpl=DEBUG
log4j.logger.org.gcube.common=ERROR log4j.logger.org.gcube.common=ERROR

View File

@ -122,7 +122,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
USER_MESSAGES_NOTIFICATIONS, // Column Family Name USER_MESSAGES_NOTIFICATIONS, // Column Family Name
StringSerializer.get(), // Key Serializer StringSerializer.get(), // Key Serializer
StringSerializer.get()); // Column Serializer StringSerializer.get()); // Column Serializer
private static ColumnFamily<String, String> cf_UserNotificationsPreferences = new ColumnFamily<String, String>( protected static ColumnFamily<String, String> cf_UserNotificationsPreferences = new ColumnFamily<String, String>(
USER_NOTIFICATIONS_PREFERENCES, // Column Family Name USER_NOTIFICATIONS_PREFERENCES, // Column Family Name
StringSerializer.get(), // Key Serializer StringSerializer.get(), // Key Serializer
StringSerializer.get()); // Column Serializer StringSerializer.get()); // Column Serializer
@ -133,6 +133,10 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
* connection instance * connection instance
*/ */
private CassandraClusterConnection conn; private CassandraClusterConnection conn;
protected CassandraClusterConnection getConnection() {
return conn;
}
/** /**
* use this constructor carefully from test classes * use this constructor carefully from test classes
* @param dropSchema set true if you want do drop the current and set up new one * @param dropSchema set true if you want do drop the current and set up new one

View File

@ -3,6 +3,7 @@ package org.gcube.portal.databook.server;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -25,6 +26,11 @@ import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import com.netflix.astyanax.connectionpool.OperationResult;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
import com.netflix.astyanax.model.Row;
import com.netflix.astyanax.model.Rows;
public class DatabookCassandraTest { public class DatabookCassandraTest {
private static DBCassandraAstyanaxImpl store; private static DBCassandraAstyanaxImpl store;
@ -39,324 +45,339 @@ public class DatabookCassandraTest {
System.out.println("End"); System.out.println("End");
} }
@Test
public void testLikes() {
int count = 10;
Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
"http://www.d4science.org/monitor", "thumbUri", "This feed is Liked ", PrivacyLevel.PUBLIC,
"Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
assertTrue(store.saveUserFeed(feed));
Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante",
new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl");
private List<String> getKeys() {
List<String> toReturn = new ArrayList<String>();
try { try {
assertTrue(store.like(toUnlike));
for (int i = 0; i < count; i++)
assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante",
new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl")));
System.out.println("massimiliano.assante liked the following feeds: "); OperationResult<Rows<String, String>> rows = store.getConnection().getKeyspace().prepareQuery(DBCassandraAstyanaxImpl.cf_UserNotificationsPreferences)
for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) { .getAllRows()
System.out.println(feedid); .setRowLimit(1000) // This is the page size
} .execute();
int i = 1;
for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) { for (Row<String, String> row : rows.getResult()) {
System.out.println(like); System.out.println(i+" ROW: " + row.getKey() + " " + row.getColumns().size());
} toReturn.add(row.getKey());
System.out.println("massimiliano.assante trying unlike the following feed: " + toUnlike); i++;
store.unlike("massimiliano.assante", toUnlike.getKey(), toUnlike.getFeedid()); }
} catch (ConnectionException e) {
} catch (Exception e) { e.printStackTrace();
System.out.println("Exception feed id not found");
} }
} return toReturn;
/**
* use exclusively to add a new CF to a keyspace
*/
@Test
public void addNotifPreferencesColumnFamily() {
// ColumnFamily<String, String> cf_UserNotificationsPreferences = new ColumnFamily<String, String>(
// DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES, // Column Family Name
// StringSerializer.get(), // Key Serializer
// StringSerializer.get()); // Column Serializer
//
// try {
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsPreferences, ImmutableMap.<String, Object>builder()
// .put("default_validation_class", "UTF8Type")
// .put("key_validation_class", "UTF8Type")
// .put("comparator_type", "UTF8Type")
// .build());
// } catch (ConnectionException e) {
// e.printStackTrace();
// }
} }
@Test @Test
public void testFriendships() { public void testUserNotificationPreferences() {
assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela")); System.out.println("Notification type" + NotificationType.POST_ALERT.toString() +" OFF for:");
assertTrue(store.requestFriendship("massimiliano.assante", "ermit"));
assertTrue(store.requestFriendship("massimiliano.assante", "giorgino"));
assertTrue(store.requestFriendship("barabba", "massimiliano.assante"));
assertTrue(store.approveFriendship("leonardo.candela", "massimiliano.assante"));
assertTrue(store.approveFriendship("ermit", "massimiliano.assante"));
assertTrue(store.denyFriendship("giorgino", "massimiliano.assante"));
System.out.println("Pending Connections for massimiliano.assante:");
for (String userid: store.getPendingFriendRequests("massimiliano.assante")) {
System.out.println(userid);
}
System.out.println("Connections for massimiliano.assante:");
for (String userid: store.getFriends("massimiliano.assante")) {
System.out.println(userid);
}
}
@Test
public void testLikedFeedsRetrieval() {
try { try {
for (Feed feed : store.getAllLikedFeedsByUser("luca.frosini", 10)) { for (String user : getKeys()) {
System.out.println(feed); List<NotificationChannelType> channels = store.getUserNotificationChannels(user, NotificationType.POST_ALERT);
if (channels.isEmpty()) {
System.out.println(user);
}
else if (! channels.contains(NotificationChannelType.EMAIL)) {
System.out.println(user + "->" + channels.toString());
}
} }
} catch (Exception e) {
e.printStackTrace();
}
}
@Test // for (NotificationChannelType channel : store.getUserNotificationChannels("roberto.trasarti", NotificationType.POST_ALERT)) {
public void testSingleNotificationPreference() { // System.out.println(channel);
try { // }
for (NotificationChannelType channel : store.getUserNotificationChannels("massimiliano.assante", NotificationType.COMMENT)) {
System.out.println(channel);
}
} catch (NotificationChannelTypeNotFoundException e) { } catch (NotificationChannelTypeNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} catch (NotificationTypeNotFoundException e) { } catch (NotificationTypeNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
}; };
HashMap<NotificationType, NotificationChannelType[]> toCreate = new HashMap<NotificationType, NotificationChannelType[]>();
for (int i = 0; i < NotificationType.values().length; i++) {
if (i == 0)
toCreate.put(NotificationType.values()[i], null);
else if (i ==3) {
NotificationChannelType[] nots = {NotificationChannelType.PORTAL};
toCreate.put(NotificationType.values()[i], nots);
}
else
toCreate.put(NotificationType.values()[i], NotificationChannelType.values());
}
store.setUserNotificationPreferences("antonio.gioia", toCreate);
try {
for (NotificationChannelType channel : store.getUserNotificationChannels("antonio.gioia", NotificationType.WP_FOLDER_RENAMED)) { //i == 3
System.out.println(channel);
}
} catch (Exception e) {
e.printStackTrace();
}
} }
@Test // @Test
public void testSingleNotification() { // public void testLikes() {
Notification not = new Notification( // int count = 10;
UUID.randomUUID().toString(), // Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
NotificationType.LIKE, // "http://www.d4science.org/monitor", "thumbUri", "This feed is Liked ", PrivacyLevel.PUBLIC,
"leonardo.candela", // "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
"MESSAGEID", // assertTrue(store.saveUserFeed(feed));
new Date(), // Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante",
"uri", // new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl");
"This is notification about a like", //
false, // try {
"leonardo.candela", "Leonardo Candela", // assertTrue(store.like(toUnlike));
"thumburl"); // for (int i = 0; i < count; i++)
assertTrue(store.saveNotification(not)); // assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante",
// new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl")));
not = new Notification( //
UUID.randomUUID().toString(), // System.out.println("massimiliano.assante liked the following feeds: ");
NotificationType.MESSAGE, // for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) {
"massimiliano.assante", // System.out.println(feedid);
"MESSAGEID", // }
new Date(), //
"uri", // for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) {
"This is notification about a like", // System.out.println(like);
false, // }
"antonio.gioia", "Antonio Gioia", // System.out.println("massimiliano.assante trying unlike the following feed: " + toUnlike);
"thumburl"); // store.unlike("massimiliano.assante", toUnlike.getKey(), toUnlike.getFeedid());
assertTrue(store.saveNotification(not)); //
System.out.println("Writing one Notification " + not); // } catch (Exception e) {
} // System.out.println("Exception feed id not found");
// }
@Test // }
public void testNotifications() { // /**
Notification not = null; // * use exclusively to add a new CF to a keyspace
System.out.println("Writing 18 Notifications"); // */
int count = 18; // @Test
for (int i = 0; i < count; i++) { // public void addNotifPreferencesColumnFamily() {
if (i % 2 != 0) { // // ColumnFamily<String, String> cf_UserNotificationsPreferences = new ColumnFamily<String, String>(
not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_OK, // // DBCassandraAstyanaxImpl.USER_NOTIFICATIONS_PREFERENCES, // Column Family Name
"leonardo.candela", "TWEETID", new Date(), "uri", "This is notification about job completed OK #"+i, false, "pasquale.pagano", "Pasquale Pagano", "thumburl"); // // StringSerializer.get(), // Key Serializer
} else { // // StringSerializer.get()); // Column Serializer
not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_NOK, // //
"massimiliano.assante", "MESSAGEID", new Date(), "uri", "This is notification about completed NOK #"+i, false, "leonardo.candela", "Leonardo Candela", "thumburl"); // // try {
} // // new CassandraClusterConnection(false).getKeyspace().createColumnFamily(cf_UserNotificationsPreferences, ImmutableMap.<String, Object>builder()
assertTrue(store.saveNotification(not)); // // .put("default_validation_class", "UTF8Type")
try { // // .put("key_validation_class", "UTF8Type")
Thread.sleep(150); // // .put("comparator_type", "UTF8Type")
} catch (InterruptedException e) { // // .build());
// TODO Auto-generated catch block // // } catch (ConnectionException e) {
e.printStackTrace(); // // e.printStackTrace();
} // // }
} // }
//
Notification rNot= null; // @Test
try { // public void testFriendships() {
// assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela"));
//read // assertTrue(store.requestFriendship("massimiliano.assante", "ermit"));
rNot = store.readNotification(not.getKey().toString()); // assertTrue(store.requestFriendship("massimiliano.assante", "giorgino"));
assertNotNull(rNot); // assertTrue(store.requestFriendship("barabba", "massimiliano.assante"));
System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType()); //
// assertTrue(store.approveFriendship("leonardo.candela", "massimiliano.assante"));
//set Read // assertTrue(store.approveFriendship("ermit", "massimiliano.assante"));
assertTrue(store.setNotificationRead(rNot.getKey().toString())); //
// assertTrue(store.denyFriendship("giorgino", "massimiliano.assante"));
System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ"); // System.out.println("Pending Connections for massimiliano.assante:");
// for (String userid: store.getPendingFriendRequests("massimiliano.assante")) {
not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE, // System.out.println(userid);
"leonardo.candela", "FEEDID", new Date(), "uri", "This is notification of a Liked Leo feed by Massi", false, "massimiliano.assante", "Massimiliano Assante", "thumburl"); // }
assertTrue(store.saveNotification(not)); //
try { // System.out.println("Connections for massimiliano.assante:");
Thread.sleep(150); // for (String userid: store.getFriends("massimiliano.assante")) {
} catch (InterruptedException e) { // System.out.println(userid);
// TODO Auto-generated catch block // }
e.printStackTrace(); //
} // }
rNot = store.readNotification(not.getKey().toString()); // @Test
System.out.println("Reading another Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " Read:? " + rNot.isRead()); // public void testLikedFeedsRetrieval() {
// //set Read // try {
// assertTrue(store.setNotificationRead(rNot.getKey().toString())); // for (Feed feed : store.getAllLikedFeedsByUser("luca.frosini", 10)) {
// System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ subject was this: " + rNot.getSubjectid()); // System.out.println(feed);
// // }
Random randomGenerator = new Random(); // } catch (Exception e) {
// e.printStackTrace();
System.out.println("leonardo.candela Notifications: "); // }
List<Notification> recentNots = store.getAllNotificationByUser("leonardo.candela", randomGenerator.nextInt(50)); // }
assertNotNull(recentNots); //
for (Notification notif :recentNots) //
System.out.println(notif); //
//
// @Test
System.out.println("massimiliano.assante Notifications: "); // public void testSingleNotification() {
recentNots = store.getUnreadNotificationsByUser("massimiliano.assante"); // Notification not = new Notification(
assertNotNull(recentNots); // UUID.randomUUID().toString(),
for (Notification notif :recentNots) // NotificationType.LIKE,
System.out.println(notif); // "leonardo.candela",
} catch (Exception e) { // "MESSAGEID",
e.printStackTrace(); // new Date(),
} // "uri",
// "This is notification about a like",
System.out.println("getRangeNotificationsByUser massimiliano.assante: "); // false,
try { // "leonardo.candela", "Leonardo Candela",
int from = 0; // "thumburl");
for (int i = 0; i < 5; i++) { // assertTrue(store.saveNotification(not));
System.out.println("\nFROM="+from); //
List<Notification> range = store.getRangeNotificationsByUser("massimiliano.assante", from, 50); // not = new Notification(
for (Notification notification : range) { // UUID.randomUUID().toString(),
System.out.println(notification.getDescription()); // NotificationType.MESSAGE,
from = 1+i * 50; // "massimiliano.assante",
} // "MESSAGEID",
} // new Date(),
} catch (Exception e) { // "uri",
e.printStackTrace(); // "This is notification about a like",
} // false,
} // "antonio.gioia", "Antonio Gioia",
// "thumburl");
// assertTrue(store.saveNotification(not));
@Test // System.out.println("Writing one Notification " + not);
public void testFeeds() { // }
int count = 18; //
Feed feed = null; // @Test
for (int i = 0; i < count; i++) { // public void testNotifications() {
if (i % 2 != 0) { // Notification not = null;
feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE", // System.out.println("Writing 18 Notifications");
"www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host"); // int count = 18;
} else { // for (int i = 0; i < count; i++) {
feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "", // if (i % 2 != 0) {
"www.d4science.org/web/guest", "thumbUri", "This is feed# "+ i, PrivacyLevel.PORTAL, "Leonardo Candela", "leonardo.candela@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host"); // not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_OK,
} // "leonardo.candela", "TWEETID", new Date(), "uri", "This is notification about job completed OK #"+i, false, "pasquale.pagano", "Pasquale Pagano", "thumburl");
assertTrue(store.saveUserFeed(feed)); // } else {
try { // not = new Notification(UUID.randomUUID().toString(), NotificationType.JOB_COMPLETED_NOK,
Thread.sleep(150); // "massimiliano.assante", "MESSAGEID", new Date(), "uri", "This is notification about completed NOK #"+i, false, "leonardo.candela", "Leonardo Candela", "thumburl");
} catch (InterruptedException e) { // }
// TODO Auto-generated catch block // assertTrue(store.saveNotification(not));
e.printStackTrace(); // try {
} // Thread.sleep(150);
} // } catch (InterruptedException e) {
// // TODO Auto-generated catch block
Feed rFeed = null; // e.printStackTrace();
try { // }
rFeed = store.readFeed(feed.getKey().toString()); // }
rFeed = store.readFeed(feed.getKey().toString()); //
rFeed = store.readFeed(feed.getKey().toString()); // Notification rNot= null;
rFeed = store.readFeed(feed.getKey().toString()); // try {
assertNotNull(rFeed); //
// //read
String feedIdToDelete = UUID.randomUUID().toString(); // rNot = store.readNotification(not.getKey().toString());
feed = new Feed(feedIdToDelete, FeedType.PUBLISH, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE", // assertNotNull(rNot);
"www.d4science.org/monitor", "thumbUri", "This is feed to be deleted", PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false); // System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType());
assertTrue(store.saveUserFeed(feed)); //
try { // //set Read
Thread.sleep(250); // assertTrue(store.setNotificationRead(rNot.getKey().toString()));
} catch (InterruptedException e) { //
// TODO Auto-generated catch block // System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ");
e.printStackTrace(); //
} // not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE,
System.out.println("Test Delete Feed "); // "leonardo.candela", "FEEDID", new Date(), "uri", "This is notification of a Liked Leo feed by Massi", false, "massimiliano.assante", "Massimiliano Assante", "thumburl");
assertTrue(store.deleteFeed(feedIdToDelete)); // assertTrue(store.saveNotification(not));
// try {
System.out.println("massimiliano.assante ALL FEEDS: "); // Thread.sleep(150);
for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante")) // } catch (InterruptedException e) {
System.out.println(recFeed); // // TODO Auto-generated catch block
} // e.printStackTrace();
catch (Exception e) { // }
e.printStackTrace(); // rNot = store.readNotification(not.getKey().toString());
} // System.out.println("Reading another Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " Read:? " + rNot.isRead());
} // // //set Read
// // assertTrue(store.setNotificationRead(rNot.getKey().toString()));
// // System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ subject was this: " + rNot.getSubjectid());
// //
@Test // Random randomGenerator = new Random();
public void testComments() { //
int count = 10; // System.out.println("leonardo.candela Notifications: ");
Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE", // List<Notification> recentNots = store.getAllNotificationByUser("leonardo.candela", randomGenerator.nextInt(50));
"http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante", // assertNotNull(recentNots);
"massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false); // for (Notification notif :recentNots)
assertTrue(store.saveUserFeed(feed)); // System.out.println(notif);
//
Comment toDelete = null; //
for (int i = 0; i < count; i++) { // System.out.println("massimiliano.assante Notifications: ");
try { // recentNots = store.getUnreadNotificationsByUser("massimiliano.assante");
toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela", // assertNotNull(recentNots);
new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl"); // for (Notification notif :recentNots)
assertTrue(store.addComment(toDelete)); // System.out.println(notif);
// } catch (Exception e) {
} catch (FeedIDNotFoundException e) { // e.printStackTrace();
System.out.println("Exception feed id not found"); // }
} //
} // System.out.println("getRangeNotificationsByUser massimiliano.assante: ");
System.out.println("GetAllCOmmentsByFeed "); // try {
for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) { // int from = 0;
System.out.println(cm.getText()); // for (int i = 0; i < 5; i++) {
}; // System.out.println("\nFROM="+from);
// List<Notification> range = store.getRangeNotificationsByUser("massimiliano.assante", from, 50);
try { // for (Notification notification : range) {
assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid())); // System.out.println(notification.getDescription());
} catch (Exception e) { // from = 1+i * 50;
System.out.println("Exception feed id not found"); // }
} // }
} // } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
//
// @Test
// public void testFeeds() {
// int count = 18;
// Feed feed = null;
// for (int i = 0; i < count; i++) {
// if (i % 2 != 0) {
// feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
// } else {
// feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "",
// "www.d4science.org/web/guest", "thumbUri", "This is feed# "+ i, PrivacyLevel.PORTAL, "Leonardo Candela", "leonardo.candela@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
// }
// assertTrue(store.saveUserFeed(feed));
// try {
// Thread.sleep(150);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// Feed rFeed = null;
// try {
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// rFeed = store.readFeed(feed.getKey().toString());
// assertNotNull(rFeed);
//
// String feedIdToDelete = UUID.randomUUID().toString();
// feed = new Feed(feedIdToDelete, FeedType.PUBLISH, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "www.d4science.org/monitor", "thumbUri", "This is feed to be deleted", PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
// assertTrue(store.saveUserFeed(feed));
// try {
// Thread.sleep(250);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// System.out.println("Test Delete Feed ");
// assertTrue(store.deleteFeed(feedIdToDelete));
//
// System.out.println("massimiliano.assante ALL FEEDS: ");
// for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante"))
// System.out.println(recFeed);
// }
// catch (Exception e) {
// e.printStackTrace();
// }
// }
//
//
//
// @Test
// public void testComments() {
// int count = 10;
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
// "http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante",
// "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
// assertTrue(store.saveUserFeed(feed));
//
// Comment toDelete = null;
// for (int i = 0; i < count; i++) {
// try {
// toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela",
// new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl");
// assertTrue(store.addComment(toDelete));
//
// } catch (FeedIDNotFoundException e) {
// System.out.println("Exception feed id not found");
// }
// }
// System.out.println("GetAllCOmmentsByFeed ");
// for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) {
// System.out.println(cm.getText());
// };
//
// try {
// assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid()));
// } catch (Exception e) {
// System.out.println("Exception feed id not found");
// }
// }
} }