| 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.Rule; |
| 27 |
|
import org.junit.Test; |
| 28 |
|
import org.xwiki.rendering.block.FormatBlock; |
| 29 |
|
import org.xwiki.rendering.block.GroupBlock; |
| 30 |
|
import org.xwiki.rendering.block.MacroBlock; |
| 31 |
|
import org.xwiki.rendering.block.ParagraphBlock; |
| 32 |
|
import org.xwiki.rendering.block.WordBlock; |
| 33 |
|
import org.xwiki.rendering.block.XDOM; |
| 34 |
|
import org.xwiki.rendering.internal.util.DefaultErrorBlockGenerator; |
| 35 |
|
import org.xwiki.rendering.listener.Format; |
| 36 |
|
import org.xwiki.rendering.util.ErrorBlockGenerator; |
| 37 |
|
import org.xwiki.test.annotation.ComponentList; |
| 38 |
|
import org.xwiki.test.mockito.MockitoComponentManagerRule; |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
@link |
| 42 |
|
|
| 43 |
|
@version |
| 44 |
|
@since |
| 45 |
|
|
| 46 |
|
@ComponentList({ |
| 47 |
|
DefaultErrorBlockGenerator.class |
| 48 |
|
}) |
| |
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 3 |
Complexity Density: 0.27 |
|
| 49 |
|
public class MacroErrorManagerTest |
| 50 |
|
{ |
| 51 |
|
@Rule |
| 52 |
|
public MockitoComponentManagerRule componentManager = new MockitoComponentManagerRule(); |
| 53 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 54 |
1 |
@Test... |
| 55 |
|
public void containsErrorWhenNoError() throws Exception |
| 56 |
|
{ |
| 57 |
1 |
MacroErrorManager errorManager = |
| 58 |
|
new MacroErrorManager(this.componentManager.getInstance(ErrorBlockGenerator.class)); |
| 59 |
1 |
XDOM xdom = new XDOM(Arrays.asList(new ParagraphBlock(Arrays.asList(new WordBlock("test"))))); |
| 60 |
1 |
Assert.assertFalse(errorManager.containsError(xdom)); |
| 61 |
|
} |
| 62 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 63 |
1 |
@Test... |
| 64 |
|
public void containsErrorWhenNoErrorButGroupAndFormatBlocks() throws Exception |
| 65 |
|
{ |
| 66 |
1 |
MacroErrorManager errorManager = |
| 67 |
|
new MacroErrorManager(this.componentManager.getInstance(ErrorBlockGenerator.class)); |
| 68 |
1 |
XDOM xdom = new XDOM(Arrays.asList(new GroupBlock(Arrays.asList( |
| 69 |
|
new FormatBlock(Arrays.asList(new WordBlock("test")), Format.BOLD))))); |
| 70 |
1 |
Assert.assertFalse(errorManager.containsError(xdom)); |
| 71 |
|
} |
| 72 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
| 73 |
1 |
@Test... |
| 74 |
|
public void containsErrorWhenInlineMacroError() throws Exception |
| 75 |
|
{ |
| 76 |
1 |
MacroErrorManager errorManager = |
| 77 |
|
new MacroErrorManager(this.componentManager.getInstance(ErrorBlockGenerator.class)); |
| 78 |
1 |
MacroBlock macroBlock = new MacroBlock("testmacro", Collections.emptyMap(), true); |
| 79 |
1 |
XDOM xdom = new XDOM(Arrays.asList(macroBlock)); |
| 80 |
1 |
errorManager.generateError(macroBlock, "test message", "test description"); |
| 81 |
1 |
Assert.assertTrue(errorManager.containsError(xdom)); |
| 82 |
|
} |
| 83 |
|
} |