Added support for unlike feature
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@94595 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
23c5f05db2
commit
a96221d129
1144
.gwt/.gwt-log
1144
.gwt/.gwt-log
File diff suppressed because it is too large
Load Diff
|
@ -21,8 +21,9 @@
|
||||||
<Changeset component="org.gcube.portal.social-networking-library.1-5-0" date="2014-03-05">
|
<Changeset component="org.gcube.portal.social-networking-library.1-5-0" date="2014-03-05">
|
||||||
<Change>Added support for post alert notifications</Change>
|
<Change>Added support for post alert notifications</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portal.social-networking-library.1-6-0" date="2014-04-02">
|
<Changeset component="org.gcube.portal.social-networking-library.1-6-0" date="2014-04-08">
|
||||||
<Change>Added support for feeed retrieval by range</Change>
|
<Change>Added support for feeed retrieval by range</Change>
|
||||||
<Change>Added support for notifications retrieval by range</Change>
|
<Change>Added support for notifications retrieval by range</Change>
|
||||||
|
<Change>Added support for unlike feature</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
</ReleaseNotes>
|
</ReleaseNotes>
|
||||||
|
|
|
@ -1286,7 +1286,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean unlike(String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException {
|
public boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException {
|
||||||
Feed toUpdate = readFeed(feedid);
|
Feed toUpdate = readFeed(feedid);
|
||||||
boolean updateLikeNoResult = false;
|
boolean updateLikeNoResult = false;
|
||||||
|
|
||||||
|
@ -1294,11 +1294,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
||||||
if (updateLikeNoResult) {
|
if (updateLikeNoResult) {
|
||||||
MutationBatch m = conn.getKeyspace().prepareMutationBatch();
|
MutationBatch m = conn.getKeyspace().prepareMutationBatch();
|
||||||
//delete the row from LikesCF
|
//delete the row from LikesCF
|
||||||
m.withRow(cf_Likes, likeid)
|
m.withRow(cf_Likes, likeid).delete();
|
||||||
.delete();
|
|
||||||
//delete the column from UserLikes
|
//delete the column from UserLikes
|
||||||
m.withRow(cf_UserLikedFeeds, likeid)
|
m.withRow(cf_UserLikedFeeds, userid).deleteColumn(likeid);
|
||||||
.deleteColumn(likeid);
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m.execute();
|
m.execute();
|
||||||
|
|
|
@ -39,254 +39,226 @@ public class DatabookCassandraTest {
|
||||||
System.out.println("End");
|
System.out.println("End");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 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
|
|
||||||
// public void testFriendships() {
|
|
||||||
// assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela"));
|
|
||||||
// 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 {
|
|
||||||
// for (Feed feed : store.getAllLikedFeedsByUser("luca.frosini", 10)) {
|
|
||||||
// System.out.println(feed);
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testSingleNotificationPreference() {
|
|
||||||
// try {
|
|
||||||
// for (NotificationChannelType channel : store.getUserNotificationChannels("massimiliano.assante", NotificationType.COMMENT)) {
|
|
||||||
// System.out.println(channel);
|
|
||||||
// }
|
|
||||||
// } catch (NotificationChannelTypeNotFoundException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// } catch (NotificationTypeNotFoundException e) {
|
|
||||||
// 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
|
|
||||||
// public void testSingleNotification() {
|
|
||||||
// Notification not = new Notification(
|
|
||||||
// UUID.randomUUID().toString(),
|
|
||||||
// NotificationType.LIKE,
|
|
||||||
// "leonardo.candela",
|
|
||||||
// "MESSAGEID",
|
|
||||||
// new Date(),
|
|
||||||
// "uri",
|
|
||||||
// "This is notification about a like",
|
|
||||||
// false,
|
|
||||||
// "leonardo.candela", "Leonardo Candela",
|
|
||||||
// "thumburl");
|
|
||||||
// assertTrue(store.saveNotification(not));
|
|
||||||
//
|
|
||||||
// not = new Notification(
|
|
||||||
// UUID.randomUUID().toString(),
|
|
||||||
// NotificationType.MESSAGE,
|
|
||||||
// "massimiliano.assante",
|
|
||||||
// "MESSAGEID",
|
|
||||||
// new Date(),
|
|
||||||
// "uri",
|
|
||||||
// "This is notification about a like",
|
|
||||||
// false,
|
|
||||||
// "antonio.gioia", "Antonio Gioia",
|
|
||||||
// "thumburl");
|
|
||||||
// assertTrue(store.saveNotification(not));
|
|
||||||
// System.out.println("Writing one Notification " + not);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testNotifications() {
|
|
||||||
// Notification not = null;
|
|
||||||
// System.out.println("Writing 18 Notifications");
|
|
||||||
// int count = 18;
|
|
||||||
// for (int i = 0; i < count; i++) {
|
|
||||||
// if (i % 2 != 0) {
|
|
||||||
// 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");
|
|
||||||
// } else {
|
|
||||||
// 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");
|
|
||||||
// }
|
|
||||||
// assertTrue(store.saveNotification(not));
|
|
||||||
// try {
|
|
||||||
// Thread.sleep(150);
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// // TODO Auto-generated catch block
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Notification rNot= null;
|
|
||||||
// try {
|
|
||||||
//
|
|
||||||
// //read
|
|
||||||
// rNot = store.readNotification(not.getKey().toString());
|
|
||||||
// assertNotNull(rNot);
|
|
||||||
// System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType());
|
|
||||||
//
|
|
||||||
// //set Read
|
|
||||||
// assertTrue(store.setNotificationRead(rNot.getKey().toString()));
|
|
||||||
//
|
|
||||||
// System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ");
|
|
||||||
//
|
|
||||||
// not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE,
|
|
||||||
// "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 {
|
|
||||||
// Thread.sleep(150);
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// // TODO Auto-generated catch block
|
|
||||||
// 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());
|
|
||||||
// //
|
|
||||||
// Random randomGenerator = new Random();
|
|
||||||
//
|
|
||||||
// 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);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// System.out.println("massimiliano.assante Notifications: ");
|
|
||||||
// recentNots = store.getUnreadNotificationsByUser("massimiliano.assante");
|
|
||||||
// assertNotNull(recentNots);
|
|
||||||
// for (Notification notif :recentNots)
|
|
||||||
// System.out.println(notif);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
@Test
|
@Test
|
||||||
public void testFeeds() {
|
public void testLikes() {
|
||||||
// int count = 18;
|
int count = 10;
|
||||||
// Feed feed = null;
|
Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||||
// for (int i = 0; i < count; i++) {
|
"http://www.d4science.org/monitor", "thumbUri", "This feed is Liked ", PrivacyLevel.PUBLIC,
|
||||||
// if (i % 2 != 0) {
|
"Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
|
||||||
// feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
assertTrue(store.saveUserFeed(feed));
|
||||||
// "www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
|
Like toUnlike = new Like(UUID.randomUUID().toString(),"massimiliano.assante",
|
||||||
// } else {
|
new Date(), feed.getKey().toString(), "Massi Pallino", "thumbUrl");
|
||||||
// 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);
|
|
||||||
//
|
|
||||||
// Random randomGenerator = new Random();
|
|
||||||
//
|
|
||||||
// System.out.println("leonardo.candela TIMELINE: ");
|
|
||||||
// List<Feed> recentFeeds = store.getRecentFeedsByUser("leonardo.candela", randomGenerator.nextInt(50));
|
|
||||||
// assertNotNull(recentFeeds);
|
|
||||||
// for (Feed recFeed :recentFeeds)
|
|
||||||
// System.out.println(recFeed);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//store.enableDeletedPosts();
|
assertTrue(store.like(toUnlike));
|
||||||
System.out.println("Notifications TIMELINE: ");
|
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: ");
|
||||||
|
for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) {
|
||||||
|
System.out.println(feedid);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) {
|
||||||
|
System.out.println(like);
|
||||||
|
}
|
||||||
|
System.out.println("massimiliano.assante trying unlike the following feed: " + toUnlike);
|
||||||
|
store.unlike("massimiliano.assante", toUnlike.getKey(), toUnlike.getFeedid());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Exception feed id not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
public void testFriendships() {
|
||||||
|
assertTrue(store.requestFriendship("massimiliano.assante", "leonardo.candela"));
|
||||||
|
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 {
|
||||||
|
for (Feed feed : store.getAllLikedFeedsByUser("luca.frosini", 10)) {
|
||||||
|
System.out.println(feed);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSingleNotificationPreference() {
|
||||||
|
try {
|
||||||
|
for (NotificationChannelType channel : store.getUserNotificationChannels("massimiliano.assante", NotificationType.COMMENT)) {
|
||||||
|
System.out.println(channel);
|
||||||
|
}
|
||||||
|
} catch (NotificationChannelTypeNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NotificationTypeNotFoundException e) {
|
||||||
|
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
|
||||||
|
public void testSingleNotification() {
|
||||||
|
Notification not = new Notification(
|
||||||
|
UUID.randomUUID().toString(),
|
||||||
|
NotificationType.LIKE,
|
||||||
|
"leonardo.candela",
|
||||||
|
"MESSAGEID",
|
||||||
|
new Date(),
|
||||||
|
"uri",
|
||||||
|
"This is notification about a like",
|
||||||
|
false,
|
||||||
|
"leonardo.candela", "Leonardo Candela",
|
||||||
|
"thumburl");
|
||||||
|
assertTrue(store.saveNotification(not));
|
||||||
|
|
||||||
|
not = new Notification(
|
||||||
|
UUID.randomUUID().toString(),
|
||||||
|
NotificationType.MESSAGE,
|
||||||
|
"massimiliano.assante",
|
||||||
|
"MESSAGEID",
|
||||||
|
new Date(),
|
||||||
|
"uri",
|
||||||
|
"This is notification about a like",
|
||||||
|
false,
|
||||||
|
"antonio.gioia", "Antonio Gioia",
|
||||||
|
"thumburl");
|
||||||
|
assertTrue(store.saveNotification(not));
|
||||||
|
System.out.println("Writing one Notification " + not);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNotifications() {
|
||||||
|
Notification not = null;
|
||||||
|
System.out.println("Writing 18 Notifications");
|
||||||
|
int count = 18;
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
if (i % 2 != 0) {
|
||||||
|
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");
|
||||||
|
} else {
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
assertTrue(store.saveNotification(not));
|
||||||
|
try {
|
||||||
|
Thread.sleep(150);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification rNot= null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
//read
|
||||||
|
rNot = store.readNotification(not.getKey().toString());
|
||||||
|
assertNotNull(rNot);
|
||||||
|
System.out.println("Reading one Notification " + rNot.getKey() + ": " + rNot.getDescription() + " Type: " + rNot.getType());
|
||||||
|
|
||||||
|
//set Read
|
||||||
|
assertTrue(store.setNotificationRead(rNot.getKey().toString()));
|
||||||
|
|
||||||
|
System.out.println("Notification " + rNot.getKey() + " of Type: " + rNot.getType() + " was set to READ");
|
||||||
|
|
||||||
|
not = new Notification(UUID.randomUUID().toString(), NotificationType.LIKE,
|
||||||
|
"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 {
|
||||||
|
Thread.sleep(150);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
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());
|
||||||
|
//
|
||||||
|
Random randomGenerator = new Random();
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("massimiliano.assante Notifications: ");
|
||||||
|
recentNots = store.getUnreadNotificationsByUser("massimiliano.assante");
|
||||||
|
assertNotNull(recentNots);
|
||||||
|
for (Notification notif :recentNots)
|
||||||
|
System.out.println(notif);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("getRangeNotificationsByUser massimiliano.assante: ");
|
||||||
|
try {
|
||||||
int from = 0;
|
int from = 0;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
System.out.println("\nFROM="+from);
|
System.out.println("\nFROM="+from);
|
||||||
|
@ -296,105 +268,95 @@ public class DatabookCassandraTest {
|
||||||
from = 1+i * 50;
|
from = 1+i * 50;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// int from = 1;
|
|
||||||
// for (int i = 0; i < 5; i++) {
|
|
||||||
// System.out.println("\nFROM="+from);
|
|
||||||
// RangeFeeds range = store.getRecentFeedsByVREAndRange("/gcube/devsec/TestVREFolder2", from, 5);
|
|
||||||
// List<Feed> recentFeeds = range.getFeeds();
|
|
||||||
// assertNotNull(recentFeeds);
|
|
||||||
// for (Feed recFeed :recentFeeds)
|
|
||||||
// System.out.println("->"+recFeed.getDescription());
|
|
||||||
// from = range.getLastReturnedFeedTimelineIndex()-1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("PORTAL TIMELINE: ");
|
|
||||||
// recentFeeds = store.getAllPortalPrivacyLevelFeeds();
|
|
||||||
// assertNotNull(recentFeeds);
|
|
||||||
// for (Feed recFeed :recentFeeds)
|
|
||||||
// System.out.println(recFeed);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// // @Test
|
|
||||||
// // public void testNotifications() {
|
@Test
|
||||||
// // int count = 10;
|
public void testFeeds() {
|
||||||
// // Notification notf = null;
|
int count = 18;
|
||||||
// // for (int i = 0; i < count; i++) {
|
Feed feed = null;
|
||||||
// // notf = new Notification(UUID.randomUUID().toString(), NotificationType.MESSAGE, "massimiliano.assante", new Date(), "http://urir.com", "Desc #"+i, "Gino Camillo", false);
|
for (int i = 0; i < count; i++) {
|
||||||
// // assertTrue(store.saveNotification(notf));
|
if (i % 2 != 0) {
|
||||||
// // }
|
feed = new Feed(UUID.randomUUID().toString(), FeedType.JOIN, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||||
// // try {
|
"www.d4science.org/monitor", "thumbUri", "This is feed# "+ i, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
|
||||||
// // assertNotNull(store.getAllNotificationByUser("massimiliano.assante"));
|
} else {
|
||||||
// // } catch (Exception e) {
|
feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "leonardo.candela", new Date(), "",
|
||||||
// // e.printStackTrace();
|
"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 {
|
||||||
// @Test
|
Thread.sleep(150);
|
||||||
// public void testComments() {
|
} catch (InterruptedException e) {
|
||||||
// int count = 10;
|
// TODO Auto-generated catch block
|
||||||
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
e.printStackTrace();
|
||||||
// "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));
|
|
||||||
//
|
Feed rFeed = null;
|
||||||
// Comment toDelete = null;
|
try {
|
||||||
// for (int i = 0; i < count; i++) {
|
rFeed = store.readFeed(feed.getKey().toString());
|
||||||
// try {
|
rFeed = store.readFeed(feed.getKey().toString());
|
||||||
// toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela",
|
rFeed = store.readFeed(feed.getKey().toString());
|
||||||
// new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl");
|
rFeed = store.readFeed(feed.getKey().toString());
|
||||||
// assertTrue(store.addComment(toDelete));
|
assertNotNull(rFeed);
|
||||||
//
|
|
||||||
// } catch (FeedIDNotFoundException e) {
|
String feedIdToDelete = UUID.randomUUID().toString();
|
||||||
// System.out.println("Exception feed id not found");
|
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));
|
||||||
// System.out.println("GetAllCOmmentsByFeed ");
|
try {
|
||||||
// for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) {
|
Thread.sleep(250);
|
||||||
// System.out.println(cm.getText());
|
} catch (InterruptedException e) {
|
||||||
// };
|
// TODO Auto-generated catch block
|
||||||
//
|
e.printStackTrace();
|
||||||
// try {
|
}
|
||||||
// assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid()));
|
System.out.println("Test Delete Feed ");
|
||||||
// } catch (Exception e) {
|
assertTrue(store.deleteFeed(feedIdToDelete));
|
||||||
// System.out.println("Exception feed id not found");
|
|
||||||
// }
|
System.out.println("massimiliano.assante ALL FEEDS: ");
|
||||||
// }
|
for (Feed recFeed : store.getAllFeedsByUser("massimiliano.assante"))
|
||||||
//
|
System.out.println(recFeed);
|
||||||
// @Test
|
}
|
||||||
// public void testLikes() {
|
catch (Exception e) {
|
||||||
// int count = 10;
|
e.printStackTrace();
|
||||||
// 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");
|
@Test
|
||||||
//
|
public void testComments() {
|
||||||
// try {
|
int count = 10;
|
||||||
// assertTrue(store.like(toUnlike));
|
Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.SHARE, "massimiliano.assante", new Date(), "/gcube/devsec/devVRE",
|
||||||
// for (int i = 0; i < count; i++)
|
"http://www.d4science.org/monitor", "thumbUri", "This is feed that is going to be commented ", PrivacyLevel.PUBLIC, "Massimiliano Assante",
|
||||||
// assertTrue(store.like(new Like(UUID.randomUUID().toString(),"massimiliano.assante",
|
"massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host", false);
|
||||||
// new Date(), feed.getKey().toString(), "Rino Pallino", "thumbUrl")));
|
assertTrue(store.saveUserFeed(feed));
|
||||||
//
|
|
||||||
// System.out.println("massimiliano.assante liked the following feeds: ");
|
Comment toDelete = null;
|
||||||
// for (String feedid : store.getAllLikedFeedIdsByUser("massimiliano.assante")) {
|
for (int i = 0; i < count; i++) {
|
||||||
// System.out.println(feedid);
|
try {
|
||||||
// }
|
toDelete = new Comment(UUID.randomUUID().toString(),"leonardo.candela",
|
||||||
//
|
new Date(), feed.getKey().toString(), "This comment #"+i, "Leonardo Candela", "thumbUrl");
|
||||||
// for (Like like : store.getAllLikesByFeed(feed.getKey().toString())) {
|
assertTrue(store.addComment(toDelete));
|
||||||
// System.out.println(like);
|
|
||||||
// }
|
} catch (FeedIDNotFoundException e) {
|
||||||
//
|
System.out.println("Exception feed id not found");
|
||||||
// System.out.println("trying unlike");
|
}
|
||||||
// assertTrue(store.unlike(toUnlike.getKey(), toUnlike.getFeedid()));
|
}
|
||||||
//
|
System.out.println("GetAllCOmmentsByFeed ");
|
||||||
// } catch (Exception e) {
|
for (Comment cm : store.getAllCommentByFeed(feed.getKey().toString())) {
|
||||||
// System.out.println("Exception feed id not found");
|
System.out.println(cm.getText());
|
||||||
// }
|
};
|
||||||
// }
|
|
||||||
|
try {
|
||||||
|
assertTrue(store.deleteComment(toDelete.getKey(), toDelete.getFeedid()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Exception feed id not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,11 +290,12 @@ public interface DatabookStore {
|
||||||
boolean like(Like like) throws FeedIDNotFoundException;
|
boolean like(Like like) throws FeedIDNotFoundException;
|
||||||
/**
|
/**
|
||||||
* unlike a feed
|
* unlike a feed
|
||||||
|
* @param userid user identifier
|
||||||
* @param likeid the like identifier to delete
|
* @param likeid the like identifier to delete
|
||||||
* @param feedid the feedid to shich the comment is associated
|
* @param feedid the feedid to shich the comment is associated
|
||||||
* @return true if success, false otherwise
|
* @return true if success, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean unlike(String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
|
boolean unlike(String userid, String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
|
||||||
/**
|
/**
|
||||||
* @param userid user identifier
|
* @param userid user identifier
|
||||||
* return all the feedids a user has liked
|
* return all the feedids a user has liked
|
||||||
|
|
Loading…
Reference in New Issue