### Question:
AccessesController { @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void createAccess(@RequestBody AccessDTO accessDTO, @PathVariable String env) { if (StringUtils.isBlank(accessDTO.getService()) && StringUtils.isBlank(accessDTO.getApplication())) { throw new ParamValidationException("Either Service or application is required."); } String application = accessDTO.getApplication(); if (StringUtils.isNotEmpty(application) && "2.6".equals(providerService.findVersionInApplication(application))) { throw new VersionValidationException("dubbo 2.6 does not support application scope blackwhite list config"); } if (accessDTO.getBlacklist() == null && accessDTO.getWhitelist() == null) { throw new ParamValidationException("One of Blacklist/Whitelist is required."); } routeService.createAccess(accessDTO); } @Autowired  AccessesController(RouteService routeService, ProviderService providerService); @RequestMapping(method = RequestMethod.GET) List<AccessDTO> searchAccess(@RequestParam(required = false) String service,
                                        @RequestParam(required = false) String application,
                                        @PathVariable String env); @RequestMapping(value = "/{id}", method = RequestMethod.GET) AccessDTO detailAccess(@PathVariable String id, @PathVariable String env); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) void deleteAccess(@PathVariable String id, @PathVariable String env); @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) void createAccess(@RequestBody AccessDTO accessDTO, @PathVariable String env); @RequestMapping(value = "/{id}", method = RequestMethod.PUT) void updateAccess(@PathVariable String id, @RequestBody AccessDTO accessDTO, @PathVariable String env);  }### Answer:
@Test public void createAccess() { AccessDTO accessDTO = new AccessDTO(); String application = "applicationName"; restTemplate.postForLocation(url("/api/{env}/rules/access"), accessDTO, env); accessDTO.setApplication(application); when(providerService.findVersionInApplication(application)).thenReturn("2.6"); restTemplate.postForLocation(url("/api/{env}/rules/access"), accessDTO, env); when(providerService.findVersionInApplication(application)).thenReturn("2.7"); restTemplate.postForLocation(url("/api/{env}/rules/access"), accessDTO, env); accessDTO.setBlacklist(new HashSet<>()); accessDTO.setWhitelist(new HashSet<>()); restTemplate.postForLocation(url("/api/{env}/rules/access"), accessDTO, env); verify(routeService).createAccess(any(AccessDTO.class)); }