diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 5bb10ae9..9ed4b727 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -360,6 +360,8 @@ public class ServerTests { private Users usersController; @Inject private User serviceUser; + @Inject + private User archiveUser; private static User ugnich, freefd; static String ugnichName, ugnichPassword, freefdName, freefdPassword; @@ -1401,16 +1403,21 @@ public class ServerTests { assertThat(editedComment.getText(), is("HEY, JOE")); assertThat(editedComment.getUpdatedAt(), greaterThan(editedComment.getCreated())); jdbcTemplate.update("UPDATE replies SET updated_at='1990-05-05 00:00:00' WHERE message_id=? AND reply_id=?", editedComment.getMid(), editedComment.getRid()); + Message updatedComment = comment.getNewMessage().get(); result = mockMvc .perform(post("/api/update").with(httpBasic(freefdName, freefdPassword)) - .param("mid", String.valueOf(comment.getNewMessage().get().getMid())) - .param("rid", String.valueOf(comment.getNewMessage().get().getRid())).param("body", "HEY, JOE AGAIN")) + .param("mid", String.valueOf(updatedComment.getMid())) + .param("rid", String.valueOf(updatedComment.getRid())).param("body", "HEY, JOE AGAIN")) .andExpect(status().isBadRequest()).andReturn(); + assertThat(messagesService.deleteReply(ugnich.getUid(), updatedComment.getMid(), updatedComment.getRid()), is(false)); + assertThat(messagesService.deleteReply(freefd.getUid(), updatedComment.getMid(), updatedComment.getRid()), is(true)); + assertThat(messagesService.getReply(updatedComment.getMid(), updatedComment.getRid()).getUser(), is(archiveUser)); jdbcTemplate.update("UPDATE messages_txt SET updated_at='1990-05-05 00:00:00' WHERE message_id=?", original.getMid()); - assertThat(messagesService.deleteMessage(ugnich.getUid(), original.getMid()), is(false)); - jdbcTemplate.update("UPDATE messages_txt SET updated_at=? WHERE message_id=?", Instant.now(), original.getMid()); assertThat(messagesService.deleteMessage(ugnich.getUid(), original.getMid()), is(true)); - + assertThat(messagesService.getMessageAuthor(original.getMid()), is(archiveUser)); + jdbcTemplate.update("UPDATE messages_txt SET updated_at=? WHERE message_id=?", Instant.now(), original.getMid()); + assertThat(messagesService.deleteMessage(ugnich.getUid(), original.getMid()), is(false)); + assertThat(messagesService.deleteMessage(archiveUser.getUid(), original.getMid()), is(true)); } @Test |