@Test public void testSetResultOptionsCornerCaseEntryGroup20() { AbstractEntry entry = getAbstractEntryGroup20(10); controller.setResultOptions(entry, 3, 10, "title"); assertEquals(0, entry.getEntryCollection().size()); }
protected void setResultOptions(AbstractEntry entry, Integer count, Integer startIndex, String sortBy) { entry.setFiltered(false); entry.setSorted(sortBy != null); if (sortBy != null) { entry.sortEntryCollection(sortBy); } entry.setUpdatedSince(false); int entrySize = entry.getEntrySize(); entry.setTotalResults(entrySize); entry.setStartIndex((startIndex != null && startIndex != 0) ? startIndex : 0); count = (count != null && count != 0) ? count : 0; startIndex = entry.getStartIndex(); if (startIndex > 0 || count > 0) { List collection = entry.getEntryCollection(); startIndex = startIndex > entrySize ? entrySize : startIndex; count = ((startIndex + count) < entrySize && count != 0) ? (startIndex + count) : entrySize; List subList = collection.subList(startIndex, count); entry.setEntryCollection(subList); } entry.setItemsPerPage(entry.getEntrySize()); }
ApiController extends AbstractApiController { protected void setResultOptions(AbstractEntry entry, Integer count, Integer startIndex, String sortBy) { entry.setFiltered(false); entry.setSorted(sortBy != null); if (sortBy != null) { entry.sortEntryCollection(sortBy); } entry.setUpdatedSince(false); int entrySize = entry.getEntrySize(); entry.setTotalResults(entrySize); entry.setStartIndex((startIndex != null && startIndex != 0) ? startIndex : 0); count = (count != null && count != 0) ? count : 0; startIndex = entry.getStartIndex(); if (startIndex > 0 || count > 0) { List collection = entry.getEntryCollection(); startIndex = startIndex > entrySize ? entrySize : startIndex; count = ((startIndex + count) < entrySize && count != 0) ? (startIndex + count) : entrySize; List subList = collection.subList(startIndex, count); entry.setEntryCollection(subList); } entry.setItemsPerPage(entry.getEntrySize()); } }
ApiController extends AbstractApiController { protected void setResultOptions(AbstractEntry entry, Integer count, Integer startIndex, String sortBy) { entry.setFiltered(false); entry.setSorted(sortBy != null); if (sortBy != null) { entry.sortEntryCollection(sortBy); } entry.setUpdatedSince(false); int entrySize = entry.getEntrySize(); entry.setTotalResults(entrySize); entry.setStartIndex((startIndex != null && startIndex != 0) ? startIndex : 0); count = (count != null && count != 0) ? count : 0; startIndex = entry.getStartIndex(); if (startIndex > 0 || count > 0) { List collection = entry.getEntryCollection(); startIndex = startIndex > entrySize ? entrySize : startIndex; count = ((startIndex + count) < entrySize && count != 0) ? (startIndex + count) : entrySize; List subList = collection.subList(startIndex, count); entry.setEntryCollection(subList); } entry.setItemsPerPage(entry.getEntrySize()); }  }
ApiController extends AbstractApiController { protected void setResultOptions(AbstractEntry entry, Integer count, Integer startIndex, String sortBy) { entry.setFiltered(false); entry.setSorted(sortBy != null); if (sortBy != null) { entry.sortEntryCollection(sortBy); } entry.setUpdatedSince(false); int entrySize = entry.getEntrySize(); entry.setTotalResults(entrySize); entry.setStartIndex((startIndex != null && startIndex != 0) ? startIndex : 0); count = (count != null && count != 0) ? count : 0; startIndex = entry.getStartIndex(); if (startIndex > 0 || count > 0) { List collection = entry.getEntryCollection(); startIndex = startIndex > entrySize ? entrySize : startIndex; count = ((startIndex + count) < entrySize && count != 0) ? (startIndex + count) : entrySize; List subList = collection.subList(startIndex, count); entry.setEntryCollection(subList); } entry.setItemsPerPage(entry.getEntrySize()); }  @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); }
ApiController extends AbstractApiController { protected void setResultOptions(AbstractEntry entry, Integer count, Integer startIndex, String sortBy) { entry.setFiltered(false); entry.setSorted(sortBy != null); if (sortBy != null) { entry.sortEntryCollection(sortBy); } entry.setUpdatedSince(false); int entrySize = entry.getEntrySize(); entry.setTotalResults(entrySize); entry.setStartIndex((startIndex != null && startIndex != 0) ? startIndex : 0); count = (count != null && count != 0) ? count : 0; startIndex = entry.getStartIndex(); if (startIndex > 0 || count > 0) { List collection = entry.getEntryCollection(); startIndex = startIndex > entrySize ? entrySize : startIndex; count = ((startIndex + count) < entrySize && count != 0) ? (startIndex + count) : entrySize; List subList = collection.subList(startIndex, count); entry.setEntryCollection(subList); } entry.setItemsPerPage(entry.getEntrySize()); }  @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; }