From f6eb11a23ab645b187c5911ec762a3d6ca58140c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 28 Mar 2018 22:28:33 +0300 Subject: move like API to server --- .../src/test/java/com/juick/server/tests/ServerTests.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'juick-server/src/test/java/com/juick/server/tests/ServerTests.java') 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 52504f4a..c9556a98 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 @@ -41,7 +41,6 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.http.MediaType; import org.springframework.jdbc.core.JdbcTemplate; @@ -465,7 +464,7 @@ public class ServerTests { .param("mid", "1").param("uid", String.valueOf(ugnich.getUid()))).andExpect(status().isUnauthorized()); } @Test - public void topTest() throws Exception { + public void topTest() { int topmid = messagesService.createMessage(ugnich.getUid(), "top message", null, null); IntStream.rangeClosed(6, 12).forEach(i -> { messagesService.createReply(topmid, 0, i, "yo", null); @@ -654,4 +653,15 @@ public class ServerTests { Assert.assertThat(count, equalTo(0L)); mockMvc.perform(get("/ws/_all")).andExpect(status().isBadRequest()); } + + @Test + public void likesTests() throws Exception { + int mid = messagesService.createMessage(ugnich.getUid(), "to be liked", null, null); + String freefdHash = userService.getHashByUID(freefd.getUid()); + int freefdMid = messagesService.createMessage(freefd.getUid(), "to be not liked", null, null); + mockMvc.perform(post("/like?mid=" + mid + "&hash=" + freefdHash)) + .andExpect(status().isOk()); + mockMvc.perform(post("/like?mid=" + freefdMid + "&hash=" + freefdHash)) + .andExpect(status().isForbidden()); + } } -- cgit v1.2.3