@Test public void shouldReturnNothingForTooLargePageNumber() { QueryParams queryParams = new QueryParams(11, 3); List<Record> result = InMemoryQueryFilter.filter(testCollection, queryParams); assertTrue(result.isEmpty()); }
public static <T> List<T> filter(Collection<T> objects, QueryParams queryParams) { List<Order> orderList = new ArrayList<>(queryParams.getOrderList()); if (!queryParams.containsOrderOnField(Constants.Util.ID_FIELD_NAME)) { orderList.add(new Order(Constants.Util.ID_FIELD_NAME, Order.Direction.ASC)); } List<T> result = order(objects, orderList); if (queryParams.isPagingSet()) { result = paginate(result, queryParams.getPage(), queryParams.getPageSize()); } return result; }
InMemoryQueryFilter { public static <T> List<T> filter(Collection<T> objects, QueryParams queryParams) { List<Order> orderList = new ArrayList<>(queryParams.getOrderList()); if (!queryParams.containsOrderOnField(Constants.Util.ID_FIELD_NAME)) { orderList.add(new Order(Constants.Util.ID_FIELD_NAME, Order.Direction.ASC)); } List<T> result = order(objects, orderList); if (queryParams.isPagingSet()) { result = paginate(result, queryParams.getPage(), queryParams.getPageSize()); } return result; } }
InMemoryQueryFilter { public static <T> List<T> filter(Collection<T> objects, QueryParams queryParams) { List<Order> orderList = new ArrayList<>(queryParams.getOrderList()); if (!queryParams.containsOrderOnField(Constants.Util.ID_FIELD_NAME)) { orderList.add(new Order(Constants.Util.ID_FIELD_NAME, Order.Direction.ASC)); } List<T> result = order(objects, orderList); if (queryParams.isPagingSet()) { result = paginate(result, queryParams.getPage(), queryParams.getPageSize()); } return result; } private  InMemoryQueryFilter(); }
InMemoryQueryFilter { public static <T> List<T> filter(Collection<T> objects, QueryParams queryParams) { List<Order> orderList = new ArrayList<>(queryParams.getOrderList()); if (!queryParams.containsOrderOnField(Constants.Util.ID_FIELD_NAME)) { orderList.add(new Order(Constants.Util.ID_FIELD_NAME, Order.Direction.ASC)); } List<T> result = order(objects, orderList); if (queryParams.isPagingSet()) { result = paginate(result, queryParams.getPage(), queryParams.getPageSize()); } return result; } private  InMemoryQueryFilter(); static List<T> filter(Collection<T> objects, QueryParams queryParams); }
InMemoryQueryFilter { public static <T> List<T> filter(Collection<T> objects, QueryParams queryParams) { List<Order> orderList = new ArrayList<>(queryParams.getOrderList()); if (!queryParams.containsOrderOnField(Constants.Util.ID_FIELD_NAME)) { orderList.add(new Order(Constants.Util.ID_FIELD_NAME, Order.Direction.ASC)); } List<T> result = order(objects, orderList); if (queryParams.isPagingSet()) { result = paginate(result, queryParams.getPage(), queryParams.getPageSize()); } return result; } private  InMemoryQueryFilter(); static List<T> filter(Collection<T> objects, QueryParams queryParams);  }