ConfigController { @RequestMapping(value = "/add", method = RequestMethod.POST) public ServiceResult<String> add(@RequestBody DataBaseInfo dataBaseInfo) { return configService.addConfig(dataBaseInfo); }  @RequestMapping(value = "/datasourceValid", method = RequestMethod.GET) ServiceResult<String> datasourceValid(); @RequestMapping(value = "/add", method = RequestMethod.POST) ServiceResult<String> add(@RequestBody DataBaseInfo dataBaseInfo); @RequestMapping(value = "/env") ServiceResult<String> env(HttpServletRequest request, @CurrentUser LoginUser user);  }
@Test public void add() throws Exception { String requestJson = JSONObject.toJSONString(DataBaseInfo.builder().id(1L).dbname("name").build()); mockMvc.perform(MockMvcRequestBuilders.get("/config/add") .contentType(MediaType.APPLICATION_JSON_UTF8) .content(requestJson) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(MockMvcResultHandlers.print()); }