### Question:
WikiWordTransformation extends AbstractTransformation { @Override public void transform(Block block, TransformationContext transformationContext) throws TransformationException { for (WordBlock wordBlock : this.filter.getChildrenByType(block, WordBlock.class, true)) { Matcher matcher = WIKIWORD_PATTERN.matcher(wordBlock.getWord()); if (matcher.matches()) { ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord()); wordBlock.getParent().replaceChild(new LinkBlock(wordBlock.getChildren(), linkReference, false), wordBlock); } } }  @Override void transform(Block block, TransformationContext transformationContext);  }### Answer:
@Test public void testWikiWordTransformation() throws Exception { String testInput = "This is a WikiWord, Another\u00D9ne, XWikiEnterprise, not one: XWiki"; Parser parser = this.componentManager.getInstance(Parser.class, "xwiki/2.1"); XDOM xdom = parser.parse(new StringReader(testInput)); this.wikiWordTransformation.transform(xdom, new TransformationContext()); WikiPrinter printer = new DefaultWikiPrinter(); BlockRenderer xwiki21BlockRenderer = this.componentManager.getInstance(BlockRenderer.class, "xwiki/2.1"); xwiki21BlockRenderer.render(xdom, printer); Assert.assertEquals("This is a [[doc:WikiWord]], [[doc:Another\u00D9ne]], [[doc:XWikiEnterprise]], " + "not one: XWiki", printer.toString()); }
@Test public void testWikiWordTransformationIgnoresProtectedContent() throws Exception { String expected = "beginDocument\n" + "beginMacroMarkerStandalone [code] []\n" + "onWord [WikiWord]\n" + "endMacroMarkerStandalone [code] []\n" + "endDocument"; XDOM xdom = new XDOM(Arrays.asList((Block) new MacroMarkerBlock("code", Collections.<String, String>emptyMap(), Arrays.asList((Block) new WordBlock("WikiWord")), false))); this.wikiWordTransformation.transform(xdom, new TransformationContext()); WikiPrinter printer = new DefaultWikiPrinter(); BlockRenderer eventBlockRenderer = this.componentManager.getInstance(BlockRenderer.class, Syntax.EVENT_1_0.toIdString()); eventBlockRenderer.render(xdom, printer); Assert.assertEquals(expected, printer.toString()); }