### Question:
ArticleController { @PutMapping("/admin/article/update") public Response update(@RequestBody ArticleReq body) { ArticleModel update = articleService.update(body); sitemapGenerateUtil.createSitemap(); return ResponseUtil.success(update); }  @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();  }### Answer:
@Test public void update() { Article article = articleMapper.getLastestArticle(); ArticleReq articleReq = new ArticleReq(); articleReq.setId(article.getId()); articleReq.setUrl("http: articleReq.setType(!article.getType()); articleReq.setCategory("test"); articleReq.setMdContent("test-" + article.getMdContent()); articleReq.setOpen(!article.getOpen()); articleReq.setTags("tag"); articleReq.setTitle("test-" + article.getTitle()); try { mockMvc.perform(put("/admin/article/update") .content(JSONObject.fromObject(articleReq).toString()) .contentType("application/json")) .andExpect(status().isOk()) .andDo(result -> { assertEquals(HAVE_NOT_LOG_IN.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code)); }); String token = userLogin(); mockMvc.perform(put("/admin/article/update") .content(JSONObject.fromObject(articleReq).toString()) .contentType("application/json") .header("Authorization", token)) .andExpect(status().isOk()) .andDo(result -> { assertEquals(PERMISSION_ERROR.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code)); }); token = adminLogin(); mockMvc.perform(put("/admin/article/update") .content(JSONObject.fromObject(articleReq).toString()) .contentType("application/json") .header("Authorization", token)) .andExpect(status().isOk()) .andDo(result -> { JSONObject jsonObject = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), jsonObject.getInt(Code)); ArticleModel a = (ArticleModel) JSONObject.toBean(jsonObject.getJSONObject(Result), ArticleModel.class); assertEquals(articleReq.getCategory(), a.getCategory()); assertEquals(articleReq.getUrl(), a.getUrl()); assertEquals(articleReq.getMdContent(), a.getMdContent()); assertEquals(articleReq.getTitle(), a.getTitle()); assertEquals(articleReq.getType(), a.getOriginal()); assertEquals(articleReq.getOpen(), a.getOpen()); assertEquals(articleReq.getId(), a.getId()); }); } catch (Exception e) { e.printStackTrace(); } }