aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/test
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-21 15:18:54 +0300
committerGravatar Vitaly Takmazov2018-03-21 15:18:54 +0300
commit2fda6291ef2869d4f5f29afa92737d8f0f527a0e (patch)
tree1ed1551abe8ffbda033973ab1ad4079fadc97dd5 /juick-server/src/test
parent2c1ea441673d9d6370e2ea419f2d0f9a863cb0d3 (diff)
xmpp: restore full tests
Diffstat (limited to 'juick-server/src/test')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java42
1 files changed, 21 insertions, 21 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 1d76ca42..0aa1e3ca 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
@@ -66,6 +66,7 @@ import java.util.stream.IntStream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
@@ -371,7 +372,7 @@ public class ServerTests extends AbstractJUnit4SpringContextTests {
public void botCommandsTests() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "PING").get(), is("PONG"));
// subscription commands have two lines, others have 1
- assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "help").get().split("\n").length, is(29));
+ assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "help").get().split("\n").length, is(31));
}
@Test
@@ -389,12 +390,11 @@ public class ServerTests extends AbstractJUnit4SpringContextTests {
tagService.getMessageTags(mid).get(0).getTag().getName());
int readerUid = userService.createUser("dummyReader", "dummySecret");
User readerUser = userService.getUserByUID(readerUid).orElse(new User());
+ Jid dummyJid = Jid.of("dummy@localhost");
assertEquals("should be subscribed", "Subscribed",
- bot.processCommand(readerUser, Jid.of("dummy@localhost"), "S #" + mid).get());
- /* TODO: move from juick-legacy
- assertEquals("should be favorited", "Message added to your recommendations",
- juickProtocol.getReply(readerUser, "! #" + mid));
- */
+ bot.processCommand(readerUser, dummyJid, "S #" + mid).get());
+ assertEquals("should be favorited", "Message is added to your recommendations",
+ bot.processCommand(readerUser, dummyJid, "! #" + mid).get());
int rid = messagesService.createReply(mid, 0, uid, "comment", null);
assertEquals("number of subscribed users should match", 1,
subscriptionService.getUsersSubscribedToComments(
@@ -405,26 +405,25 @@ public class ServerTests extends AbstractJUnit4SpringContextTests {
subscriptionService.getUsersSubscribedToComments(
messagesService.getMessage(mid),
messagesService.getReply(mid, rid)).size());
- /*
- assertEquals("should be subscribed", "Subscribed",
+ assertEquals("should be subscribed", "Subscribed to @" + user.getName(),
bot.processCommand(readerUser, Jid.of("dummy@localhost"), "S @" + user.getName()).get());
List<User> friends = userService.getUserFriends(readerUid);
assertEquals("number of friend users should match", 2,
friends.size());
assertEquals("number of reader users should match", 1,
userService.getUserReaders(uid).size());
- String expectedReply = "Reply posted.\n#" + mid + "/1 "
- + "http://juick.com/" + mid + "#1";
String expectedSecondReply = "Reply posted.\n#" + mid + "/2 "
- + "http://juick.com/" + mid + "#2";
- assertEquals("should be reply", expectedReply,
- bot.processCommand(user, Jid.of("test@localhost"), "#" + mid + " yoyo").get());
+ + "https://juick.com/" + mid + "#2";
+ String expectedThirdReply = "Reply posted.\n#" + mid + "/3 "
+ + "https://juick.com/" + mid + "#3";
assertEquals("should be second reply", expectedSecondReply,
- bot.processCommand(user, Jid.of("test@localhost"), "#" + mid + "/1 yoyo").get());
- Message reply = messagesService.getReplies(mid).stream().filter(m -> m.getRid() == 2).findFirst()
+ bot.processCommand(user, Jid.of("test@localhost"), "#" + mid + " yoyo").get());
+ assertEquals("should be third reply", expectedThirdReply,
+ bot.processCommand(user, Jid.of("test@localhost"), "#" + mid + "/2 yoyo").get());
+ Message reply = messagesService.getReplies(mid).stream().filter(m -> m.getRid() == 3).findFirst()
.orElse(new Message());
- assertEquals("should be reply to first comment", 1, reply.getReplyto());
- assertNotEquals("tags should NOT be updated", "Tags are updated",
+ assertEquals("should be reply to second comment", 2, reply.getReplyto());
+ assertEquals("tags should NOT be updated", "It is not your message",
bot.processCommand(readerUser, Jid.of("dummy@localhost"), "#" + mid + " *yo *there").get());
assertEquals("tags should be updated", "Tags are updated",
bot.processCommand(user, Jid.of("test@localhost"), "#" + mid + " *there").get());
@@ -461,13 +460,14 @@ public class ServerTests extends AbstractJUnit4SpringContextTests {
assertEquals("should be unsubscribed", "Unsubscribed from #" + mid,
bot.processCommand(readerUser, Jid.of("dummy@localhost"), "u #" + mid).get());
assertEquals("number of subscribed users should match", 0,
- subscriptionService.getUsersSubscribedToComments(mid, uid).size());
+ subscriptionService.getUsersSubscribedToComments(messagesService.getMessage(mid),
+ messagesService.getReply(mid, rid)).size());
assertNotEquals("should NOT be deleted", String.format("Message %s deleted", mid),
bot.processCommand(readerUser, Jid.of("dummy@localhost"), "D #" + mid).get());
- assertEquals("should be deleted", String.format("Message %s deleted", mid),
+ assertEquals("should be deleted", "Message deleted",
bot.processCommand(user, Jid.of("test@localhost"), "D #" + mid).get());
- assertEquals("should not have messages", 0, messagesService.getAll(user.getUid(), 0).size());
- */
+ assertEquals("should be not found", "Message not found",
+ bot.processCommand(user, Jid.of("test@localhost"), "#" + mid).get());
}
@Test
public void mailParserTest() throws Exception {