### Question:
DefaultDocumentSplitter implements DocumentSplitter { @Override public List<WikiDocument> split(WikiDocument rootDoc, SplittingCriterion splittingCriterion, NamingCriterion namingCriterion) { List<WikiDocument> result = new ArrayList<WikiDocument>(); result.add(rootDoc); split(rootDoc, rootDoc.getXdom().getChildren(), 1, result, splittingCriterion, namingCriterion); updateAnchors(result); return result; }  @Override List<WikiDocument> split(WikiDocument rootDoc, SplittingCriterion splittingCriterion,
        NamingCriterion namingCriterion);  }### Answer:
@Test public void split() throws Exception { SplittingCriterion splittingCriterion = mock(SplittingCriterion.class); when(splittingCriterion.shouldSplit(any(Block.class), anyInt())).thenReturn(true, false, false, true); when(splittingCriterion.shouldIterate(any(SectionBlock.class), anyInt())).thenReturn(true, false, false, false); NamingCriterion namingCriterion = mock(NamingCriterion.class); when(namingCriterion.getDocumentName(any(XDOM.class))).thenReturn("Child1", "Child2"); HeaderBlock header = new HeaderBlock(Arrays.<Block> asList(new WordBlock("Section 1.1")), HeaderLevel.LEVEL2); ParagraphBlock paragraph = new ParagraphBlock(Arrays.<Block> asList(new WordBlock("In a kingdom far away.."))); SectionBlock subSection = new SectionBlock(Arrays.<Block> asList(header, paragraph)); header = new HeaderBlock(Arrays.<Block> asList(new WordBlock("Chapter 1")), HeaderLevel.LEVEL1); paragraph = new ParagraphBlock(Arrays.<Block> asList(new WordBlock("Once upon a time.."))); SectionBlock section = new SectionBlock(Arrays.<Block> asList(header, paragraph, subSection)); XDOM xdom = new XDOM(Arrays.<Block> asList(section)); WikiDocument document = new WikiDocument("Space.Page", xdom, null); List<WikiDocument> result = mocker.getComponentUnderTest().split(document, splittingCriterion, namingCriterion); assertEquals(3, result.size()); assertSame(document, result.get(0)); assertEquals("Child1", result.get(1).getFullName()); assertSame(document, result.get(1).getParent()); assertEquals("Child2", result.get(2).getFullName()); assertSame(result.get(1), result.get(2).getParent()); ClassBlockMatcher headerMatcher = new ClassBlockMatcher(HeaderBlock.class); ClassBlockMatcher linkMatcher = new ClassBlockMatcher(LinkBlock.class); assertTrue(document.getXdom().getBlocks(headerMatcher, Axes.DESCENDANT).isEmpty()); assertEquals(1, document.getXdom().getBlocks(linkMatcher, Axes.DESCENDANT).size()); assertEquals(1, result.get(1).getXdom().getBlocks(headerMatcher, Axes.DESCENDANT).size()); assertEquals(1, result.get(1).getXdom().getBlocks(linkMatcher, Axes.DESCENDANT).size()); assertEquals(1, result.get(2).getXdom().getBlocks(headerMatcher, Axes.DESCENDANT).size()); assertTrue(result.get(2).getXdom().getBlocks(linkMatcher, Axes.DESCENDANT).isEmpty()); }