@Test public void articles() { try { mockMvc.perform(MockMvcRequestBuilders.get("/articles")) .andExpect(status().is(200)); mockMvc.perform(MockMvcRequestBuilders.get("/articles?page=1&count=5")) .andExpect(status().is(200)) .andDo(result -> { JSONObject articlesJSON = JSONObject.fromObject(result.getResponse().getContentAsString()); Response response = (Response) JSONObject.toBean(articlesJSON, Response.class); assertEquals(SUCCESS.getCode(), response.getCode()); assertNotNull(response.getResult()); JSONObject resultJson = JSONObject.fromObject(response.getResult()); PageInfo pageInfo = (PageInfo) JSONObject.toBean(resultJson, PageInfo.class); assertNotEquals(0, pageInfo.getTotal()); assertNotEquals(0, pageInfo.getStartRow()); assertNotEquals(0, pageInfo.getEndRow()); assertEquals(1, pageInfo.getPageNum()); assertEquals(5, pageInfo.getPageSize()); for (Object arc : pageInfo.getList()) { ArticleModel a = (ArticleModel) JSONObject.toBean(JSONObject.fromObject(arc), ArticleModel.class); assertNotNull(a.getTitle()); assertNotNull(a.getId()); assertNotNull(a.getSummary()); assertNotNull(a.getOriginal()); assertNotNull(a.getPublishDateFormat()); assertNotNull(a.getCategory()); assertNotNull(a.getTags()); assertNotNull(a.getAuthorName()); } }); } catch (Exception e) { e.printStackTrace(); } }
@GetMapping("/articles") public Response articles(@RequestParam(name = "page", defaultValue = "1") int page, @RequestParam(name = "count", defaultValue = "5") int count) { return ResponseUtil.success(articleService.retrievePageForOpen(count, page)); }
ArticleController { @GetMapping("/articles") public Response articles(@RequestParam(name = "page", defaultValue = "1") int page, @RequestParam(name = "count", defaultValue = "5") int count) { return ResponseUtil.success(articleService.retrievePageForOpen(count, page)); } }
ArticleController { @GetMapping("/articles") public Response articles(@RequestParam(name = "page", defaultValue = "1") int page, @RequestParam(name = "count", defaultValue = "5") int count) { return ResponseUtil.success(articleService.retrievePageForOpen(count, page)); }  }
ArticleController { @GetMapping("/articles") public Response articles(@RequestParam(name = "page", defaultValue = "1") int page, @RequestParam(name = "count", defaultValue = "5") int count) { return ResponseUtil.success(articleService.retrievePageForOpen(count, page)); }  @PostMapping("/admin/article/create") Response create(@RequestBody ArticleReq body); @DeleteMapping("/admin/article/del") Response delete(@RequestParam("articleID") long articleId); @PutMapping("/admin/article/update") Response update(@RequestBody ArticleReq body); @GetMapping("/article/articleID/{articleID}") Response retrieveOneById(@PathVariable("articleID") long articleId,
                                    @RequestParam(value = "update", defaultValue = "false") boolean is4update,
                                    HttpServletRequest request); @GetMapping("/articles") Response articles(@RequestParam(name = "page", defaultValue = "1") int page,
                             @RequestParam(name = "count", defaultValue = "5") int count); @GetMapping("/admin/articles") Response adminArticles(@RequestParam(name = "page", defaultValue = "1") int page,
                                  @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/articles/category/{name}") Response findByCategory(@PathVariable("name") String name,
                                   @RequestParam(name = "page", defaultValue = "1") int page,
                                   @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/articles/tag/{name}") Response findByTag(@PathVariable("name") String name,
                              @RequestParam(name = "page", defaultValue = "1") int page,
                              @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/createSitemap") Response createSitemap(); }
ArticleController { @GetMapping("/articles") public Response articles(@RequestParam(name = "page", defaultValue = "1") int page, @RequestParam(name = "count", defaultValue = "5") int count) { return ResponseUtil.success(articleService.retrievePageForOpen(count, page)); }  @PostMapping("/admin/article/create") Response create(@RequestBody ArticleReq body); @DeleteMapping("/admin/article/del") Response delete(@RequestParam("articleID") long articleId); @PutMapping("/admin/article/update") Response update(@RequestBody ArticleReq body); @GetMapping("/article/articleID/{articleID}") Response retrieveOneById(@PathVariable("articleID") long articleId,
                                    @RequestParam(value = "update", defaultValue = "false") boolean is4update,
                                    HttpServletRequest request); @GetMapping("/articles") Response articles(@RequestParam(name = "page", defaultValue = "1") int page,
                             @RequestParam(name = "count", defaultValue = "5") int count); @GetMapping("/admin/articles") Response adminArticles(@RequestParam(name = "page", defaultValue = "1") int page,
                                  @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/articles/category/{name}") Response findByCategory(@PathVariable("name") String name,
                                   @RequestParam(name = "page", defaultValue = "1") int page,
                                   @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/articles/tag/{name}") Response findByTag(@PathVariable("name") String name,
                              @RequestParam(name = "page", defaultValue = "1") int page,
                              @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/createSitemap") Response createSitemap();  }