Я тестирую контроллер и столкнулся с проблемой, которую не могу решить. Не понимаю, зачем нужны идентификаторы и где их не хватает.
Вот мой контроллер
@GetMapping(value = "/ads/in/rubrics")
public List<Ad> findAllAdInRubricByIds(@RequestParam(value = "ids", required = true) List<Integer> ids) {
return adService.findAllAdInRubricByIds(ids);
}
метод тестирования
@Test
public void findAllAdInRubricByIds() throws Exception {
List<Ad> ads = new ArrayList<>();
ads.add(initAd());
Mockito.when(controller.findAllAdInRubricByIds(((ArgumentMatchers.anyList())))).thenReturn(ads);
mockMvc.perform(
get("/ad/ads/in/rubrics"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$[0].id").value(0));
}
Ошибка
MockHttpServletResponse:
Status = 400
Error message = Required List parameter 'ids' is not present
Headers = []
Content type = null
Body =
Forwarded URL = null
Redirected URL = null
Cookies = []
java.lang.AssertionError: Status
Expected :200
Actual :400