Я использую spring-boot 2.1.7-RELEASE и использую org.springframework.test.web.servlet.Mock Mvc и org.springframework.web.context.WebApplicationContext в моем тестовом классе
Вот моя конечная точка
@RequestMapping(value = "/user/{userId}",produces = { "application/json" }, method = RequestMethod.GET)
public User getUser(@PathVariable("userId") UUID userId, @Valid @RequestParam(value = "filters", required = false) List<String> filters){
//some processing and return User;
}
Вот мой метод тестирования
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
this.mockMvc = MockMvcBuilders
.webAppContextSetup(context)
.apply(springSecurity())
.build();
}
@Test
public void getAccount()throws Exception {
mockMvc.perform(get("/user/1"))
.andDo(print())
.andExpect(status().isOk());
}
, и я получаю следующую ошибку
MockHttpServletRequest:
HTTP Method = GET
Request URI = /user/1
Parameters = {}
Headers = [Content-Type:"application/json;charset=UTF-8"]
Body = null
Session Attrs = {}
Handler:
Type = org.springframework.cloud.netflix.zuul.web.ZuulController
Async:
Async started = false
Async result = null
Resolved Exception:
Type = null
ModelAndView:
View name = null
View = null
Model = null
FlashMap:
Attributes = null
MockHttpServletResponse:
Status = 500
Error message = null
Headers = [X-Content-Type-Options:"nosniff", X-XSS-Protection:"1; mode=block", Cache-Control:"no-cache, no-store, max-age=0, must-revalidate", Pragma:"no-cache", Expires:"0", X-Frame-Options:"DENY"]
Content type = null
Body =
Forwarded URL = /error
Redirected URL = null
Cookies = []
java.lang.AssertionError: Status
Expected :200
Actual :500
Может кто-нибудь помочь мне понять почему я получаю эту ошибку?