RestController { @ExceptionHandler(value = { MissingAnyOfOptionalServletRequestParametersException.class, MissingServletRequestParameterException.class }) public @ResponseBody ResponseEntity<BadRequest> handleMissingRequestParameter(ServletRequestBindingException exception, HttpServletRequest req) { return new ResponseEntity<BadRequest>(handleBadRequest(exception, req), HttpStatus.BAD_REQUEST); }  @RequestMapping(value = ADDRESS_URI, method = RequestMethod.GET) @ResponseBody Map<String, Object> address(
            @RequestParam(required = false) String houseNumber,
            @RequestParam String street,
            @RequestParam(required = false) String borough,
            @RequestParam(required = false) String zip); @RequestMapping(value = ADDRESSPOINT_URI, method = RequestMethod.GET) @ResponseBody Map<String, Object> addresspoint(
            @RequestParam(required = false) String houseNumber,
            @RequestParam String street,
            @RequestParam(required = false) String borough,
            @RequestParam(required = false) String zip); @RequestMapping(value = PLACE_URI, method = RequestMethod.GET) @ResponseBody Map<String, Object> place(
            @RequestParam String name,
            @RequestParam(required = false) String borough,
            @RequestParam(required = false) String zip); @RequestMapping(value = INTERSECTION_URI, method = RequestMethod.GET) @ResponseBody Map<String, Object> intersection(@RequestParam String crossStreetOne, @RequestParam String crossStreetTwo,
            @RequestParam String borough, @RequestParam(required = false) String boroughCrossStreetTwo,
            @RequestParam(required = false) String compassDirection); @RequestMapping(value = BLOCKFACE_URI, method = RequestMethod.GET) @ResponseBody Map<String, Object> blockface(@RequestParam String onStreet, @RequestParam String crossStreetOne,
            @RequestParam String crossStreetTwo, @RequestParam String borough,
            @RequestParam(required = false) String boroughCrossStreetOne,
            @RequestParam(required = false) String boroughCrossStreetTwo,
            @RequestParam(required = false) String compassDirection); @RequestMapping(value = BBL_URI, method = RequestMethod.GET) @ResponseBody Map<String, Object> bbl(@RequestParam String borough, @RequestParam String block, @RequestParam String lot); @RequestMapping(value = BIN_URI, method = RequestMethod.GET) @ResponseBody Map<String, Object> bin(@RequestParam String bin); @RequestMapping(value = NORMALIZE_URI, method = RequestMethod.GET) @ResponseBody Map<String, Object> normalize(@RequestParam String name, @RequestParam(required = false, defaultValue = "32") Integer length, @RequestParam(required = false, defaultValue = "S") String format); @RequestMapping(value = STREETCODE_URI, method = RequestMethod.GET) @ResponseBody Map<String, Object> streetcode(@RequestParam String streetCode,
            @RequestParam(required = false) String streetCodeTwo,
            @RequestParam(required = false) String streetCodeThree,
            @RequestParam(required = false, defaultValue = "32") Integer length,
            @RequestParam(required = false, defaultValue = "S") String format); @RequestMapping(value = GEOSUPPORT_URI, method = RequestMethod.GET) @ResponseBody Map<String, Object> geosupport(@RequestParam Map<String, Object> params); @RequestMapping(value = VERSION_URI, method = RequestMethod.GET) @ResponseBody Version version(); @ExceptionHandler(value = { MissingAnyOfOptionalServletRequestParametersException.class, MissingServletRequestParameterException.class }) @ResponseBody ResponseEntity<BadRequest> handleMissingRequestParameter(ServletRequestBindingException exception,
            HttpServletRequest req); @ExceptionHandler @ResponseBody ResponseEntity<BadRequest> handleInvalidStreetCodeRequestParameter(InvalidStreetCodeException exception,
            HttpServletRequest req); void setGeosupportService(GeosupportService geosupportService); static final String ADDRESS_URI; static final String ADDRESSPOINT_URI; static final String BBL_URI; static final String BIN_URI; static final String BLOCKFACE_URI; static final String GEOSUPPORT_URI; static final String INTERSECTION_URI; static final String NORMALIZE_URI; static final String PLACE_URI; static final String STREETCODE_URI; static final String VERSION_URI; static final String ADDRESS_OBJ; static final String ADDRESSPOINT_OBJ; static final String BBL_OBJ; static final String BIN_OBJ; static final String BLOCKFACE_OBJ; static final String INTERSECTION_OBJ; static final String NORMALIZE_OBJ; static final String PLACE_OBJ; static final String STREETCODE_OBJ; }
@Test public void testHandleMissingRequestParameter() { MockHttpServletRequest req = new MockHttpServletRequest(); String requestUri = "/foo"; String queryString = "bar=1"; req.setRequestURI(requestUri); req.setQueryString(queryString); MissingAnyOfOptionalServletRequestParametersException e = new MissingAnyOfOptionalServletRequestParametersException( "dog", "cat"); ResponseEntity<BadRequest> result = this.restController.handleMissingRequestParameter(e, req); assertEquals(HttpStatus.BAD_REQUEST, result.getStatusCode()); assertEquals(String.format("%s?%s", requestUri, queryString), result.getBody().getRequestUri()); assertEquals(e.getMessage(), result.getBody().getMessage()); }