aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/test/java/com')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java42
1 files changed, 22 insertions, 20 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 2930d61b..4dba2523 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
@@ -540,13 +540,15 @@ public class ServerTests {
}
@Test
public void botCommandsTests() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
- assertThat(commandsManager.processCommand(new User(), Jid.of("test@localhost"), "PING", null).get().getText(), is("PONG"));
+ URI emptyUri = URI.create(StringUtils.EMPTY);
+ assertThat(commandsManager.processCommand(new User(), Jid.of("test@localhost"), "PING", emptyUri).get().getText(), is("PONG"));
// subscription commands have two lines, others have 1
- assertThat(commandsManager.processCommand(new User(), Jid.of("test@localhost"), "help", null).get().getText().split("\n").length, is(32));
+ assertThat(commandsManager.processCommand(new User(), Jid.of("test@localhost"), "help", emptyUri).get().getText().split("\n").length, is(32));
}
@Test
public void protocolTests() throws Exception {
+ URI emptyUri = URI.create(StringUtils.EMPTY);
int uid = userService.createUser("me", "secret");
User user = userService.getUserByUID(uid).orElse(new User());
Tag yo = tagService.getTag("yo", true);
@@ -556,7 +558,7 @@ public class ServerTests {
assertThat(msgreply.getAttachmentType(), equalTo("png"));
int mid = messagesService.createMessage(uid, "yoyo", null, Collections.singletonList(yo));
assertEquals("should be message", true,
- commandsManager.processCommand(user, Jid.of("test@localhost"), String.format("#%d", mid), null).get().getText().startsWith("@me"));
+ commandsManager.processCommand(user, Jid.of("test@localhost"), String.format("#%d", mid), emptyUri).get().getText().startsWith("@me"));
assertEquals("text should match", "yoyo",
messagesService.getMessage(mid).getText());
assertEquals("tag should match", "yo",
@@ -565,9 +567,9 @@ public class ServerTests {
User readerUser = userService.getUserByUID(readerUid).orElse(new User());
Jid dummyJid = Jid.of("dummy@localhost");
assertEquals("should be subscribed", "Subscribed",
- commandsManager.processCommand(readerUser, dummyJid, "S #" + mid, null).get().getText());
+ commandsManager.processCommand(readerUser, dummyJid, "S #" + mid, emptyUri).get().getText());
assertEquals("should be favorited", "Message is added to your recommendations",
- commandsManager.processCommand(readerUser, dummyJid, "! #" + mid, null).get().getText());
+ commandsManager.processCommand(readerUser, dummyJid, "! #" + mid, emptyUri).get().getText());
int rid = messagesService.createReply(mid, 0, uid, "comment", null);
assertEquals("number of subscribed users should match", 1,
subscriptionService.getUsersSubscribedToComments(
@@ -579,7 +581,7 @@ public class ServerTests {
messagesService.getMessage(mid),
messagesService.getReply(mid, rid)).size());
assertEquals("should be subscribed", "Subscribed to @" + user.getName(),
- commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "S @" + user.getName(), null).get().getText());
+ commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "S @" + user.getName(), emptyUri).get().getText());
List<User> friends = userService.getUserFriends(readerUid);
assertEquals("number of friend users should match", 2,
friends.size());
@@ -590,57 +592,57 @@ public class ServerTests {
String expectedThirdReply = "Reply posted.\n#" + mid + "/3 "
+ "https://juick.com/" + mid + "#3";
assertEquals("should be second reply", expectedSecondReply,
- commandsManager.processCommand(user, Jid.of("test@localhost"), "#" + mid + " yoyo", null).get().getText());
+ commandsManager.processCommand(user, Jid.of("test@localhost"), "#" + mid + " yoyo", emptyUri).get().getText());
assertEquals("should be third reply", expectedThirdReply,
- commandsManager.processCommand(user, Jid.of("test@localhost"), "#" + mid + "/2 yoyo", null).get().getText());
+ commandsManager.processCommand(user, Jid.of("test@localhost"), "#" + mid + "/2 yoyo", emptyUri).get().getText());
Message reply = messagesService.getReplies(mid).stream().filter(m -> m.getRid() == 3).findFirst()
.orElse(new Message());
assertEquals("should be reply to second comment", 2, reply.getReplyto());
assertEquals("tags should NOT be updated", "It is not your message",
- commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "#" + mid + " *yo *there", null).get().getText());
+ commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "#" + mid + " *yo *there", emptyUri).get().getText());
assertEquals("tags should be updated", "Tags are updated",
- commandsManager.processCommand(user, Jid.of("test@localhost"), "#" + mid + " *there", null).get().getText());
+ commandsManager.processCommand(user, Jid.of("test@localhost"), "#" + mid + " *there", emptyUri).get().getText());
assertEquals("number of tags should match", 2,
tagService.getMessageTags(mid).size());
assertEquals("should be blacklisted", "Tag added to your blacklist",
- commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "BL *there", null).get().getText());
+ commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "BL *there", emptyUri).get().getText());
assertEquals("number of subscribed users should match", 0,
subscriptionService.getSubscribedUsers(uid, mid).size());
assertEquals("tags should be updated", "Tags are updated",
- commandsManager.processCommand(user, Jid.of("test@localhost"), "#" + mid + " *there", null).get().getText());
+ commandsManager.processCommand(user, Jid.of("test@localhost"), "#" + mid + " *there", emptyUri).get().getText());
assertEquals("number of tags should match", 1,
tagService.getMessageTags(mid).size());
int taggerUid = userService.createUser("dummyTagger", "dummySecret");
User taggerUser = userService.getUserByUID(taggerUid).orElse(new User());
assertEquals("should be subscribed", "Subscribed",
- commandsManager.processCommand(taggerUser, Jid.of("tagger@localhost"), "S *yo", null).get().getText());
+ commandsManager.processCommand(taggerUser, Jid.of("tagger@localhost"), "S *yo", emptyUri).get().getText());
assertEquals("number of subscribed users should match", 2,
subscriptionService.getSubscribedUsers(uid, mid).size());
assertEquals("should be unsubscribed", "Unsubscribed from yo",
- commandsManager.processCommand(taggerUser, Jid.of("tagger@localhost"), "U *yo", null).get().getText());
+ commandsManager.processCommand(taggerUser, Jid.of("tagger@localhost"), "U *yo", emptyUri).get().getText());
assertEquals("number of subscribed users should match", 1,
subscriptionService.getSubscribedUsers(uid, mid).size());
assertEquals("number of readers should match", 1,
userService.getUserReaders(uid).size());
- String readerFeed = commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "#", null).get().getText();
+ String readerFeed = commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "#", emptyUri).get().getText();
assertEquals("description should match", true, readerFeed.startsWith("Your feed"));
assertEquals("should be unsubscribed", "Unsubscribed from @" + user.getName(),
- commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "U @" + user.getName(), null).get().getText());
+ commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "U @" + user.getName(), emptyUri).get().getText());
assertEquals("number of readers should match", 0,
userService.getUserReaders(uid).size());
assertEquals("number of friends should match", 1,
userService.getUserFriends(uid).size());
assertEquals("should be unsubscribed", "Unsubscribed from #" + mid,
- commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "u #" + mid, null).get().getText());
+ commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "u #" + mid, emptyUri).get().getText());
assertEquals("number of subscribed users should match", 0,
subscriptionService.getUsersSubscribedToComments(messagesService.getMessage(mid),
messagesService.getReply(mid, rid)).size());
assertNotEquals("should NOT be deleted", String.format("Message %s deleted", mid),
- commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "D #" + mid, null).get().getText());
+ commandsManager.processCommand(readerUser, Jid.of("dummy@localhost"), "D #" + mid, emptyUri).get().getText());
assertEquals("should be deleted", "Message deleted",
- commandsManager.processCommand(user, Jid.of("test@localhost"), "D #" + mid, null).get().getText());
+ commandsManager.processCommand(user, Jid.of("test@localhost"), "D #" + mid, emptyUri).get().getText());
assertEquals("should be not found", "Message not found",
- commandsManager.processCommand(user, Jid.of("test@localhost"), "#" + mid, null).get().getText());
+ commandsManager.processCommand(user, Jid.of("test@localhost"), "#" + mid, emptyUri).get().getText());
}
@Test
public void mailParserTest() throws Exception {