@Test public void getAllUser() throws Exception { mockMvc.perform(get("/admin/users?page=1&count=10")) .andDo(result -> assertEquals(HAVE_NOT_LOG_IN.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code))); mockMvc.perform(get("/admin/users?page=1&count=10").header("authorization", userLogin())) .andDo(result -> assertEquals(PERMISSION_ERROR.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code))); mockMvc.perform(get("/admin/users?page=1&count=10").header("Authorization", adminLogin())) .andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), object.getInt(Code)); assertNotNull(object.getJSONObject(Result)); JSONObject resultJson = JSONObject.fromObject(object.getJSONObject(Result)); 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(10, pageInfo.getPageSize()); for (Object user : pageInfo.getList()) { UserModel u = (UserModel) JSONObject.toBean(JSONObject.fromObject(user), UserModel.class); assertNotNull(u.getId()); assertNotNull(u.getEmail()); assertNotNull(u.getRole()); assertNotNull(u.getEmailStatus()); assertNotNull(u.getDisplayName()); } }); }
@GetMapping("/admin/users") public Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count) { return ResponseUtil.success(userService.getUserList(pageNum, count)); }
UserController { @GetMapping("/admin/users") public Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count) { return ResponseUtil.success(userService.getUserList(pageNum, count)); } }
UserController { @GetMapping("/admin/users") public Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count) { return ResponseUtil.success(userService.getUserList(pageNum, count)); }  }
UserController { @GetMapping("/admin/users") public Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count) { return ResponseUtil.success(userService.getUserList(pageNum, count)); }  @PostMapping("/login") Response login(@RequestBody LoginReq loginReq); @PostMapping("/registration") Response registration(@RequestParam("email") String email,
                                 @RequestParam("password") String password); @GetMapping("/logout") Response logout(); @PutMapping("/user/userInfo/update") Response updateInfo(String desc, String displayName); @GetMapping("/user/userInfo") Response getUserInfo(); @PostMapping("/user/imgUpload") @ResponseBody Response upload(@RequestParam("file") MultipartFile file); @PostMapping("/sendResetPwdEmail") Response sendResetPwdEmail(@RequestParam("email") String email); @PostMapping("/sendVerifyEmail") Response sendVerifyEmail(@RequestParam("email") String email); @PostMapping("/emailVerify") Response emailVerify(@RequestParam("verifyId") String verifyId,
                                @RequestParam("email") String mail); @PostMapping("/resetPwd") Response resetPwd(@RequestParam("verifyId") String verifyId,
                             @RequestParam("email") String email,
                             @RequestParam("pwd") String pwd); @DeleteMapping("/admin/user/delete") Response multipleDelete(@RequestBody Integer[] ids); @DeleteMapping("/admin/user/delete/{id}") Response delete(@PathVariable("id") Integer id); @PutMapping("/admin/user") Response updateInfoByAdmin(@RequestBody UserReq user); @GetMapping("/admin/users") Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count); @GetMapping("/emailStatus/{email}") Response getEmailStatus(@PathVariable("email") String email); }
UserController { @GetMapping("/admin/users") public Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count) { return ResponseUtil.success(userService.getUserList(pageNum, count)); }  @PostMapping("/login") Response login(@RequestBody LoginReq loginReq); @PostMapping("/registration") Response registration(@RequestParam("email") String email,
                                 @RequestParam("password") String password); @GetMapping("/logout") Response logout(); @PutMapping("/user/userInfo/update") Response updateInfo(String desc, String displayName); @GetMapping("/user/userInfo") Response getUserInfo(); @PostMapping("/user/imgUpload") @ResponseBody Response upload(@RequestParam("file") MultipartFile file); @PostMapping("/sendResetPwdEmail") Response sendResetPwdEmail(@RequestParam("email") String email); @PostMapping("/sendVerifyEmail") Response sendVerifyEmail(@RequestParam("email") String email); @PostMapping("/emailVerify") Response emailVerify(@RequestParam("verifyId") String verifyId,
                                @RequestParam("email") String mail); @PostMapping("/resetPwd") Response resetPwd(@RequestParam("verifyId") String verifyId,
                             @RequestParam("email") String email,
                             @RequestParam("pwd") String pwd); @DeleteMapping("/admin/user/delete") Response multipleDelete(@RequestBody Integer[] ids); @DeleteMapping("/admin/user/delete/{id}") Response delete(@PathVariable("id") Integer id); @PutMapping("/admin/user") Response updateInfoByAdmin(@RequestBody UserReq user); @GetMapping("/admin/users") Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count); @GetMapping("/emailStatus/{email}") Response getEmailStatus(@PathVariable("email") String email);  }