1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.transformation.macro; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
import java.util.Collections; |
24 |
|
|
25 |
|
import org.junit.Assert; |
26 |
|
import org.junit.Test; |
27 |
|
import org.xwiki.rendering.block.Block; |
28 |
|
import org.xwiki.rendering.block.MacroBlock; |
29 |
|
import org.xwiki.rendering.block.WordBlock; |
30 |
|
import org.xwiki.rendering.block.XDOM; |
31 |
|
import org.xwiki.rendering.syntax.Syntax; |
32 |
|
import org.xwiki.rendering.transformation.AbstractTransformation; |
33 |
|
import org.xwiki.rendering.transformation.MacroTransformationContext; |
34 |
|
import org.xwiki.rendering.transformation.Transformation; |
35 |
|
import org.xwiki.rendering.transformation.TransformationContext; |
36 |
|
import org.xwiki.rendering.transformation.TransformationException; |
37 |
|
|
38 |
|
|
39 |
|
@link |
40 |
|
|
41 |
|
@version |
42 |
|
@since |
43 |
|
|
|
|
| 90.5% |
Uncovered Elements: 2 (21) |
Complexity: 2 |
Complexity Density: 0.11 |
|
44 |
|
public class MacroTransformationContextTest |
45 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
46 |
1 |
@Test... |
47 |
|
public void testClone() |
48 |
|
{ |
49 |
1 |
MacroTransformationContext context = new MacroTransformationContext(); |
50 |
1 |
context.setId("id"); |
51 |
1 |
context.setInline(true); |
52 |
1 |
context.setSyntax(Syntax.XWIKI_2_0); |
53 |
|
|
54 |
1 |
XDOM xdom = new XDOM(Arrays.<Block>asList(new WordBlock("test1"))); |
55 |
1 |
context.setXDOM(xdom); |
56 |
|
|
57 |
1 |
MacroBlock macroBlock = new MacroBlock("testmacro", Collections.<String, String>emptyMap(), null, false); |
58 |
1 |
context.setCurrentMacroBlock(macroBlock); |
59 |
|
|
60 |
1 |
Transformation transformation = new AbstractTransformation() |
61 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
0 |
@Override... |
63 |
|
public void transform(Block block, TransformationContext context) throws TransformationException |
64 |
|
{ |
65 |
0 |
throw new RuntimeException("dummy"); |
66 |
|
} |
67 |
|
}; |
68 |
1 |
context.setTransformation(transformation); |
69 |
|
|
70 |
1 |
MacroTransformationContext newContext = context.clone(); |
71 |
1 |
Assert.assertNotSame(context, newContext); |
72 |
1 |
Assert.assertEquals("id", newContext.getId()); |
73 |
1 |
Assert.assertEquals(true, newContext.isInline()); |
74 |
1 |
Assert.assertEquals(Syntax.XWIKI_2_0, newContext.getSyntax()); |
75 |
1 |
Assert.assertEquals(xdom, newContext.getXDOM()); |
76 |
1 |
Assert.assertEquals(macroBlock, newContext.getCurrentMacroBlock()); |
77 |
1 |
Assert.assertEquals(transformation, newContext.getTransformation()); |
78 |
|
} |
79 |
|
} |