@Test public void update() throws Exception { PartnerSite partnerSite = new PartnerSite(); partnerSite.setName(UUID.randomUUID().toString().substring(0, 4)); partnerSite.setOpen(true); partnerSite.setUrl("https: mapper.insert(partnerSite); PartnerSite lastest = mapper.getLastest(); assertNotNull(lastest.getId()); String token = adminLogin(); LinkReq linkReq = new LinkReq(); linkReq.setUrl(lastest.getUrl()); linkReq.setOpen(!lastest.getOpen()); linkReq.setName(UUID.randomUUID().toString().substring(0, 4)); linkReq.setId(lastest.getId()); mockMvc.perform( put("/admin/links/update") .content(JSONObject.fromObject(linkReq).toString()) .contentType(MediaType.APPLICATION_JSON) .header("Authorization", token) ).andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), object.getInt(Code)); PartnerSite site = (PartnerSite) JSONObject.toBean(object.getJSONObject(Result), PartnerSite.class); assertNotNull(site.getId()); assertEquals(linkReq.getId(), site.getId().longValue()); assertEquals(linkReq.getUrl(), site.getUrl()); assertEquals(linkReq.getName(), site.getName()); assertEquals(linkReq.isOpen(), site.getOpen()); }); }
@PutMapping("/admin/links/update") public Response update(@RequestBody LinkReq reqBody) { return ResponseUtil.success(partnerSiteService.update(reqBody)); }
LinksController { @PutMapping("/admin/links/update") public Response update(@RequestBody LinkReq reqBody) { return ResponseUtil.success(partnerSiteService.update(reqBody)); } }
LinksController { @PutMapping("/admin/links/update") public Response update(@RequestBody LinkReq reqBody) { return ResponseUtil.success(partnerSiteService.update(reqBody)); }  }
LinksController { @PutMapping("/admin/links/update") public Response update(@RequestBody LinkReq reqBody) { return ResponseUtil.success(partnerSiteService.update(reqBody)); }  @PostMapping("/admin/links/create") Response create(@RequestBody LinkReq reqBody); @DeleteMapping("/admin/links/del/{id}") Response del(@PathVariable("id") long id); @PutMapping("/admin/links/update") Response update(@RequestBody LinkReq reqBody); @GetMapping("/links") Response allForOpen(); @GetMapping("/admin/links") Response all(@RequestParam("page") int page,
                        @RequestParam("count") int count); @PostMapping("/apply") Response apply(@RequestParam("name") String name,
                          @RequestParam("url") String url); }
LinksController { @PutMapping("/admin/links/update") public Response update(@RequestBody LinkReq reqBody) { return ResponseUtil.success(partnerSiteService.update(reqBody)); }  @PostMapping("/admin/links/create") Response create(@RequestBody LinkReq reqBody); @DeleteMapping("/admin/links/del/{id}") Response del(@PathVariable("id") long id); @PutMapping("/admin/links/update") Response update(@RequestBody LinkReq reqBody); @GetMapping("/links") Response allForOpen(); @GetMapping("/admin/links") Response all(@RequestParam("page") int page,
                        @RequestParam("count") int count); @PostMapping("/apply") Response apply(@RequestParam("name") String name,
                          @RequestParam("url") String url);  }