From 8948fecade6f82e3853868e6edadbf343c04968f Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Sat, 26 Nov 2016 04:35:28 +0700 Subject: messages controller improvenments; test corrected --- .../src/test/java/com/juick/api/tests/MessagesTests.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'juick-api/src/test/java/com/juick/api/tests/MessagesTests.java') 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 1dec4b7c..fd233a03 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 @@ -6,6 +6,7 @@ import com.juick.User; import com.juick.api.configuration.ApiAppConfiguration; import com.juick.api.configuration.ApiMvcConfiguration; import com.juick.api.configuration.ApiSecurityConfig; +import com.juick.configuration.DataConfiguration; import com.juick.service.MessagesService; import com.juick.service.UserService; import org.junit.Before; @@ -43,7 +44,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @WebAppConfiguration public class MessagesTests { @Configuration - @Import(value={ApiMvcConfiguration.class, ApiAppConfiguration.class, ApiSecurityConfig.class}) + @Import(value={ApiMvcConfiguration.class, ApiAppConfiguration.class, ApiSecurityConfig.class, DataConfiguration.class}) static class Config { @Bean @Primary @@ -59,12 +60,12 @@ public class MessagesTests { private MockMvc mockMvc; @Inject - WebApplicationContext webApplicationContext; + private WebApplicationContext webApplicationContext; @Inject - MessagesService messagesService; + private MessagesService messagesService; @Inject - UserService userService; + private UserService userService; @Before public void setUp() { @@ -86,8 +87,9 @@ public class MessagesTests { msg.setTags(Collections.singletonList(new Tag("yo"))); mockMvc.perform(get("/home")) .andExpect(status().is4xxClientError()); - when(userService.getUIDByHttpAuth(null)) - .thenReturn(1); + + when(userService.getUserByName(null)) + .thenReturn(user); when(messagesService.getMyFeed(1, 0)) .thenReturn(Collections.singletonList(1)); -- cgit v1.2.3