@Test public void deleteOne() throws Exception { Category category = categoryMapper.getLastestCategory(); mockMvc.perform(delete("/admin/category/del?id=" + category.getId())).andExpect(status().isOk()) .andDo(result -> { assertEquals(HAVE_NOT_LOG_IN.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code)); }); String token = userLogin(); mockMvc.perform(delete("/admin/category/del?id=" + category.getId()) .header("Authorization", token)) .andExpect(status().isOk()) .andDo(result -> { assertEquals(PERMISSION_ERROR.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code)); }); token = adminLogin(); mockMvc.perform(delete("/admin/category/del?id=" + category.getId()) .header("Authorization", token)) .andExpect(status().isOk()) .andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), object.getInt(Code)); assertTrue(object.getBoolean(Result)); }); }
@DeleteMapping("/admin/category/del") public Response deleteOne(@RequestParam("id") long id) { return ResponseUtil.success(categoryService.delete(id)); }
CategoryController { @DeleteMapping("/admin/category/del") public Response deleteOne(@RequestParam("id") long id) { return ResponseUtil.success(categoryService.delete(id)); } }
CategoryController { @DeleteMapping("/admin/category/del") public Response deleteOne(@RequestParam("id") long id) { return ResponseUtil.success(categoryService.delete(id)); }  }
CategoryController { @DeleteMapping("/admin/category/del") public Response deleteOne(@RequestParam("id") long id) { return ResponseUtil.success(categoryService.delete(id)); }  @PostMapping("/admin/category/create") Response addOne(@RequestParam("name") String name); @DeleteMapping("/admin/category/del") Response deleteOne(@RequestParam("id") long id); @PutMapping("/admin/category/update") Response updateOne(@RequestParam("id") Long id,
                              @RequestParam("name") String name); @GetMapping("/categories") Response getPage(); }
CategoryController { @DeleteMapping("/admin/category/del") public Response deleteOne(@RequestParam("id") long id) { return ResponseUtil.success(categoryService.delete(id)); }  @PostMapping("/admin/category/create") Response addOne(@RequestParam("name") String name); @DeleteMapping("/admin/category/del") Response deleteOne(@RequestParam("id") long id); @PutMapping("/admin/category/update") Response updateOne(@RequestParam("id") Long id,
                              @RequestParam("name") String name); @GetMapping("/categories") Response getPage();  }