@Test public void addOne() throws Exception { String name = UUID.randomUUID().toString().substring(0, 4); mockMvc.perform(post("/admin/tag/create?name=" + name)).andDo(result -> assertEquals(HAVE_NOT_LOG_IN.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code))); mockMvc.perform(post("/admin/tag/create?name=" + name).header("authorization", userLogin())).andDo(result -> assertEquals(PERMISSION_ERROR.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code))); mockMvc.perform(post("/admin/tag/create?name=" + name).header("authorization", adminLogin())).andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), object.getInt(Code)); JSONObject resJson = object.getJSONObject(Result); Tag tag = (Tag) JSONObject.toBean(resJson, Tag.class); assertNotNull(tag.getId()); assertEquals(name, tag.getName()); }); }
@PostMapping("/admin/tag/create") public Response addOne(@RequestParam("name") String name) { return ResponseUtil.success(tagService.create(name)); }
TagController { @PostMapping("/admin/tag/create") public Response addOne(@RequestParam("name") String name) { return ResponseUtil.success(tagService.create(name)); } }
TagController { @PostMapping("/admin/tag/create") public Response addOne(@RequestParam("name") String name) { return ResponseUtil.success(tagService.create(name)); }  }
TagController { @PostMapping("/admin/tag/create") public Response addOne(@RequestParam("name") String name) { return ResponseUtil.success(tagService.create(name)); }  @PostMapping("/admin/tag/create") Response addOne(@RequestParam("name") String name); @DeleteMapping("/admin/tag/del") Response delOne(@RequestParam("id") long id); @PutMapping("/admin/tag/update") Response updateOne(@RequestParam("id") Long id, @RequestParam("name") String name); @GetMapping("/tag/id/{id}") Response retrieveOneById(@PathVariable("id") long id); @GetMapping("/tag/name/{name}") Response retrieveOneByName(@PathVariable("name") String name); @GetMapping("/tags") Response getPage(@RequestParam(required = false, defaultValue = "10", value = "count") int count,
                            @RequestParam(required = false, defaultValue = "1", value = "page") int page); @GetMapping("/tags/nac") Response getTagNameAndCount(); }
TagController { @PostMapping("/admin/tag/create") public Response addOne(@RequestParam("name") String name) { return ResponseUtil.success(tagService.create(name)); }  @PostMapping("/admin/tag/create") Response addOne(@RequestParam("name") String name); @DeleteMapping("/admin/tag/del") Response delOne(@RequestParam("id") long id); @PutMapping("/admin/tag/update") Response updateOne(@RequestParam("id") Long id, @RequestParam("name") String name); @GetMapping("/tag/id/{id}") Response retrieveOneById(@PathVariable("id") long id); @GetMapping("/tag/name/{name}") Response retrieveOneByName(@PathVariable("name") String name); @GetMapping("/tags") Response getPage(@RequestParam(required = false, defaultValue = "10", value = "count") int count,
                            @RequestParam(required = false, defaultValue = "1", value = "page") int page); @GetMapping("/tags/nac") Response getTagNameAndCount();  }