UserController { @PostMapping("/create/user") public CreateUserResponse createUser(@RequestBody CreateUserRequest request) throws AdException { log.info("ad-sponsor: createUser -> {}", JSON.toJSONString(request)); return iUserService.createUser(request); } @Autowired  UserController(IUserService iUserService); @PostMapping("/create/user") CreateUserResponse createUser(@RequestBody CreateUserRequest request);  }
@Test public void testCreateUser() { Map<String, String> map = new HashMap<>(); map.put("username", "qinyi"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<Map<String, String>> entity = new HttpEntity<>(map, headers); CommonResponse response = template.postForEntity("http: entity, CommonResponse.class).getBody(); log.debug(JSON.toJSONString(response)); }
@Test public void testService() throws AdUserException { CreateUserResponse response = iUserService.createUser(new CreateUserRequest( "qinyi" )); log.debug(JSON.toJSONString(response)); }