diff options
author | Vitaly Takmazov | 2018-08-15 14:30:33 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-08-15 14:30:33 +0300 |
commit | e2750a57b9405522102fc6ad083e738f3f389249 (patch) | |
tree | d01d2678a93a2ea60a802b5bc14395adeb47e614 /juick-server/src/test/java | |
parent | f8963d4a127742552e8839c28ce54c38c48eb26d (diff) |
Fix recommendations delivery
Diffstat (limited to 'juick-server/src/test/java')
-rw-r--r-- | juick-server/src/test/java/com/juick/server/tests/ServerTests.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java index 2d28dc9d..646e1443 100644 --- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java @@ -1168,4 +1168,36 @@ public class ServerTests { assertThat(editedComment.getUpdatedAt(), greaterThan(editedComment.getTimestamp())); messagesService.deleteMessage(ugnich.getUid(), original.getMid()); } + @Test + public void subscribersToRecommendations() { + int readerId = userService.createUser("reader", "123456"); + int recommenderId = userService.createUser("recommender", "123456"); + int lateRecommenderId = userService.createUser("lateRecommender", "123456"); + int posterId = userService.createUser("poster", "123456"); + User reader = userService.getUserByName("reader"); + User recommender = userService.getUserByName("recommender"); + User lateRecommender = userService.getUserByName("lateRecommender"); + User poster = userService.getUserByName("poster"); + subscriptionService.subscribeUser(reader, recommender); + subscriptionService.subscribeUser(reader, lateRecommender); + Tag sampleTag = tagService.getTag("banned", true); + int posterMid = messagesService.createMessage(posterId, "YO", null, Collections.singletonList(sampleTag)); + messagesService.recommendMessage(posterMid, recommenderId); + BiFunction<Integer, Integer, List<User>> subscribers = (recommId, msgId) -> + subscriptionService.getUsersSubscribedToUserRecommendations(recommId, msgId, posterId); + List<User> recommendSubscribers = subscribers.apply(recommenderId, posterMid); + assertThat(recommendSubscribers.size(), is(1)); + assertThat(recommendSubscribers.get(0).getUid(), is(readerId)); + privacyQueriesService.blacklistUser(reader, poster); + assertThat(subscribers.apply(recommenderId, posterMid).size(), is(0)); + privacyQueriesService.blacklistUser(reader, poster); + assertThat(subscribers.apply(recommenderId, posterMid).size(), is(1)); + tagService.blacklistTag(reader, sampleTag); + assertThat(subscribers.apply(recommenderId, posterMid).size(), is(0)); + tagService.blacklistTag(reader, sampleTag); + assertThat(subscribers.apply(recommenderId, posterMid).size(), is(1)); + messagesService.recommendMessage(posterMid, lateRecommenderId); + List<User> lateRecommendSubscribers = subscribers.apply(recommenderId, posterMid); + assertThat(lateRecommendSubscribers.size(), is(0)); + } } |