PageableCollectionBase extends PropertyChangeSupportedBase implements PageableCollection<T_ITEM> { @Override public final QueryParams getQueryParams() { return queryParams; } PageableCollectionBase(QueryOptions queryOptions); @Override final QueryParams getQueryParams(); @Override QueryOptions getQueryOptions(); @Override int getPageSize(); @Override void setPageSize(int newSize); @Override long getPageIdx(); @Override void setPageIdx(long pageIdx); @Override Selection<T_ITEM> getSelection(); @Override Modifications<T_ITEM> getModifications();  }
@Test public void testSwitchQueryExecOffAndOn() { assertEquals("[a, b, c, d, e, f]", PageableCollectionUtil.shallowCopy(collection).toString()); collection.getQueryParams().setExecQuery(false); assertEquals(0, collection.getNumOfItems()); assertEquals("[]", PageableCollectionUtil.shallowCopy(collection).toString()); collection.getQueryParams().setExecQuery(true); assertEquals(6, collection.getNumOfItems()); assertEquals("[a, b, c, d, e, f]", PageableCollectionUtil.shallowCopy(collection).toString()); assertEquals("Add event count", 0, pclAdd.getPropChangeEventCount()); assertEquals("Update event count", 0, pclUpdate.getPropChangeEventCount()); assertEquals("Remove event count", 0, pclRemove.getPropChangeEventCount()); assertEquals("Set page index event count", 0, pclPageIdx.getPropChangeEventCount()); assertEquals("Set page size event count", 0, pclPageSize.getPropChangeEventCount()); }
@Test public void testSortItems() { assertEquals("Initial (unsorted) sort order", "[a, b, c, d, e, f]", PageableCollectionUtil.shallowCopy(collection).toString()); collection.getQueryParams().setSortOrder(nameSortOrder); assertEquals("Ascending sort order", "[a, b, c, d, e, f]", PageableCollectionUtil.shallowCopy(collection).toString()); collection.getQueryParams().setSortOrder(nameSortOrder.getReverseSortOrder()); assertEquals("Descending sort order", "[f, e, d, c, b, a]", PageableCollectionUtil.shallowCopy(collection).toString()); collection.getQueryParams().setSortOrder(null); assertEquals("Initial (unsorted) sort order again", "[a, b, c, d, e, f]", PageableCollectionUtil.shallowCopy(collection).toString()); assertEquals("Add event count", 0, pclAdd.getPropChangeEventCount()); assertEquals("Update event count", 0, pclUpdate.getPropChangeEventCount()); assertEquals("Remove event count", 0, pclRemove.getPropChangeEventCount()); assertEquals("Set page index event count", 0, pclPageIdx.getPropChangeEventCount()); assertEquals("Set page size event count", 0, pclPageSize.getPropChangeEventCount()); }
@Test public void testFilterItems() { collection.getQueryParams().setQueryExpression(getFilterNameStartsWith("b")); assertEquals("Filtered item set.", "[b]", PageableCollectionUtil.shallowCopy(collection).toString()); collection.getQueryParams().setQueryExpression(null); assertEquals("We get all items after resetting the filter.", "[a, b, c, d, e, f]", PageableCollectionUtil.shallowCopy(collection).toString()); assertEquals("Add event count", 0, pclAdd.getPropChangeEventCount()); assertEquals("Update event count", 0, pclUpdate.getPropChangeEventCount()); assertEquals("Remove event count", 0, pclRemove.getPropChangeEventCount()); assertEquals("Set page index event count", 0, pclPageIdx.getPropChangeEventCount()); assertEquals("Set page size event count", 0, pclPageSize.getPropChangeEventCount()); }