1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.internal.transformation.macro

File MacroTransformationContextTest.java

 

Code metrics

0
19
2
1
79
47
2
0.11
9.5
2
1

Classes

Class Line # Actions
MacroTransformationContextTest 44 19 0% 2 2
0.904761990.5%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * Unit tests for {@link MacroTransformationContext}.
40    *
41    * @version $Id: 90c1217dee7c3b054dd05cbb1f1c096c163771d1 $
42    * @since 3.0M1
43    */
 
44    public class MacroTransformationContextTest
45    {
 
46  1 toggle @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    {
 
62  0 toggle @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    }