PaginationInfo { public String getPageUrl(int pageIndex) { Map<String, Object> attr = createAttributeMap(pageIndex, page.getSize(), page.getSort()); StringBuilder pageUriBuilder = new StringBuilder(pageUri.expand(attr) .encode().toUriString()); if (StringUtils.hasLength(criteriaQuery)) { if (pageUri.getQueryParams().isEmpty()) { pageUriBuilder.append("?"); } else { pageUriBuilder.append("&"); } pageUriBuilder.append(criteriaQuery); } return pageUriBuilder.toString(); } PaginationInfo(Page<?> page, String pathTmpl, String queryTmpl,
            int maxDisplayCount);  PaginationInfo(Page<?> page, String pathTmpl, String queryTmpl,
            String criteriaQuery, boolean disableHtmlEscapeOfCriteriaQuery,
            int maxDisplayCount); static Map<String, Object> createAttributeMap(int pageIndex,
            int size, Sort sort); int getCurrent(); String getPathTmpl(); String getQueryTmpl(); String getCriteriaQuery(); int getMaxDisplayCount(); String getPageUrl(int pageIndex); String getFirstUrl(); String getLastUrl(); String getPreviousUrl(); String getNextUrl(); boolean isFirstPage(); boolean isLastPage(); boolean isCurrent(int page); BeginAndEnd getBeginAndEnd(); static final int DEFAULT_MAX_DISPLAY_COUNT; static final String DEFAULT_PATH_TEMPLATE; static final String DEFAULT_QUERY_TEMPLATE; static final String PAGE_ATTR; static final String SIZE_ATTR; static final String SORT_ORDER_PROPERTY_ATTR; static final String SORT_ORDER_DIRECTION_ATTR; static final String A_ELM; static final String HREF_ATTR; static final String CLASS_ATTR; static final String DEFAULT_OUTER_ELM; static final String DEFAULT_OUTER_CLASS; static final String DEFAULT_INNER_ELM; static final String DEFAULT_INNER_CLASS; static final String DEFAULT_FIRST_LINK_TEXT; static final String DEFAULT_PREVIOUS_LINK_TEXT; static final String DEFAULT_NEXT_LINK_TEXT; static final String DEFAULT_LAST_LINK_TEXT; static final String DEFAULT_DISABLED_HREF; static final String DEFAULT_ACTIVE_CLASS; static final String DEFAULT_DISABLED_CLASS; }
@Test public void issue12_testGetPageUrl_criteriaQueryIsEmpty() { PaginationInfo info = new PaginationInfo(page, pathTmpl, queryTmpl, "", false, 10); String expectedURL = "terasoluna?value=test&page=0&size=5"; assertThat(info.getPageUrl(0), is(expectedURL)); }
@Test public void issue12_testGetPageUrl_criteriaQueryIsSpecified() { PaginationInfo info = new PaginationInfo(page, pathTmpl, queryTmpl, "a=%2B", false, 10); String expectedURL = "terasoluna?value=test&page=0&size=5&a=%2B"; assertThat(info.getPageUrl(0), is(expectedURL)); }
@Test public void issue12_testGetPageUrl_criteriaQueryIsSpecified_queryTmplNotSpecified() { PaginationInfo info = new PaginationInfo(page, "/{page}/{size}", null, "a=<>&\"'a1", false, 10); String expectedURL = "/3/5?a=&lt;&gt;&amp;&quot;&#39;a1"; assertThat(info.getPageUrl(3), is(expectedURL)); }
@Test public void issue12_testGetPageUrl_disableHtmlEscapeOfCriteriaQueryIsTrue_queryTmplNotSpecified() { PaginationInfo info = new PaginationInfo(page, "/{page}/{size}", null, "a=<>&\"'a1", true, 10); String expectedURL = "/3/5?a=<>&\"'a1"; assertThat(info.getPageUrl(3), is(expectedURL)); }