### Question:
LoadBalanceController { @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public boolean createLoadbalance(@RequestBody BalancingDTO balancingDTO, @PathVariable String env) throws ParamValidationException { if (StringUtils.isBlank(balancingDTO.getService()) && StringUtils.isBlank(balancingDTO.getApplication())) { throw new ParamValidationException("Either Service or application is required."); } String application = balancingDTO.getApplication(); if (StringUtils.isNotEmpty(application) && this.providerService.findVersionInApplication(application).equals("2.6")) { throw new VersionValidationException("dubbo 2.6 does not support application scope load balancing config"); } overrideService.saveBalance(balancingDTO); return true; } @Autowired  LoadBalanceController(OverrideService overrideService, ProviderService providerService); @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) boolean createLoadbalance(@RequestBody BalancingDTO balancingDTO, @PathVariable String env); @RequestMapping(value = "/{id}", method = RequestMethod.PUT) boolean updateLoadbalance(@PathVariable String id, @RequestBody BalancingDTO balancingDTO, @PathVariable String env); @RequestMapping(method = RequestMethod.GET) List<BalancingDTO> searchLoadbalances(@RequestParam(required = false) String service,
                                                 @RequestParam(required = false) String application,
                                                 @PathVariable String env); @RequestMapping(value = "/{id}", method = RequestMethod.GET) BalancingDTO detailLoadBalance(@PathVariable String id, @PathVariable String env); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) boolean deleteLoadBalance(@PathVariable String id, @PathVariable String env);  }### Answer:
@Test public void createLoadbalance() throws IOException { BalancingDTO balancingDTO = new BalancingDTO(); ResponseEntity<String> response; response = restTemplate.postForEntity(url("/api/{env}/rules/balancing"), balancingDTO, String.class, env); assertFalse("should return a fail response, when service and application are all blank", (Boolean) objectMapper.readValue(response.getBody(), Map.class).get("success")); balancingDTO.setApplication("test application"); balancingDTO.setService("test service"); when(providerService.findVersionInApplication("test application")).thenReturn("2.6"); response = restTemplate.postForEntity(url("/api/{env}/rules/balancing"), balancingDTO, String.class, env); assertFalse("should return a fail response, when dubbo version is 2.6", (Boolean) objectMapper.readValue(response.getBody(), Map.class).get("success")); when(providerService.findVersionInApplication("test application")).thenReturn("2.7"); response = restTemplate.postForEntity(url("/api/{env}/rules/balancing"), balancingDTO, String.class, env); assertEquals(HttpStatus.CREATED, response.getStatusCode()); assertTrue(Boolean.valueOf(response.getBody())); }