### Question:
AccessesController { @RequestMapping(method = RequestMethod.GET) public List<AccessDTO> searchAccess(@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"); } List<AccessDTO> accessDTOS = new ArrayList<>(); AccessDTO accessDTO; if (StringUtils.isNotBlank(application)) { accessDTO = routeService.findAccess(application); } else { accessDTO = routeService.findAccess(service); } if (accessDTO != null) { accessDTO.setEnabled(true); accessDTOS.add(accessDTO); } return accessDTOS; } @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 searchAccess() throws IOException { AccessDTO accessDTO = new AccessDTO(); ResponseEntity<String> response; String exceptResponseBody; response = restTemplate.getForEntity(url("/api/{env}/rules/access"), String.class, env); Map map = objectMapper.readValue(response.getBody(), Map.class); assertFalse("should return a fail response", (Boolean) map.get("success")); String application = "applicationName"; when(routeService.findAccess(application)).thenReturn(accessDTO); response = restTemplate.getForEntity(url("/api/{env}/rules/access?application={application}"), String.class, env, application); exceptResponseBody = objectMapper.writeValueAsString(Collections.singletonList(accessDTO)); assertEquals(exceptResponseBody, response.getBody()); String service = "serviceName"; when(routeService.findAccess(service)).thenReturn(accessDTO); response = restTemplate.getForEntity(url("/api/{env}/rules/access?service={service}"), String.class, env, service); exceptResponseBody = objectMapper.writeValueAsString(Collections.singletonList(accessDTO)); assertEquals(exceptResponseBody, response.getBody()); }