Details
-
Improvement
-
Resolution: Fixed
-
Minor
-
3.2
-
None
Description
Right now it means providing an implementation of Configuration Source which is too complex. A better solution is to add an addMapping API in the IconTransformationConfiguration interface
// Initialize Rendering components and allow getting instances final EmbeddableComponentManager cm = new EmbeddableComponentManager(); cm.initialize(this.getClass().getClassLoader()); XDOM xdom = new XDOM(Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new SpecialSymbolBlock(':'), new SpecialSymbolBlock(':'))))); // Test adding a new Icon Mapping by registering a Configuration Source implementation (note that this can // also be done by writing a Java class, using annotations and registering it in components.txt) cm.lookup(IconTransformationConfiguration.class).addMapping("::", "something"); Transformation transformation = cm.lookup(Transformation.class, "icon"); TransformationContext txContext = new TransformationContext(); transformation.transform(xdom, txContext); WikiPrinter printer = new DefaultWikiPrinter(); BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString()); renderer.render(xdom, printer); String expected = "image:something"; Assert.assertEquals(expected, printer.toString());