ServerGroupController { @RequestMapping(value = "/add", method = RequestMethod.POST) public ServiceResult<String> add(@Validated(AddServerGroup.class) @RequestBody ServerGroup serverGroup, @CurrentUser LoginUser user, Errors errors) throws Exception { serverGroup.setUpdate_user_no(user.getUserNo()); ValidateResult validateRes = serverGroupService.validatePermision(user, errors) .addAssert(() -> serverGroupDaoOld.getCountByName(serverGroup.getName()) == 0, serverGroup.getName() + " 已存在！") .addAssert(() -> serverGroupDaoOld.insertServerGroup(serverGroup) > 0, message.db_message_add_operation_failed).validate(); if (!validateRes.isValid()) { return ServiceResult.fail(validateRes.getSummarize()); } return serverGroupService.addDataCenter(user, serverGroup); }  @RequestMapping(value = "/loadAllServerGroups") ServiceResult<List<ServerGroup>> loadAllServerGroups(); @RequestMapping(value = "/serversNoGroup") ServiceResult<List<Server>> serversNoGroup(@RequestParam(value = "appGroupId", defaultValue = "0") Integer appGroupId); @RequestMapping(value = "/list", method = RequestMethod.POST) ServiceResult<ListResult<ServerGroupView>> loadPageList(@RequestBody Paging<ServerGroup> paging); @RequestMapping(value = "/add", method = RequestMethod.POST) ServiceResult<String> add(@Validated(AddServerGroup.class) @RequestBody ServerGroup serverGroup, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/update", method = RequestMethod.PUT) ServiceResult<String> update(@Validated(UpdateServerGroup.class) @RequestBody ServerGroup serverGroup, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/delete", method = RequestMethod.DELETE) ServiceResult<String> delete(@Validated(DeleteServerGroup.class) @RequestBody ServerGroup serverGroup, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/sync") ServiceResult<String> sync(@RequestParam("id") Long id, @CurrentUser LoginUser user); @RequestMapping(value = "/check") ConfigCkeckResult<ConfigCheckItem> check(@RequestParam("id") Long id, @CurrentUser LoginUser user);  }
@Test public void add() throws Exception { mockMvc.perform(MockMvcRequestBuilders.post("/serverGroup/add") .contentType(MediaType.APPLICATION_JSON_UTF8) .content(requestJson) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(MockMvcResultHandlers.print()); }