DatabaseSetEntryController { @RequestMapping(value = "/syncdb") public ServiceResult<String> syncdb(@Validated(AddDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors) throws Exception { DataBaseInfo dataBaseInfo = dataBaseDao.getDatabaseByName(dbsetEntry.getDbName()); if (dataBaseInfo == null) { return ServiceResult.fail("请先同步物理库！" + dbsetEntry.getDbName()); } DatabaseSet databaseSet = databaseSetDao.getDatabaseSetByName(dbsetEntry.getDbsetName()); if (databaseSet == null) { return ServiceResult.fail("请先同步逻辑库！" + dbsetEntry.getDbsetName()); } dbsetEntry.setDb_Id(dataBaseInfo.getId()); dbsetEntry.setDbset_id(databaseSet.getId()); return addDbSetEntry(dbsetEntry, user, errors); }  @RequestMapping(value = "/{dbsetId}/list") ServiceResult<List<DatabaseSetEntry>> list(@PathVariable("dbsetId") Long dbsetId); @RequestMapping(value = "/list", method = RequestMethod.POST) ServiceResult<ListResult<DatabaseSetEntryView>> loadPageList(@RequestBody Paging<DatabaseSetEntry> paging); @RequestMapping(value = "/add", method = RequestMethod.POST) ServiceResult<String> add(@Validated(AddDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/adds", method = RequestMethod.POST) ServiceResult<String> adds(@Validated(AddDbSetEntry.class) @RequestBody List<DatabaseSetEntry> list, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/update", method = RequestMethod.PUT) ServiceResult<String> update(@Validated(UpdateDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/delete", method = RequestMethod.DELETE) ServiceResult<String> delete(@Validated(DeleteDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping(value = "/sync") ServiceResult<String> sync(@RequestParam("id") Long id, @CurrentUser LoginUser user); @RequestMapping(value = "/check") ConfigCkeckResult check(@RequestParam("id") Long id, @CurrentUser LoginUser user); @RequestMapping(value = "/syncdb") ServiceResult<String> syncdb(@Validated(AddDbSetEntry.class) @RequestBody DatabaseSetEntry dbsetEntry, @CurrentUser LoginUser user, Errors errors); @RequestMapping("/buttons") ServiceResult getProjectButton(@CurrentUser LoginUser user);  }
@Test public void syncdb() throws Exception { String requestJson = JSONObject.toJSONString(DataBaseInfo.builder().id(1L).dbname("name").build()); mockMvc.perform(MockMvcRequestBuilders.post("/groupdbSetEntry/syncdb") .contentType(MediaType.APPLICATION_JSON_UTF8) .content(requestJson) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(MockMvcResultHandlers.print()); }