PdfMergeInput implements PageRangeSelection, PagesSelection, MergeInput { @Override public Set<Integer> getPages(int totalNumberOfPage) { Set<Integer> retSet = new NullSafeSet<Integer>(); if (isAllPages()) { for (int i = 1; i <= totalNumberOfPage; i++) { retSet.add(i); } } else { for (PageRange range : getPageSelection()) { retSet.addAll(range.getPages(totalNumberOfPage)); } } return retSet; } PdfMergeInput(PdfSource<?> source, Set<PageRange> pageSelection);  PdfMergeInput(PdfSource<?> source); PdfSource<?> getSource(); @Override Set<PageRange> getPageSelection(); void addPageRange(PageRange range); void addAllPageRanges(Collection<PageRange> ranges); boolean isAllPages(); @Override Set<Integer> getPages(int totalNumberOfPage); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object other);  }
@Test public void getPages() { PdfMergeInput victim = new PdfMergeInput(source); List<PageRange> ranges = new ArrayList<PageRange>(); ranges.add(new PageRange(5, 8)); ranges.add(new PageRange(10, 11)); victim.addAllPageRanges(ranges); assertEquals(6, victim.getPages(20).size()); }