@Test
public void rootIsKeptChildIsStripped() {

    PDPage page1 = new PDPage();
    PDPage page2 = new PDPage();
    PDDocument document = new PDDocument();
    document.addPage(page1);
    document.addPage(page2);
    PDDocumentOutline outlines = new PDDocumentOutline();
    PDOutlineItem root = new PDOutlineItem();
    root.setTitle("title");
    root.setDestination(page1);
    PDOutlineItem child = new PDOutlineItem();
    child.setTitle("child");
    child.setDestination(page2);
    root.addFirst(child);
    outlines.addFirst(root);
    document.getDocumentCatalog().setDocumentOutline(outlines);
    mapping.addLookupEntry(document.getPage(0), new PDPage());
    PDDocumentOutline outline = new PDDocumentOutline();
    new OutlineDistiller(document).appendRelevantOutlineTo(outline, mapping);
    assertTrue(outline.hasChildren());
    assertEquals(1, outline.getOpenCount());
}