SearchContextModel implements IModel<SearchContext>, SearchContext { public static SearchContextModel next(SearchContext current) { if (current.hasNext()) { final Long count = current.getResultCount(); final Long nextIndex = current.getIndex() + 1; return createNew(current, nextIndex, count); } else { return null; } } SearchContextModel(IModel<QueryFacetsSelection> selectionModel);  SearchContextModel(Long index, Long resultCount, IModel<QueryFacetsSelection> selectionModel); IModel<QueryFacetsSelection> getSelectionModel(); @Override QueryFacetsSelection getSelection(); @Override Long getResultCount(); @Override Long getIndex(); @Override SearchContext getObject(); @Override void detach(); static SearchContextModel next(SearchContext current); static SearchContextModel previous(SearchContext current); @Override boolean hasPrevious(); @Override boolean hasNext();  }
@Test public void testNext() { final SearchContextModel result = SearchContextModel.next(instance); assertEquals(Long.valueOf(index + 1L), result.getIndex()); assertEquals(resultCount, result.getResultCount()); assertEquals(selection, result.getSelection()); }
@Test public void testLastNext() { final SearchContextModel lastRecordContext = new SearchContextModel(9L, 10L, Model.of(selection)); assertNull(SearchContextModel.next(lastRecordContext)); }