### Question:
LoadBalanceController { @RequestMapping(method = RequestMethod.GET) public List<BalancingDTO> searchLoadbalances(@RequestParam(required = false) String service, @RequestParam(required = false) String application, @PathVariable String env) { if (StringUtils.isBlank(service) && StringUtils.isBlank(application)) { throw new ParamValidationException("Either service or application is required"); } BalancingDTO balancingDTO; if (StringUtils.isNotBlank(application)) { balancingDTO = overrideService.findBalance(application); } else { balancingDTO = overrideService.findBalance(service); } List<BalancingDTO> balancingDTOS = new ArrayList<>(); if (balancingDTO != null) { balancingDTOS.add(balancingDTO); } return balancingDTOS; } @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 searchLoadbalances() throws IOException { String service = "test service", application = "test application"; ResponseEntity<String> response; response = restTemplate.getForEntity(url("/api/{env}/rules/balancing"), 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")); response = restTemplate.getForEntity(url("/api/{env}/rules/balancing?service={service}&application={application}"), String.class, env, service, null); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(overrideService).findBalance(service); response = restTemplate.getForEntity(url("/api/{env}/rules/balancing?service={service}&application={application}"), String.class, env, null, application); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(overrideService).findBalance(application); BalancingDTO balancingDTO = new BalancingDTO(); when(overrideService.findBalance(anyString())).thenReturn(balancingDTO); response = restTemplate.getForEntity(url("/api/{env}/rules/balancing?service={service}&application={application}"), String.class, env, null, application); assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(1, objectMapper.readValue(response.getBody(), List.class).size()); }