TableOfContentsCreator { public void addToC() throws TaskException { addToC(0); } TableOfContentsCreator(MergeParameters params, PDDocument document); void appendItem(String text, long pageNumber, PDPage page); void addToC(); void addToC(int beforePageNumber); boolean hasToc(); boolean shouldGenerateToC(); void pageSizeIfNotSet(PDRectangle pageSize); float getFontSize(); long tocNumberOfPages();  }
@Test public void testAddToC() throws TaskException { MergeParameters params = new MergeParameters(); params.setTableOfContentsPolicy(ToCPolicy.DOC_TITLES); PDDocument doc = new PDDocument(); assertEquals(0, doc.getNumberOfPages()); TableOfContentsCreator victim = new TableOfContentsCreator(params, doc); victim.appendItem("text", 10, new PDPage()); victim.addToC(); assertEquals(1, doc.getNumberOfPages()); }