ApiController extends AbstractApiController { @ResponseStatus(value = HttpStatus.NOT_FOUND) @ResponseBody @ExceptionHandler(RuntimeException.class) public Object handleRuntimeException(RuntimeException e) { LOG.error("Handling generic runtime exception, will respond with HTTP Not Found.", e); return new Group20Entry(new ArrayList<Group20>()); }  @RequestMapping(method = RequestMethod.GET, value = "/people/{userId:.+}") @ResponseBody PersonEntry getPerson(@PathVariable("userId")
  String userId); @RequestMapping(method = RequestMethod.GET, value = "/people/{userId:.+}/{groupId:.+}") @ResponseBody Object getGroupMembers(@PathVariable("userId")
  String userId, @PathVariable("groupId")
  String groupId, @RequestParam(value = "count", required = false)
  Integer count, @RequestParam(value = "startIndex", required = false)
  Integer startIndex, @RequestParam(value = "sortBy", required = false)
  String sortBy); @RequestMapping(method = RequestMethod.GET, value = "/groups/{userId:.+}") @ResponseBody Group20Entry getGroups(@PathVariable("userId")
  String userId, @RequestParam(value = "count", required = false)
  Integer count, @RequestParam(value = "startIndex", required = false)
  Integer startIndex, @RequestParam(value = "sortBy", required = false)
  String sortBy); @RequestMapping(method = RequestMethod.GET, value = "/osgroups/{userId:.+}") @ResponseBody GroupEntry getOsGroups(@PathVariable("userId")
  String userId, @RequestParam(value = "count", required = false)
  Integer count, @RequestParam(value = "startIndex", required = false)
  Integer startIndex, @RequestParam(value = "sortBy", required = false)
  String sortBy); @RequestMapping(method = RequestMethod.GET, value = "/groups/{userId:.+}/{groupId}") @ResponseBody Group20Entry getGroup(@PathVariable("userId")
  String userId, @PathVariable("groupId")
  String groupId); @ResponseStatus(value = HttpStatus.NOT_FOUND) @ResponseBody @ExceptionHandler(RuntimeException.class) Object handleRuntimeException(RuntimeException e); @ResponseStatus(value = HttpStatus.BAD_REQUEST) @ResponseBody @ExceptionHandler(IllegalArgumentException.class) Object handleIllegalArgumentException(IllegalArgumentException e); static final String GROUP_ID_SELF; static final String PERSON_ID_SELF; }
@Test public void testErrorHandling() throws JsonGenerationException, JsonMappingException, IOException { Object results = controller.handleRuntimeException(new RuntimeException("nice")); String s = new ObjectMapper().writeValueAsString(results); System.out.println(s); }