aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick/tests/ApiTests.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-03-02 17:57:00 +0300
committerGravatar Vitaly Takmazov2017-03-02 17:57:00 +0300
commit4ad9878d536588833838afc3ada1e4e3e19c26f9 (patch)
tree44f1e1174350895c3e02e531999fe3931b678a78 /src/test/java/com/juick/tests/ApiTests.java
parentc2f4735877781313ef0d0960ac3c0403944a495c (diff)
juick-server: protocol cleanup
Diffstat (limited to 'src/test/java/com/juick/tests/ApiTests.java')
-rw-r--r--src/test/java/com/juick/tests/ApiTests.java39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java
index 2d09d463..529abd6c 100644
--- a/src/test/java/com/juick/tests/ApiTests.java
+++ b/src/test/java/com/juick/tests/ApiTests.java
@@ -9,7 +9,6 @@ import com.juick.User;
import com.juick.server.helpers.TagStats;
import com.juick.server.protocol.JuickProtocol;
import com.juick.server.protocol.ProtocolListener;
-import com.juick.server.protocol.ProtocolReply;
import com.juick.service.MessagesService;
import com.juick.service.SubscriptionService;
import com.juick.service.TagService;
@@ -198,22 +197,22 @@ public class ApiTests {
User user = userService.getUserByUID(uid).orElse(new User());
String expectedMessage = "New message posted";
assertEquals("should be message", true,
- juickProtocol.getReply(user, "*yo yoyo").getResult().startsWith(expectedMessage));
+ juickProtocol.getReply(user, "*yo yoyo").startsWith(expectedMessage));
int mid = messagesService.getUserBlog(user.getUid(), -1, 0).stream().reduce((first, second) -> second).get();
assertEquals("text should match", "yoyo",
messagesService.getMessage(mid).getText());
assertEquals("tag should match", "yo",
tagService.getMessageTags(mid).get(0).getTag().getName());
- assertNotEquals("should not be error", "Error", juickProtocol.getReply(user, "#" + mid).getResult());
- assertEquals("should be PONG", "PONG", juickProtocol.getReply(user, " ping \n ").getResult());
+ assertNotEquals("should not be error", "Error", juickProtocol.getReply(user, "#" + mid));
+ assertEquals("should be PONG", "PONG", juickProtocol.getReply(user, "ping"));
int readerUid = userService.createUser("dummyReader", "dummySecret");
User readerUser = userService.getUserByUID(readerUid).orElse(new User());
assertEquals("should be subscribed", "Subscribed",
- juickProtocol.getReply(readerUser, "S #" + mid).getResult());
+ juickProtocol.getReply(readerUser, "S #" + mid));
assertEquals("number of subscribed users should match", 1,
subscriptionService.getUsersSubscribedToComments(mid, uid).size());
assertEquals("should be subscribed", "Subscribed",
- juickProtocol.getReply(readerUser, "S @" + user.getName()).getResult());
+ juickProtocol.getReply(readerUser, "S @" + user.getName()));
List<User> friends = userService.getUserFriends(readerUid);
assertEquals("number of friend users should match", 2,
friends.size());
@@ -224,54 +223,54 @@ public class ApiTests {
String expectedSecondReply = "Reply posted.\n#" + mid + "/2 "
+ juickProtocol.getBaseUri() + mid + "#2";
assertEquals("should be reply", expectedReply,
- juickProtocol.getReply(user, "#" + mid + " yoyo").getResult());
+ juickProtocol.getReply(user, "#" + mid + " yoyo"));
assertEquals("should be second reply", expectedSecondReply,
- juickProtocol.getReply(user, "#" + mid + "/1 yoyo").getResult());
+ juickProtocol.getReply(user, "#" + mid + "/1 yoyo"));
Message reply = messagesService.getReplies(mid).stream().filter(m -> m.getRid() == 2).findFirst()
.orElse(new Message());
assertEquals("should be reply to first comment", 1, reply.getReplyto());
assertNotEquals("tags should NOT be updated", "Tags are updated",
- juickProtocol.getReply(readerUser, "#" + mid + " *yo *there").getResult());
+ juickProtocol.getReply(readerUser, "#" + mid + " *yo *there"));
assertEquals("tags should be updated", "Tags are updated",
- juickProtocol.getReply(user, "#" + mid + " *there").getResult());
+ juickProtocol.getReply(user, "#" + mid + " *there"));
assertEquals("number of tags should match", 2,
tagService.getMessageTags(mid).size());
assertEquals("should be blacklisted", "Tag added to your blacklist",
- juickProtocol.getReply(readerUser, "BL *there").getResult());
+ juickProtocol.getReply(readerUser, "BL *there"));
assertEquals("number of subscribed users should match", 0,
subscriptionService.getSubscribedUsers(uid, mid).size());
assertEquals("tags should be updated", "Tags are updated",
- juickProtocol.getReply(user, "#" + mid + " *there").getResult());
+ juickProtocol.getReply(user, "#" + mid + " *there"));
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",
- juickProtocol.getReply(taggerUser, "S *yo").getResult());
+ juickProtocol.getReply(taggerUser, "S *yo"));
assertEquals("number of subscribed users should match", 2,
subscriptionService.getSubscribedUsers(uid, mid).size());
assertEquals("should be unsubscribed", "Unsubscribed from yo",
- juickProtocol.getReply(taggerUser, "U *yo").getResult());
+ juickProtocol.getReply(taggerUser, "U *yo"));
assertEquals("number of subscribed users should match", 1,
subscriptionService.getSubscribedUsers(uid, mid).size());
assertEquals("number of readers should match", 1,
userService.getUserReaders(uid).size());
- ProtocolReply readerFeed = juickProtocol.getReply(readerUser, "#");
- assertEquals("description should match", true, readerFeed.getResult().startsWith("Your feed"));
+ String readerFeed = juickProtocol.getReply(readerUser, "#");
+ assertEquals("description should match", true, readerFeed.startsWith("Your feed"));
assertEquals("should be unsubscribed", "Unsubscribed from @" + user.getName(),
- juickProtocol.getReply(readerUser, "U @" + user.getName()).getResult());
+ juickProtocol.getReply(readerUser, "U @" + user.getName()));
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,
- juickProtocol.getReply(readerUser, "u #" + mid).getResult());
+ juickProtocol.getReply(readerUser, "u #" + mid));
assertEquals("number of subscribed users should match", 0,
subscriptionService.getUsersSubscribedToComments(mid, uid).size());
assertNotEquals("should NOT be deleted", String.format("Message %s deleted", mid),
- juickProtocol.getReply(readerUser, "D #" + mid).getResult());
+ juickProtocol.getReply(readerUser, "D #" + mid));
assertEquals("should be deleted", String.format("Message %s deleted", mid),
- juickProtocol.getReply(user, "D #" + mid).getResult());
+ juickProtocol.getReply(user, "D #" + mid));
assertEquals("should not have messages", 0, messagesService.getAll(user.getUid(), 0).size());
}