TableOfContentsCreator { public boolean shouldGenerateToC() { return params.getTableOfContentsPolicy() != ToCPolicy.NONE; } 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 testShouldGenerateToC() { MergeParameters params = new MergeParameters(); params.setTableOfContentsPolicy(ToCPolicy.DOC_TITLES); assertTrue(new TableOfContentsCreator(params, new PDDocument()).shouldGenerateToC()); assertFalse(new TableOfContentsCreator(new MergeParameters(), new PDDocument()).shouldGenerateToC()); params.setTableOfContentsPolicy(null); assertFalse(new TableOfContentsCreator(new MergeParameters(), new PDDocument()).shouldGenerateToC()); }