From f9e9dc9daf7393fe5753e24bff051760981552e6 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 28 Nov 2016 13:17:55 +0300 Subject: juick-api: red test for anonymous apis --- .../test/java/com/juick/api/tests/MessagesTests.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java b/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java index cec2bc7d..66cd6048 100644 --- a/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java +++ b/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java @@ -229,4 +229,24 @@ public class MessagesTests { .andExpect(header().string("Access-Control-Allow-Methods", "POST,GET,PUT,OPTIONS,DELETE")) .andExpect(header().string("Access-Control-Allow-Headers", "X-PINGOTHER, Content-Type")); } + @Test + public void anonymousApis() throws Exception { + String ugnichName = "ugnich"; + String uginchPassword = "MyPassw0rd!"; + String freefdName = "freefd"; + String freefdPassword = "MyPassw0rd!"; + User ugnich = getUser(1, ugnichName, uginchPassword); + User freefd = getUser(2, freefdName, freefdPassword); + when(userService.getFullyUserByName(ugnichName)) + .thenReturn(ugnich); + when(userService.getFullyUserByName(freefdName)) + .thenReturn(freefd); + mockMvc.perform(get("/messages")) + .andExpect(status().isOk()); + mockMvc.perform(get("/users") + .param("uname", "ugnich").param("uname", "freefd")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(jsonPath("$", hasSize(2))); + } } -- cgit v1.2.3