PageRange { public List<Integer> getQualifyingPageNums(int nbPages) { List<Integer> allPages = new ArrayList<>(); for (IPageRangePart sequence : sequences) { allPages.addAll(sequence.getAllPagesInRange(nbPages)); } return allPages; } PageRange();  PageRange(String pageRange); PageRange addPageRangePart(IPageRangePart part); PageRange addPageSequence(int startPageNumber, int endPageNumber); PageRange addSinglePage(int pageNumber); List<Integer> getQualifyingPageNums(int nbPages); boolean isPageInRange(int pageNumber); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void addSingleConstructor() { PageRange range = new PageRange("5"); Assert.assertEquals(Arrays.asList(5), range.getQualifyingPageNums(7)); }
@Test public void addSinglesConstructor() { PageRange range = new PageRange("5, 1"); Assert.assertEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(10)); }
@Test public void addSequenceConstructor() { PageRange range = new PageRange("11-19"); Assert.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range.getQualifyingPageNums(16)); }
@Test public void addSequenceAndSingleConstructor() { PageRange range = new PageRange("22-27,25"); Assert.assertEquals(Arrays.asList(22, 23, 24, 25, 26, 27, 25), range.getQualifyingPageNums(30)); }
@Test public void addSingleAndSequenceConstructor() { PageRange range = new PageRange("5, 3-8"); Assert.assertEquals(Arrays.asList(5, 3, 4, 5, 6, 7, 8), range.getQualifyingPageNums(10)); }
@Test public void addCustomAfterConstructor() { PageRange range = new PageRange("3-"); Assert.assertEquals(Arrays.asList(3, 4, 5), range.getQualifyingPageNums(5)); }
@Test public void addCustomEvenConstructor() { PageRange range = new PageRange("even"); Assert.assertEquals(Arrays.asList(2, 4), range.getQualifyingPageNums(5)); }
@Test public void addCustomAndConstructor() { PageRange range = new PageRange("odd & 2-14"); Assert.assertEquals(Arrays.asList(3, 5, 7, 9, 11, 13), range.getQualifyingPageNums(15)); }
@Test public void addIncorrectCustomAndConstructor() { PageRange range = new PageRange("&"); Assert.assertEquals(new ArrayList<>(), range.getQualifyingPageNums(0)); }
@Test public void addIncorrectConstructor() { PageRange range = new PageRange(""); Assert.assertEquals(new ArrayList<>(), range.getQualifyingPageNums(0)); }