1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.index.tree.test.po; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.openqa.selenium.WebElement; |
26 |
|
import org.xwiki.model.internal.reference.DefaultStringEntityReferenceSerializer; |
27 |
|
import org.xwiki.model.internal.reference.DefaultSymbolScheme; |
28 |
|
import org.xwiki.model.reference.AttachmentReference; |
29 |
|
import org.xwiki.model.reference.DocumentReference; |
30 |
|
import org.xwiki.model.reference.EntityReference; |
31 |
|
import org.xwiki.tree.test.po.TreeElement; |
32 |
|
import org.xwiki.tree.test.po.TreeNodeElement; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
|
|
| 66.1% |
Uncovered Elements: 19 (56) |
Complexity: 21 |
Complexity Density: 0.66 |
|
40 |
|
public class DocumentTreeElement extends TreeElement |
41 |
|
{ |
42 |
|
private DefaultStringEntityReferenceSerializer entityReferenceSerializer = |
43 |
|
new DefaultStringEntityReferenceSerializer(new DefaultSymbolScheme()); |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
6 |
public DocumentTreeElement(WebElement element)... |
51 |
|
{ |
52 |
6 |
super(element); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
5 |
@Override... |
56 |
|
public DocumentTreeElement openTo(String nodeId) |
57 |
|
{ |
58 |
5 |
return (DocumentTreeElement) super.openTo(nodeId); |
59 |
|
} |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
4 |
@Override... |
62 |
|
public DocumentTreeElement clearSelection() |
63 |
|
{ |
64 |
4 |
return (DocumentTreeElement) super.clearSelection(); |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
@param |
71 |
|
@return |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
0 |
public DocumentTreeElement openToSpace(String... path)... |
74 |
|
{ |
75 |
0 |
return openTo(getSpaceNodeId(path)); |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
@param |
82 |
|
@return |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
5 |
public DocumentTreeElement openToDocument(String... path)... |
85 |
|
{ |
86 |
5 |
return openTo(getDocumentNodeId(path)); |
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
@param |
93 |
|
@return |
94 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
95 |
0 |
public DocumentTreeElement openToAttachment(String... path)... |
96 |
|
{ |
97 |
0 |
return openTo(getAttachmentNodeId(path)); |
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
8 |
@Override... |
101 |
|
public DocumentTreeElement waitForIt() |
102 |
|
{ |
103 |
8 |
return (DocumentTreeElement) super.waitForIt(); |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
@param |
110 |
|
@return |
111 |
|
@since |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
1 |
public DocumentTreeElement waitForDocumentSelected(String... path)... |
114 |
|
{ |
115 |
1 |
return (DocumentTreeElement) super.waitForNodeSelected(getDocumentNodeId(path)); |
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
@param |
120 |
|
@return |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
0 |
public boolean hasSpace(String... path)... |
123 |
|
{ |
124 |
0 |
return hasNode(getSpaceNodeId(path)); |
125 |
|
} |
126 |
|
|
127 |
|
|
128 |
|
@param |
129 |
|
@return |
130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
6 |
public boolean hasDocument(String... path)... |
132 |
|
{ |
133 |
6 |
return hasNode(getDocumentNodeId(path)); |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
@param |
138 |
|
@return |
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
140 |
1 |
public boolean hasAttachment(String... path)... |
141 |
|
{ |
142 |
1 |
return hasNode(getAttachmentNodeId(path)); |
143 |
|
} |
144 |
|
|
145 |
|
|
146 |
|
@param |
147 |
|
@return |
148 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
149 |
0 |
public TreeNodeElement getSpaceNode(String... path)... |
150 |
|
{ |
151 |
0 |
return getNode(getSpaceNodeId(path)); |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
@param |
156 |
|
@return |
157 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
158 |
4 |
public TreeNodeElement getDocumentNode(String... path)... |
159 |
|
{ |
160 |
4 |
return getNode(getDocumentNodeId(path)); |
161 |
|
} |
162 |
|
|
163 |
|
|
164 |
|
@param |
165 |
|
@return |
166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
167 |
1 |
public TreeNodeElement getAttachmentNode(String... path)... |
168 |
|
{ |
169 |
1 |
return getNode(getAttachmentNodeId(path)); |
170 |
|
} |
171 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
18 |
private String getNodeId(EntityReference reference)... |
173 |
|
{ |
174 |
18 |
return reference.getType().getLowerCase() + ":" + this.entityReferenceSerializer.serialize(reference); |
175 |
|
} |
176 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
177 |
0 |
private String getSpaceNodeId(String... path)... |
178 |
|
{ |
179 |
0 |
if (path.length > 0) { |
180 |
0 |
DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList(path), "WebHome"); |
181 |
0 |
return getNodeId(documentReference.getParent()); |
182 |
|
} else { |
183 |
0 |
throw new IllegalArgumentException("Incomplete path: it should have at least 1 element (space)"); |
184 |
|
} |
185 |
|
} |
186 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
187 |
16 |
private String getDocumentNodeId(String... path)... |
188 |
|
{ |
189 |
16 |
if (path.length > 1) { |
190 |
16 |
List<String> pathElements = Arrays.asList(path); |
191 |
16 |
List<String> spaces = pathElements.subList(0, path.length - 1); |
192 |
16 |
String document = path[path.length - 1]; |
193 |
16 |
return getNodeId(new DocumentReference("xwiki", spaces, document)); |
194 |
|
} else { |
195 |
0 |
throw new IllegalArgumentException("Incomplete path: it should have at least 2 elements (space/page)"); |
196 |
|
} |
197 |
|
} |
198 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
199 |
2 |
private String getAttachmentNodeId(String... path)... |
200 |
|
{ |
201 |
2 |
if (path.length > 2) { |
202 |
2 |
List<String> pathElements = Arrays.asList(path); |
203 |
2 |
List<String> spaces = pathElements.subList(0, path.length - 2); |
204 |
2 |
String document = path[path.length - 2]; |
205 |
2 |
String fileName = path[path.length - 1]; |
206 |
2 |
return getNodeId(new AttachmentReference(fileName, new DocumentReference("xwiki", spaces, document))); |
207 |
|
} else { |
208 |
0 |
throw new IllegalArgumentException("Incomplete path: it should have at least 3 elements (space/page/file)"); |
209 |
|
} |
210 |
|
} |
211 |
|
} |