Source:
void executeIncludeMacroWhenExcludeFirstHeadingTrue() throws Exception { String expected = "beginDocument\n" + "beginMetaData [[source]=[wiki:space.document][syntax]=[XWiki 2.0]]\n" + "beginSection\n" + "beginSection\n" + "beginParagraph\n" + "onWord [content]\n" + "endParagraph\n" + "endSection\n" + "endSection\n" + "endMetaData [[source]=[wiki:space.document][syntax]=[XWiki 2.0]]\n" + "endDocument"; IncludeMacroParameters parameters = new IncludeMacroParameters(); parameters.setReference("document"); parameters.setExcludeFirstHeading(true); MacroTransformationContext macroContext = createMacroTransformationContext("whatever", false); DocumentReference resolvedReference = new DocumentReference("wiki", "space", "document"); when(this.macroEntityReferenceResolver.resolve("document", EntityType.DOCUMENT, macroContext.getCurrentMacroBlock())).thenReturn(resolvedReference); when(this.contextualAuthorizationManager.hasAccess(Right.VIEW, resolvedReference)).thenReturn(true); when(this.dab.getDocumentInstance((EntityReference) resolvedReference)).thenReturn(this.document); when(this.dab.getTranslatedDocumentInstance(this.document)).thenReturn(this.document); when(this.dab.getCurrentDocumentReference()) .thenReturn(new DocumentReference("wiki", "Space", "IncludingPage")); when(this.document.getDocumentReference()).thenReturn(resolvedReference); when(this.document.getSyntax()).thenReturn(Syntax.XWIKI_2_0); when(this.document.getXDOM()).thenReturn(getXDOM("== Heading ==\ncontent")); when(this.document.getRealLanguage()).thenReturn(""); List<Block> blocks = this.includeMacro.execute(parameters, null, macroContext); assertBlocks(expected, blocks, this.rendererFactory); }

Target:
void executeIncludeMacroWhenExcludeFirstHeadingTrue() throws Exception { String expected = "beginDocument\n" + "beginMetaData [[source]=[wiki:space.document][syntax]=[XWiki 2.0]]\n" + "beginSection\n" + "endSection\n" + "endMetaData [[source]=[wiki:space.document][syntax]=[XWiki 2.0]]\n" + "endDocument"; IncludeMacroParameters parameters = new IncludeMacroParameters(); parameters.setReference("document"); parameters.setExcludeFirstHeading(true); MacroTransformationContext macroContext = createMacroTransformationContext("whatever", false); DocumentReference resolvedReference = new DocumentReference("wiki", "space", "document"); when(this.macroEntityReferenceResolver.resolve("document", EntityType.DOCUMENT, macroContext.getCurrentMacroBlock())).thenReturn(resolvedReference); when(this.contextualAuthorizationManager.hasAccess(Right.VIEW, resolvedReference)).thenReturn(true); when(this.dab.getDocumentInstance((EntityReference) resolvedReference)).thenReturn(this.document); when(this.dab.getTranslatedDocumentInstance(this.document)).thenReturn(this.document); when(this.dab.getCurrentDocumentReference()) .thenReturn(new DocumentReference("wiki", "Space", "IncludingPage")); when(this.document.getDocumentReference()).thenReturn(resolvedReference); when(this.document.getSyntax()).thenReturn(Syntax.XWIKI_2_1); when(this.document.getXDOM()).thenReturn(getXDOM("=content=")); when(this.document.getRealLanguage()).thenReturn(""); List<Block> blocks = this.includeMacro.execute(parameters, null, macroContext); assertBlocks(expected, blocks, this.rendererFactory); }