UserListController { @GetMapping({"userlist", "users"}) @SuppressWarnings("AssignmentToMethodParameter") public String userList(HttpServletRequest request, @PageableDefault(50) Pageable pageable) { Sort sort = pageable.getSort(); int pageSize = Math.min(pageable.getPageSize(), 500); if (sort == null || !sort.iterator().hasNext()) { sort = DEFAULT_SORT; } pageable = PageRequest.of(pageable.getPageNumber(), pageSize, sort); String query = URIBuilder.fromRequest(request) .replaceQueryParam("page") .toString(); request.setAttribute("url", query); request.setAttribute("page", accountService.findAll(pageable)); return "users/list"; }  @GetMapping({"userlist", "users"}) @SuppressWarnings("AssignmentToMethodParameter") String userList(HttpServletRequest request, @PageableDefault(50) Pageable pageable);  }
@Test public void testUserList() throws Exception { log.info("userList"); MvcResult result = mvc.perform(get("/userlist")) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) .andReturn(); for (int i = 0; i < 105; i++) { mockDataService.user(); } result = mvc.perform(get("/userlist")) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) .andReturn(); for (int i = 0; i < 1000; i++) { mockDataService.user(); } for (int page : new int[]{ 0, 1, 2, 7, 8, 9, 18, 19 }) { result = mvc.perform(get("/userlist").param("page", Integer.toString(page))) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) .andReturn(); } }