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.syntax; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Before; |
24 |
|
import org.junit.Test; |
25 |
|
import org.xwiki.rendering.parser.ParseException; |
26 |
|
import org.xwiki.rendering.syntax.Syntax; |
27 |
|
import org.xwiki.rendering.syntax.SyntaxFactory; |
28 |
|
import org.xwiki.test.jmock.AbstractComponentTestCase; |
29 |
|
|
30 |
|
|
31 |
|
@link |
32 |
|
|
33 |
|
@version |
34 |
|
|
|
|
| 88.2% |
Uncovered Elements: 2 (17) |
Complexity: 6 |
Complexity Density: 0.46 |
|
35 |
|
public class DefaultSyntaxFactoryTest extends AbstractComponentTestCase |
36 |
|
{ |
37 |
|
private SyntaxFactory syntaxFactory; |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
39 |
3 |
@Before... |
40 |
|
public void configure() throws Exception |
41 |
|
{ |
42 |
3 |
this.syntaxFactory = getComponentManager().getInstance(SyntaxFactory.class); |
43 |
|
} |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
45 |
1 |
@Test... |
46 |
|
public void testCreateSyntaxFromSyntaxIdString() throws Exception |
47 |
|
{ |
48 |
1 |
Syntax syntax = this.syntaxFactory.createSyntaxFromIdString("type/version"); |
49 |
1 |
Assert.assertEquals("type", syntax.getType().getId()); |
50 |
1 |
Assert.assertEquals("type", syntax.getType().getName()); |
51 |
1 |
Assert.assertEquals("version", syntax.getVersion()); |
52 |
|
} |
53 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
54 |
1 |
@Test... |
55 |
|
public void testCreateSyntaxFromSyntaxIdStringWhenInvalid() throws Exception |
56 |
|
{ |
57 |
1 |
try { |
58 |
1 |
this.syntaxFactory.createSyntaxFromIdString("invalid"); |
59 |
0 |
Assert.fail("Should have thrown an exception"); |
60 |
|
} catch (ParseException expected) { |
61 |
1 |
Assert.assertEquals("Invalid Syntax format [invalid]", expected.getMessage()); |
62 |
|
} |
63 |
|
} |
64 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
65 |
1 |
@Test... |
66 |
|
public void testCreateSyntaxFromSyntaxIdStringWhenNull() throws Exception |
67 |
|
{ |
68 |
1 |
try { |
69 |
1 |
this.syntaxFactory.createSyntaxFromIdString(null); |
70 |
0 |
Assert.fail("Should have thrown an exception"); |
71 |
|
} catch (ParseException expected) { |
72 |
1 |
Assert.assertEquals("The passed Syntax cannot be NULL", expected.getMessage()); |
73 |
|
} |
74 |
|
} |
75 |
|
} |