BootstrapPaginator extends FormComponentPanel<Integer> { public void setTotalResults(IModel<Integer> totalResults) { this.totalResults = totalResults; } BootstrapPaginator(String id, IModel<Integer> totalResults); @SuppressWarnings("serial")  BootstrapPaginator(String id, IModel<Integer> totalResults, int resultsPerPage); boolean isShowFirstButton(); void setShowFirstButton(boolean showFirstButton); boolean isShowLastButton(); void setShowLastButton(boolean showLastButton); boolean isShowNextButton(); void setShowNextButton(boolean showNextButton); boolean isShowPreviousButton(); void setShowPreviousButton(boolean showPreviousButton); int getPagesToShow(); void setPagesToShow(int pagesToShow); int getTotalPages(); boolean isHiddenFirstButton(); void setHiddenFirstButton(boolean hiddenFirstButton); boolean isHiddenLastButton(); void setHiddenLastButton(boolean hiddenLastButton); boolean isHiddenPreviousButton(); void setHiddenPreviousButton(boolean hiddenPreviousButton); boolean isHiddenNextButton(); void setHiddenNextButton(boolean hiddenNextButton); abstract void onPageChange(AjaxRequestTarget target, IModel<Integer> page); IModel<Integer> getTotalResults(); void setTotalResults(IModel<Integer> totalResults); int getNumberResultsPerPage(); void setNumberResultsPerPage(int numberResultsPerPage); int getCurrentIndex();  }
@Test public void testRenderComponent(){ WicketTester tester = createTester(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { } }; paginator.setTotalResults(Model.of(100)); tester.startComponentInPage(paginator); tester.assertDisabled("paginator:first:link"); tester.assertDisabled("paginator:previous:link"); tester.assertEnabled("paginator:next:link"); tester.assertEnabled("paginator:last:link"); }
@Test public void testNextButton(){ WicketTester tester = createTester(); final Boxed<Integer> pageBox = new Boxed<Integer>(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { pageBox.value=page.getObject(); } }; paginator.setTotalResults(Model.of(100)); tester.startComponentInPage(paginator); tester.clickLink("paginator:next:link"); assertEquals(1, (int) pageBox.value); tester.assertEnabled("paginator:last:link"); tester.assertEnabled("paginator:next:link"); tester.assertEnabled("paginator:previous:link"); tester.assertEnabled("paginator:first:link"); }
@Test public void testPreviousButton(){ WicketTester tester = createTester(); final Boxed<Integer> pageBox = new Boxed<Integer>(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { pageBox.value=page.getObject(); } }; paginator.setTotalResults(Model.of(100)); paginator.setModelObject(2); tester.startComponentInPage(paginator); tester.clickLink("paginator:previous:link"); assertEquals(1, (int) pageBox.value); tester.assertEnabled("paginator:last:link"); tester.assertEnabled("paginator:next:link"); tester.assertEnabled("paginator:previous:link"); tester.assertEnabled("paginator:first:link"); }
@Test public void testFirstButton(){ WicketTester tester = createTester(); final Boxed<Integer> pageBox = new Boxed<Integer>(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { pageBox.value=page.getObject(); } }; paginator.setTotalResults(Model.of(100)); paginator.setModelObject(2); tester.startComponentInPage(paginator); tester.clickLink("paginator:first:link"); assertEquals(0, (int) pageBox.value); tester.assertEnabled("paginator:last:link"); tester.assertEnabled("paginator:next:link"); tester.assertDisabled("paginator:previous:link"); tester.assertDisabled("paginator:first:link"); }