LinkHeaderResponseFilter implements ContainerResponseFilter { protected Integer getPrevPage(Page<?> page) { Integer prev = page.getPageRequest().getPage() - 1; return (prev < 1 || prev >= getLastPage(page)) ? null : prev; } @Inject  LinkHeaderResponseFilter(Configuration config,
        @Named("PREFIX_APIURL_KEY") String apiUrlPrefixKey); @SuppressWarnings("rawtypes") void filter(ContainerRequestContext reqContext, ContainerResponseContext respContext); static final int MAX_LINK_LENGTH; static final String LINK_HEADER; static final String TOTAL_RECORDS_COUNT; static final String LINK_TYPE; }
@Test public void testGetPrevPage() { Page<Object> p = new Page<>(); p.setMaxRecords(55); PageRequest pr = new PageRequest(); p.setPageRequest(pr); pr.setPerPage(10); pr.setPage(3); assertEquals(Integer.valueOf(2), interceptor.getPrevPage(p)); }
@Test public void testGetPrevPageWhenOnFirstPage() { Page<Object> p = new Page<>(); p.setMaxRecords(55); PageRequest pr = new PageRequest(); p.setPageRequest(pr); pr.setPerPage(10); pr.setPage(1); assertNull(interceptor.getPrevPage(p)); }