diff options
Diffstat (limited to 'src/test/java/com/juick/tests/ApiTests.java')
-rw-r--r-- | src/test/java/com/juick/tests/ApiTests.java | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java index 02180888..b80b9eb9 100644 --- a/src/test/java/com/juick/tests/ApiTests.java +++ b/src/test/java/com/juick/tests/ApiTests.java @@ -59,7 +59,7 @@ public class ApiTests { public void messageTests() { int user_id = UserQueries.createUser(jdbc, "mmmme", "secret"); User user = UserQueries.getUserByUID(jdbc, user_id).orElse(new User()); - assertEquals("it should be me", "mmmme", user.getUName()); + assertEquals("it should be me", "mmmme", user.getName()); int mid = MessagesQueries.createMessage(jdbc, user_id, "yo", null, new ArrayList<>()); Message msg = MessagesQueries.getMessage(jdbc, mid); assertEquals("yo", msg.getText()); @@ -67,27 +67,27 @@ public class ApiTests { calendar.setTime(msg.getDate()); assertEquals(2016, calendar.get(Calendar.YEAR)); User me = msg.getUser(); - assertEquals("mmmme", me.getUName()); - assertEquals("mmmme", MessagesQueries.getMessageAuthor(jdbc, mid).getUName()); + assertEquals("mmmme", me.getName()); + assertEquals("mmmme", MessagesQueries.getMessageAuthor(jdbc, mid).getName()); int tagID = TagQueries.createTag(jdbc, "weather"); Tag tag = TagQueries.getTag(jdbc, tagID); List<Tag> tagList = new ArrayList<>(); tagList.add(tag); int mid2 = MessagesQueries.createMessage(jdbc, user_id, "yo2", null, tagList); Message msg2 = MessagesQueries.getMessage(jdbc, mid2); - assertEquals(1, msg2.Tags.size()); + assertEquals(1, msg2.getTags().size()); assertEquals("we already have ugnich", -1, UserQueries.createUser(jdbc, "ugnich", "x")); int ugnich_id = UserQueries.createUser(jdbc, "hugnich", "x"); User ugnich = UserQueries.getUserByUID(jdbc, ugnich_id).orElse(new User()); - int rid = MessagesQueries.createReply(jdbc, msg2.getMID(), 0, ugnich.getUID(), "bla-bla", null); + int rid = MessagesQueries.createReply(jdbc, msg2.getMid(), 0, ugnich.getUid(), "bla-bla", null); assertEquals(1, rid); Message msg3 = MessagesQueries.getMessage(jdbc, mid2); assertEquals(1, msg3.Replies); - assertEquals("weather", msg3.Tags.get(0).getName()); - assertEquals(ugnich.getUID(), UserQueries.checkPassword(jdbc, ugnich.getUName(), "x")); - assertEquals(-1, UserQueries.checkPassword(jdbc, ugnich.getUName(), "xy")); - SubscriptionsQueries.subscribeMessage(jdbc, msg.getMID(), ugnich.getUID()); - assertEquals(1, SubscriptionsQueries.getUsersSubscribedToComments(jdbc, msg.getMID(), user.getUID()).size()); + assertEquals("weather", msg3.getTags().get(0).getName()); + assertEquals(ugnich.getUid(), UserQueries.checkPassword(jdbc, ugnich.getName(), "x")); + assertEquals(-1, UserQueries.checkPassword(jdbc, ugnich.getName(), "xy")); + SubscriptionsQueries.subscribeMessage(jdbc, msg.getMid(), ugnich.getUid()); + assertEquals(1, SubscriptionsQueries.getUsersSubscribedToComments(jdbc, msg.getMid(), user.getUid()).size()); MessagesQueries.deleteMessage(jdbc, user_id, mid); MessagesQueries.deleteMessage(jdbc, user_id, mid2); String htmlTagName = ">_<"; @@ -110,7 +110,7 @@ public class ApiTests { String expectedMessage = "New message posted"; assertEquals("should be message", true, protocol.getReply(user, "*yo yoyo").getDescription().startsWith(expectedMessage)); - int mid = MessagesQueries.getUserBlog(jdbc, user.getUID(), -1, 0).stream().reduce((first, second) -> second).get(); + int mid = MessagesQueries.getUserBlog(jdbc, user.getUid(), -1, 0).stream().reduce((first, second) -> second).get(); assertEquals("text should match", "yoyo", MessagesQueries.getMessage(jdbc, mid).getText()); assertEquals("tag should match", "yo", @@ -124,7 +124,7 @@ public class ApiTests { assertEquals("number of subscribed users should match", 1, SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, uid).size()); assertEquals("should be subscribed", "Subscribed", - protocol.getReply(readerUser, "S @" + user.getUName()).getDescription()); + protocol.getReply(readerUser, "S @" + user.getName()).getDescription()); List<User> friends = UserQueries.getUserFriends(jdbc, readerUid); assertEquals("number of friend users should match", 2, friends.size()); @@ -138,9 +138,9 @@ public class ApiTests { protocol.getReply(user, "#" + mid + " yoyo").getDescription()); assertEquals("should be second reply", expectedSecondReply, protocol.getReply(user, "#" + mid + "/1 yoyo").getDescription()); - Message reply = MessagesQueries.getReplies(jdbc, mid).stream().filter(m -> m.getRID() == 2).findFirst() + Message reply = MessagesQueries.getReplies(jdbc, mid).stream().filter(m -> m.getRid() == 2).findFirst() .orElse(new Message()); - assertEquals("should be reply to first comment", 1, reply.ReplyTo); + assertEquals("should be reply to first comment", 1, reply.getReplyto()); String jsonReply = protocol.getReply(user, "#" + mid).getJson().orElse(""); JSONArray jsonMessages = new JSONArray(jsonReply); Message receivedMsg = json.deserialize(jsonMessages.getJSONObject(0)); @@ -176,8 +176,8 @@ public class ApiTests { String readerUserFeed = readerFeed.getJson().orElse(""); JSONArray readerUserFeedMessages = new JSONArray(readerUserFeed); assertEquals("messages count should match", 1, readerUserFeedMessages.length()); - assertEquals("should be unsubscribed", "Unsubscribed from @" + user.getUName(), - protocol.getReply(readerUser, "U @" + user.getUName()).getDescription()); + assertEquals("should be unsubscribed", "Unsubscribed from @" + user.getName(), + protocol.getReply(readerUser, "U @" + user.getName()).getDescription()); assertEquals("number of readers should match", 0, UserQueries.getUserReaders(jdbc, uid).size()); assertEquals("number of friends should match", 1, @@ -190,7 +190,7 @@ public class ApiTests { protocol.getReply(readerUser, "D #" + mid).getDescription()); assertEquals("should be deleted", String.format("Message %s deleted", mid), protocol.getReply(user, "D #" + mid).getDescription()); - assertEquals("should not have messages", 0, MessagesQueries.getAll(jdbc, user.getUID(), 0).size()); + assertEquals("should not have messages", 0, MessagesQueries.getAll(jdbc, user.getUid(), 0).size()); String allFeed = protocol.getReply(readerUser, "#").getJson().orElse(""); JSONArray allFeedMessages = new JSONArray(allFeed); assertEquals("messages count should match", 0, allFeedMessages.length()); |