aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/test/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-09-29 16:39:37 +0300
committerGravatar Vitaly Takmazov2018-09-29 16:39:37 +0300
commit1621fb481fe91b084a48326419969f3a22ccbbe2 (patch)
treebe6aa4acd21ee5d8e7edf8cde95cffe64590ec0e /juick-server/src/test/java/com/juick
parent80f305e6f5d22abc38807fd6fad37b5cb450c249 (diff)
Mentions
Diffstat (limited to 'juick-server/src/test/java/com/juick')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java41
1 files changed, 33 insertions, 8 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 7e5acf1a..0f483acc 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
@@ -251,7 +251,8 @@ public class ServerTests {
Tag yoTag = tagService.getTag("yoyo", true);
assertThat(tagService.getTag("YOYO", false), equalTo(yoTag));
int mid = messagesService.createMessage(ugnich.getUid(), "yo", null, Collections.singletonList(yoTag));
- List<User> subscribers = subscriptionService.getSubscribedUsers(ugnich.getUid(), mid);
+ Message msg = messagesService.getMessage(mid);
+ List<User> subscribers = subscriptionService.getSubscribedUsers(ugnich.getUid(), msg);
telegramService.createTelegramUser(12345, "freefd");
String loginhash = jdbcTemplate.queryForObject("SELECT loginhash FROM telegram where tg_id=?",
@@ -263,13 +264,18 @@ public class ServerTests {
assertThat(subscribers.size(), equalTo(telegramSubscribers.size()));
assertThat(subscribers.get(0).getUid(), equalTo(freefd.getUid()));
tagService.blacklistTag(freefd, yoTag);
- List<User> subscribers2 = subscriptionService.getSubscribedUsers(ugnich.getUid(), mid);
+ List<User> subscribers2 = subscriptionService.getSubscribedUsers(ugnich.getUid(), msg);
assertThat(subscribers2.size(), equalTo(0));
assertThat(telegramService.getTelegramIdentifiers(subscribers2).size(), equalTo(0));
tagService.blacklistTag(freefd, yoTag);
- assertThat(subscriptionService.getSubscribedUsers(ugnich.getUid(), mid).size(), equalTo(1));
+ assertThat(subscriptionService.getSubscribedUsers(ugnich.getUid(), msg).size(), equalTo(1));
subscriptionService.unSubscribeUser(freefd, ugnich);
- assertThat(subscriptionService.getSubscribedUsers(ugnich.getUid(), mid).size(), equalTo(0));
+ assertThat(subscriptionService.getSubscribedUsers(ugnich.getUid(), msg).size(), equalTo(0));
+ Message mentionMessage = new Message();
+ mentionMessage.setText("@freefd - dick");
+ assertThat(subscriptionService.getSubscribedUsers(ugnich.getUid(), mentionMessage).size(), equalTo(1));
+ subscriptionService.subscribeUser(freefd, ugnich);
+ assertThat(subscriptionService.getSubscribedUsers(ugnich.getUid(), mentionMessage).size(), equalTo(1));
}
@Test
public void pmTests() {
@@ -725,7 +731,8 @@ public class ServerTests {
CommandResult yoyoMsg = commandsManager.processCommand(user, "*yo", URI.create("http://static.juick.com/settings/facebook.png"));
assertTrue(yoyoMsg.getNewMessage().isPresent());
assertThat(yoyoMsg.getNewMessage().get().getTags().get(0), is(yo));
- int mid = yoyoMsg.getNewMessage().get().getMid();
+ Message msg2 = yoyoMsg.getNewMessage().get();
+ int mid = msg2.getMid();
Timestamp last = jdbcTemplate.queryForObject("SELECT lastmessage FROM users WHERE id=?", Timestamp.class, user.getUid());
assertThat(last.toInstant(), equalTo(yoyoMsg.getNewMessage().get().getTimestamp()));
assertEquals("should be message", true,
@@ -785,7 +792,7 @@ public class ServerTests {
assertEquals("should be blacklisted", "Tag added to your blacklist",
commandsManager.processCommand(readerUser, "BL *there", emptyUri).getText());
assertEquals("number of subscribed users should match", 0,
- subscriptionService.getSubscribedUsers(uid, mid).size());
+ subscriptionService.getSubscribedUsers(uid, msg2).size());
assertEquals("tags should be updated", "Tags are updated",
commandsManager.processCommand(user, "#" + mid + " *there", emptyUri).getText());
assertEquals("number of tags should match", 1,
@@ -795,11 +802,11 @@ public class ServerTests {
assertEquals("should be subscribed", "Subscribed",
commandsManager.processCommand(taggerUser, "S *yo", emptyUri).getText());
assertEquals("number of subscribed users should match", 2,
- subscriptionService.getSubscribedUsers(uid, mid).size());
+ subscriptionService.getSubscribedUsers(uid, msg2).size());
assertEquals("should be unsubscribed", "Unsubscribed from yo",
commandsManager.processCommand(taggerUser, "U *yo", emptyUri).getText());
assertEquals("number of subscribed users should match", 1,
- subscriptionService.getSubscribedUsers(uid, mid).size());
+ subscriptionService.getSubscribedUsers(uid, msg2).size());
assertEquals("number of readers should match", 1,
userService.getUserReaders(uid).size());
String readerFeed = commandsManager.processCommand(readerUser, "#", emptyUri).getText();
@@ -1266,6 +1273,24 @@ public class ServerTests {
assertThat(subscribers.apply(recommenderId, messagesService.getMessage(readerMid)).size(), is(0));
}
@Test
+ public void mentionsInComments() {
+ int posterId = userService.createUser("p", "secret");
+ int commenterId = userService.createUser("cc", "secret");
+ User commenter = userService.getUserByUID(commenterId).get();
+ int mentionerId = userService.createUser("mmm", "secret");
+ User mentioner = userService.getUserByUID(mentionerId).get();
+ int mid = messagesService.createMessage(posterId, "who is dick?", null, null);
+ Message msg = messagesService.getMessage(mid);
+ int rid = messagesService.createReply(mid, 0, commenter,
+ "@mmm is dick", null);
+ Message reply = messagesService.getReply(mid, rid);
+ assertThat(subscriptionService.getUsersSubscribedToComments(msg, reply).size(), is(1));
+ subscriptionService.subscribeUser(mentioner, commenter);
+ assertThat(subscriptionService.getUsersSubscribedToComments(msg, reply).size(), is(1));
+ privacyQueriesService.blacklistUser(mentioner, commenter);
+ assertThat(subscriptionService.getUsersSubscribedToComments(msg, reply).size(), is(0));
+ }
+ @Test
public void xmppStatusApi() throws Exception {
Supplier<XMPPStatus> getStatus = () -> {
try {