SearchContextModel implements IModel<SearchContext>, SearchContext { public static SearchContextModel previous(SearchContext current) { if (current.hasPrevious()) { final long count = current.getResultCount(); final long prevIndex = current.getIndex() - 1; return createNew(current, prevIndex, 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 testPrevious() { final SearchContextModel result = SearchContextModel.previous(instance); assertEquals(Long.valueOf(index - 1), result.getIndex()); assertEquals(resultCount, result.getResultCount()); assertEquals(selection, result.getSelection()); }
@Test public void testFirstPrevious() { final SearchContextModel lastRecordContext = new SearchContextModel(0L, 10L, Model.of(selection)); assertNull(SearchContextModel.previous(lastRecordContext)); }