1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.objects.classes; |
21 |
|
|
22 |
|
import org.junit.Rule; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.model.reference.DocumentReference; |
25 |
|
|
26 |
|
import com.xpn.xwiki.test.MockitoOldcoreRule; |
27 |
|
import com.xpn.xwiki.test.reference.ReferenceComponentList; |
28 |
|
|
29 |
|
import static org.junit.Assert.*; |
30 |
|
|
31 |
|
|
32 |
|
@link |
33 |
|
|
34 |
|
@version |
35 |
|
|
36 |
|
@ReferenceComponentList |
|
|
| 100% |
Uncovered Elements: 0 (51) |
Complexity: 5 |
Complexity Density: 0.11 |
|
37 |
|
public class BaseClassTest |
38 |
|
{ |
39 |
|
@Rule |
40 |
|
public MockitoOldcoreRule oldcore = new MockitoOldcoreRule(); |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
42 |
1 |
@Test... |
43 |
|
public void setDocumentReference() throws Exception |
44 |
|
{ |
45 |
1 |
BaseClass baseClass = new BaseClass(); |
46 |
|
|
47 |
1 |
DocumentReference reference = new DocumentReference("wiki", "space", "page"); |
48 |
1 |
baseClass.setDocumentReference(reference); |
49 |
|
|
50 |
1 |
assertEquals(reference, baseClass.getDocumentReference()); |
51 |
|
} |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
53 |
1 |
@Test... |
54 |
|
public void setNameSetWiki() throws Exception |
55 |
|
{ |
56 |
1 |
String database = this.oldcore.getXWikiContext().getWikiId(); |
57 |
1 |
BaseClass baseClass = new BaseClass(); |
58 |
|
|
59 |
1 |
baseClass.setName("space.page"); |
60 |
|
|
61 |
1 |
assertEquals(database, baseClass.getDocumentReference().getWikiReference().getName()); |
62 |
1 |
assertEquals("space", baseClass.getDocumentReference().getLastSpaceReference().getName()); |
63 |
1 |
assertEquals("page", baseClass.getDocumentReference().getName()); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
66 |
1 |
@Test... |
67 |
|
public void setNameAloneWithChangingContext() throws Exception |
68 |
|
{ |
69 |
1 |
String database = this.oldcore.getXWikiContext().getWikiId(); |
70 |
1 |
BaseClass baseClass = new BaseClass(); |
71 |
|
|
72 |
1 |
baseClass.setName("space.page"); |
73 |
|
|
74 |
1 |
try { |
75 |
1 |
this.oldcore.getXWikiContext().setWikiId("otherwiki"); |
76 |
|
|
77 |
1 |
assertEquals(database, baseClass.getDocumentReference().getWikiReference().getName()); |
78 |
1 |
assertEquals("space", baseClass.getDocumentReference().getLastSpaceReference().getName()); |
79 |
1 |
assertEquals("page", baseClass.getDocumentReference().getName()); |
80 |
|
|
81 |
1 |
baseClass.setName("otherspace.otherpage"); |
82 |
|
} finally { |
83 |
1 |
this.oldcore.getXWikiContext().setWikiId(database); |
84 |
|
} |
85 |
|
|
86 |
1 |
assertEquals(database, baseClass.getDocumentReference().getWikiReference().getName()); |
87 |
1 |
assertEquals("otherspace", baseClass.getDocumentReference().getLastSpaceReference().getName()); |
88 |
1 |
assertEquals("otherpage", baseClass.getDocumentReference().getName()); |
89 |
|
|
90 |
1 |
baseClass = new BaseClass(); |
91 |
1 |
try { |
92 |
1 |
this.oldcore.getXWikiContext().setWikiId("otherwiki"); |
93 |
1 |
baseClass.setName("space.page"); |
94 |
|
} finally { |
95 |
1 |
this.oldcore.getXWikiContext().setWikiId(database); |
96 |
|
} |
97 |
|
|
98 |
1 |
assertEquals("otherwiki", baseClass.getDocumentReference().getWikiReference().getName()); |
99 |
1 |
assertEquals("space", baseClass.getDocumentReference().getLastSpaceReference().getName()); |
100 |
1 |
assertEquals("page", baseClass.getDocumentReference().getName()); |
101 |
|
|
102 |
1 |
baseClass.setName("otherspace.otherpage"); |
103 |
|
|
104 |
1 |
assertEquals("otherwiki", baseClass.getDocumentReference().getWikiReference().getName()); |
105 |
1 |
assertEquals("otherspace", baseClass.getDocumentReference().getLastSpaceReference().getName()); |
106 |
1 |
assertEquals("otherpage", baseClass.getDocumentReference().getName()); |
107 |
|
} |
108 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
109 |
1 |
@Test... |
110 |
|
public void addTextAreaFieldWhenNullContentType() throws Exception |
111 |
|
{ |
112 |
1 |
BaseClass baseClass = new BaseClass(); |
113 |
|
|
114 |
1 |
TextAreaClass textAreaClass = new TextAreaClass(); |
115 |
1 |
textAreaClass.setName("field"); |
116 |
1 |
textAreaClass.setPrettyName("pretty name"); |
117 |
1 |
textAreaClass.setSize(55); |
118 |
1 |
textAreaClass.setRows(33); |
119 |
1 |
baseClass.put("field", textAreaClass); |
120 |
|
|
121 |
1 |
assertFalse(baseClass.addTextAreaField("field", "pretty name", 55, 33)); |
122 |
|
} |
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
124 |
1 |
@Test... |
125 |
|
public void addTextAreaFieldWhenExistingNumberField() throws Exception |
126 |
|
{ |
127 |
1 |
BaseClass baseClass = new BaseClass(); |
128 |
|
|
129 |
1 |
baseClass.addNumberField("field", "int pretty name", 30, "int"); |
130 |
|
|
131 |
1 |
assertTrue(baseClass.addTextAreaField("field", "pretty name", 55, 33)); |
132 |
|
} |
133 |
|
} |