ListProviderUtil { public static Map<String, String> filterMap(Map<String, String> map, ResourceListQuery query) { if (noActionRequired(query)) return map; int limit = query.getLimit().getOrElse(0); int offset = query.getOffset().getOrElse(0); SmartIterator<String> si = new SmartIterator<>(limit, offset); return si.applyLimitAndOffset(map); } private  ListProviderUtil(); static Map<String, String> sortMapByValue(Map<String, String> map, boolean asc); static Map<String, String> filterMap(Map<String, String> map, ResourceListQuery query); static Map<String, String> invertMap(Map<String, String> map);  }
@Test public void testFilterMap() { Map<String, String> testMap = getTestMap(); ResourceListQueryImpl query = new ResourceListQueryImpl(); query.setLimit(3); query.setOffset(0); assertEquals(3, filterMap(testMap, query).size()); query.setLimit(0); query.setOffset(testMap.size()); assertEquals(0, filterMap(testMap, query).size()); query.setLimit(6); query.setOffset(testMap.size() - 3); assertEquals(3, filterMap(testMap, query).size()); }