1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.model.reference; |
21 |
|
|
22 |
|
import org.junit.Test; |
23 |
|
import org.xwiki.model.EntityType; |
24 |
|
|
25 |
|
import org.junit.Assert; |
26 |
|
|
27 |
|
|
28 |
|
@link |
29 |
|
|
30 |
|
@version |
31 |
|
@since |
32 |
|
|
|
|
| 80% |
Uncovered Elements: 3 (15) |
Complexity: 6 |
Complexity Density: 0.5 |
|
33 |
|
public class AttachmentReferenceTest |
34 |
|
{ |
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
35 |
1 |
@Test... |
36 |
|
public void testInvalidType() |
37 |
|
{ |
38 |
1 |
try { |
39 |
1 |
new AttachmentReference(new EntityReference("filename", EntityType.DOCUMENT)); |
40 |
0 |
Assert.fail("Should have thrown an exception here"); |
41 |
|
} catch (IllegalArgumentException expected) { |
42 |
1 |
Assert.assertEquals("Invalid type [DOCUMENT] for an attachment reference", expected.getMessage()); |
43 |
|
} |
44 |
|
} |
45 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
46 |
1 |
@Test... |
47 |
|
public void testInvalidNullParent() |
48 |
|
{ |
49 |
1 |
try { |
50 |
1 |
new AttachmentReference("filename", null); |
51 |
0 |
Assert.fail("Should have thrown an exception here"); |
52 |
|
} catch (IllegalArgumentException expected) { |
53 |
1 |
Assert.assertEquals("Invalid parent reference [null] in an attachment reference", expected.getMessage()); |
54 |
|
} |
55 |
|
} |
56 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
57 |
1 |
@Test... |
58 |
|
public void testInvalidParentType() |
59 |
|
{ |
60 |
1 |
try { |
61 |
1 |
new AttachmentReference(new EntityReference("filename", EntityType.ATTACHMENT, new WikiReference("wiki"))); |
62 |
0 |
Assert.fail("Should have thrown an exception here"); |
63 |
|
} catch (IllegalArgumentException expected) { |
64 |
1 |
Assert.assertEquals("Invalid parent reference [Wiki wiki] in an attachment reference", |
65 |
|
expected.getMessage()); |
66 |
|
} |
67 |
|
} |
68 |
|
} |