1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.security.authorization.testwikibuilding; |
21 |
|
|
22 |
|
import java.util.AbstractCollection; |
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Arrays; |
25 |
|
import java.util.Collection; |
26 |
|
import java.util.Collections; |
27 |
|
import java.util.Formatter; |
28 |
|
import java.util.HashMap; |
29 |
|
import java.util.HashSet; |
30 |
|
import java.util.Iterator; |
31 |
|
import java.util.LinkedHashMap; |
32 |
|
import java.util.List; |
33 |
|
import java.util.Map; |
34 |
|
import java.util.Set; |
35 |
|
import java.util.Vector; |
36 |
|
|
37 |
|
import org.jmock.Expectations; |
38 |
|
import org.jmock.Mockery; |
39 |
|
import org.jmock.api.Invocation; |
40 |
|
import org.jmock.lib.action.CustomAction; |
41 |
|
import org.jmock.lib.legacy.ClassImposteriser; |
42 |
|
import org.xwiki.bridge.event.DocumentCreatedEvent; |
43 |
|
import org.xwiki.bridge.event.DocumentDeletedEvent; |
44 |
|
import org.xwiki.bridge.event.DocumentUpdatedEvent; |
45 |
|
import org.xwiki.component.descriptor.DefaultComponentDescriptor; |
46 |
|
import org.xwiki.component.manager.ComponentManager; |
47 |
|
import org.xwiki.model.EntityType; |
48 |
|
import org.xwiki.model.reference.DocumentReference; |
49 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
50 |
|
import org.xwiki.model.reference.EntityReference; |
51 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
52 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
53 |
|
import org.xwiki.model.reference.SpaceReference; |
54 |
|
import org.xwiki.model.reference.WikiReference; |
55 |
|
import org.xwiki.observation.ObservationManager; |
56 |
|
import org.xwiki.security.authorization.Right; |
57 |
|
import org.xwiki.wiki.descriptor.WikiDescriptorManager; |
58 |
|
|
59 |
|
import com.xpn.xwiki.XWiki; |
60 |
|
import com.xpn.xwiki.XWikiContext; |
61 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
62 |
|
import com.xpn.xwiki.objects.BaseObject; |
63 |
|
import com.xpn.xwiki.user.api.XWikiGroupService; |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
@since |
69 |
|
@version |
70 |
|
|
71 |
|
|
|
|
| 70.6% |
Uncovered Elements: 65 (221) |
Complexity: 58 |
Complexity Density: 0.4 |
|
72 |
|
public class LegacyTestWiki extends AbstractTestWiki |
73 |
|
{ |
74 |
|
private final boolean legacymock; |
75 |
|
|
76 |
|
private final XWikiContext context; |
77 |
|
|
78 |
|
private final XWiki xwiki; |
79 |
|
|
80 |
|
private final Mockery mockery; |
81 |
|
|
82 |
|
private final DocumentReferenceResolver<String> documentReferenceResolver; |
83 |
|
|
84 |
|
private final EntityReferenceSerializer<String> entityReferenceSerializer; |
85 |
|
|
86 |
|
private final ObservationManager observationManager; |
87 |
|
|
88 |
|
protected WikiDescriptorManager wikiDescriptorManager; |
89 |
|
|
90 |
|
private final Map<String, TestWiki> wikis = new HashMap<String, TestWiki>(); |
91 |
|
|
92 |
|
|
93 |
|
@param |
94 |
|
@param |
95 |
|
@param |
96 |
|
|
|
|
| 89.3% |
Uncovered Elements: 3 (28) |
Complexity: 4 |
Complexity Density: 0.18 |
|
97 |
18 |
public LegacyTestWiki(Mockery mockery, ComponentManager componentManager, String testWikiFilename,... |
98 |
|
boolean legacymock) throws Exception |
99 |
|
{ |
100 |
18 |
this.legacymock = legacymock; |
101 |
18 |
this.mockery = mockery; |
102 |
|
|
103 |
18 |
this.documentReferenceResolver = componentManager.getInstance(DocumentReferenceResolver.TYPE_STRING); |
104 |
18 |
this.entityReferenceSerializer = componentManager.getInstance(EntityReferenceSerializer.TYPE_STRING); |
105 |
18 |
this.observationManager = componentManager.getInstance(ObservationManager.class); |
106 |
|
|
107 |
18 |
mockery.setImposteriser(ClassImposteriser.INSTANCE); |
108 |
|
|
109 |
18 |
context = new XWikiContext(); |
110 |
|
|
111 |
18 |
xwiki = mockery.mock(XWiki.class); |
112 |
18 |
this.context.setWiki(xwiki); |
113 |
|
|
114 |
18 |
if (!componentManager.hasComponent(WikiDescriptorManager.class)) { |
115 |
18 |
DefaultComponentDescriptor<WikiDescriptorManager> descriptor = new DefaultComponentDescriptor<>(); |
116 |
18 |
descriptor.setRoleType(WikiDescriptorManager.class); |
117 |
18 |
this.wikiDescriptorManager = mockery.mock(WikiDescriptorManager.class); |
118 |
18 |
componentManager.registerComponent(descriptor, this.wikiDescriptorManager); |
119 |
|
} |
120 |
|
|
121 |
18 |
final XWikiGroupService groupService = mockery.mock(XWikiGroupService.class); |
122 |
|
|
123 |
18 |
loadTestWiki(testWikiFilename); |
124 |
|
|
125 |
18 |
if (this.context.getMainXWiki() == null) { |
126 |
0 |
throw new RuntimeException("None of the declared wikis had attribute mainWiki=\"true\"!"); |
127 |
|
} |
128 |
|
|
129 |
18 |
this.context.setWikiId(this.context.getMainXWiki()); |
130 |
|
|
131 |
18 |
mockery.checking(new Expectations() |
132 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
|
133 |
18 |
{... |
134 |
|
|
135 |
|
|
136 |
18 |
allowing(xwiki).getDatabase(); |
137 |
18 |
will(returnValue(context.getMainXWiki())); |
138 |
18 |
allowing(xwiki).isReadOnly(); |
139 |
18 |
will(new CustomAction("indicate wether the wiki is read only") |
140 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
71 |
@Override... |
142 |
|
public Object invoke(Invocation invocation) |
143 |
|
{ |
144 |
71 |
return isReadOnly(context.getWikiId()); |
145 |
|
} |
146 |
|
}); |
147 |
18 |
allowing(xwiki).getMaxRecursiveSpaceChecks(with(any(XWikiContext.class))); |
148 |
18 |
will(returnValue(100)); |
149 |
18 |
allowing(xwiki).getDocument(with(any(DocumentReference.class)), with(any(XWikiContext.class))); |
150 |
18 |
will(new CustomAction("return a mocked document") |
151 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
152 |
99 |
@Override... |
153 |
|
public Object invoke(Invocation invocation) |
154 |
|
{ |
155 |
99 |
DocumentReference documentReference = (DocumentReference) invocation.getParameter(0); |
156 |
99 |
return getDocument(documentReference); |
157 |
|
} |
158 |
|
}); |
159 |
18 |
allowing(xwiki).getDocument(with(any(EntityReference.class)), with(any(XWikiContext.class))); |
160 |
18 |
will(new CustomAction("return a mocked document") |
161 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
162 |
68 |
@Override... |
163 |
|
public Object invoke(Invocation invocation) |
164 |
|
{ |
165 |
68 |
EntityReference documentReference = (EntityReference) invocation.getParameter(0); |
166 |
68 |
return getDocument(documentReference, (XWikiContext) invocation.getParameter(1)); |
167 |
|
} |
168 |
|
}); |
169 |
18 |
allowing(xwiki).getWikiOwner(with(aNonNull(String.class)), with(any(XWikiContext.class))); |
170 |
18 |
will(new CustomAction("return the wiki owner") |
171 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
172 |
88 |
@Override... |
173 |
|
public Object invoke(Invocation invocation) |
174 |
|
{ |
175 |
88 |
String wikiName = (String) invocation.getParameter(0); |
176 |
88 |
TestWiki wiki = wikis.get(wikiName); |
177 |
88 |
return wiki.getOwner(); |
178 |
|
} |
179 |
|
}); |
180 |
18 |
allowing(xwiki).getGroupService(with(any(XWikiContext.class))); |
181 |
18 |
will(returnValue(groupService)); |
182 |
|
|
183 |
|
|
184 |
|
|
185 |
18 |
allowing(groupService).getAllGroupsReferencesForMember(with(any(DocumentReference.class)), |
186 |
|
with(any(Integer.class)), with(any(Integer.class)), with(any(XWikiContext.class))); |
187 |
18 |
will(new CustomAction("return a collection of member profile document references") |
188 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
189 |
64 |
@Override... |
190 |
|
public Object invoke(Invocation invocation) |
191 |
|
{ |
192 |
64 |
return getAllGroupReferences((DocumentReference) invocation.getParameter(0)); |
193 |
|
} |
194 |
|
}); |
195 |
|
|
196 |
|
|
197 |
18 |
allowing(wikiDescriptorManager).getCurrentWikiId(); |
198 |
18 |
will(new CustomAction("get the current wiki id") |
199 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
200 |
136 |
@Override... |
201 |
|
public Object invoke(Invocation invocation) |
202 |
|
{ |
203 |
136 |
return context.getWikiId(); |
204 |
|
} |
205 |
|
}); |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
18 |
allowing(xwiki).getXWikiPreference(with(any(String.class)), with(equal("")), |
210 |
|
with(any(XWikiContext.class))); |
211 |
18 |
will(returnValue("false")); |
212 |
18 |
allowing(xwiki).getXWikiPreferenceAsInt(with(any(String.class)), with(0), |
213 |
|
with(any(XWikiContext.class))); |
214 |
18 |
will(returnValue(0)); |
215 |
18 |
allowing(xwiki).getSpacePreference(with(any(String.class)), with(equal("")), |
216 |
|
with(any(XWikiContext.class))); |
217 |
18 |
will(returnValue("false")); |
218 |
18 |
allowing(xwiki).getSpacePreferenceAsInt(with(any(String.class)), with(0), |
219 |
|
with(any(XWikiContext.class))); |
220 |
18 |
will(returnValue(0)); |
221 |
|
|
222 |
|
} |
223 |
|
}); |
224 |
|
|
225 |
18 |
if (legacymock) { |
226 |
10 |
mockery.checking(new Expectations() |
227 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
228 |
10 |
{... |
229 |
10 |
allowing(xwiki).getDocument(with(any(String.class)), with(any(XWikiContext.class))); |
230 |
10 |
will(new CustomAction("return a mocked document") |
231 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
232 |
32 |
@Override... |
233 |
|
public Object invoke(Invocation invocation) |
234 |
|
{ |
235 |
32 |
String documentName = (String) invocation.getParameter(0); |
236 |
32 |
return getDocument(documentName); |
237 |
|
} |
238 |
|
}); |
239 |
10 |
allowing(xwiki).getDocument(with(any(String.class)), with(any(String.class)), |
240 |
|
with(any(XWikiContext.class))); |
241 |
10 |
will(new CustomAction("return a mocked document") |
242 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
243 |
58 |
@Override... |
244 |
|
public Object invoke(Invocation invocation) |
245 |
|
{ |
246 |
58 |
String spaceName = (String) invocation.getParameter(0); |
247 |
58 |
String documentName = (String) invocation.getParameter(1); |
248 |
58 |
return getDocument(spaceName, documentName); |
249 |
|
} |
250 |
|
}); |
251 |
|
} |
252 |
|
}); |
253 |
|
} |
254 |
|
|
255 |
|
} |
256 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
257 |
0 |
public String getMainWikiName()... |
258 |
|
{ |
259 |
0 |
return context.getMainXWiki(); |
260 |
|
} |
261 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
262 |
26 |
@Override... |
263 |
|
public HasWikiContents addWiki(String name, String owner, boolean isMainWiki, boolean isReadOnly, String alt) |
264 |
|
{ |
265 |
|
|
266 |
26 |
if (isMainWiki) { |
267 |
18 |
if (context.getMainXWiki() != null) { |
268 |
0 |
throw new RuntimeException("Only one wiki can be the main wiki!"); |
269 |
|
} |
270 |
|
|
271 |
18 |
context.setMainXWiki(name); |
272 |
|
} |
273 |
|
|
274 |
26 |
return mockWiki(name, owner, isReadOnly, isMainWiki, alt); |
275 |
|
} |
276 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
277 |
4 |
public void setUser(String username)... |
278 |
|
{ |
279 |
4 |
context.setUser(username); |
280 |
|
} |
281 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
282 |
34 |
public WikiReference getCurrentWikiReference()... |
283 |
|
{ |
284 |
34 |
String currentWikiId = this.context.getWikiId(); |
285 |
|
|
286 |
34 |
return currentWikiId != null ? new WikiReference(currentWikiId) : null; |
287 |
|
} |
288 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
289 |
1 |
public void setSdoc(String sdocFullname)... |
290 |
|
{ |
291 |
1 |
XWikiDocument sdoc; |
292 |
1 |
if (sdocFullname != null) { |
293 |
0 |
sdoc = new XWikiDocument(this.documentReferenceResolver.resolve(sdocFullname, getCurrentWikiReference())); |
294 |
|
} else { |
295 |
1 |
sdoc = null; |
296 |
|
} |
297 |
|
|
298 |
1 |
setSdoc(sdoc); |
299 |
|
} |
300 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
301 |
2 |
public void setSdoc(XWikiDocument sdoc)... |
302 |
|
{ |
303 |
2 |
this.context.put("sdoc", sdoc); |
304 |
|
} |
305 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
306 |
2 |
public void setDoc(String docFullname)... |
307 |
|
{ |
308 |
2 |
XWikiDocument doc; |
309 |
2 |
if (docFullname != null) { |
310 |
2 |
doc = new XWikiDocument(this.documentReferenceResolver.resolve(docFullname, getCurrentWikiReference())); |
311 |
|
} else { |
312 |
0 |
doc = null; |
313 |
|
} |
314 |
|
|
315 |
2 |
this.context.setDoc(doc); |
316 |
|
} |
317 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
318 |
26 |
private TestWiki mockWiki(String name, String owner, boolean isReadOnly, boolean isMainWiki, String alt)... |
319 |
|
{ |
320 |
26 |
TestWiki wiki = wikis.get(name); |
321 |
|
|
322 |
26 |
if (wiki == null) { |
323 |
26 |
wiki = new TestWiki(name, owner, isReadOnly, isMainWiki, alt); |
324 |
26 |
wikis.put(name, wiki); |
325 |
|
} |
326 |
|
|
327 |
26 |
return wiki; |
328 |
|
} |
329 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
330 |
64 |
private Collection<DocumentReference> getAllGroupReferences(final DocumentReference userReference)... |
331 |
|
{ |
332 |
64 |
final TestWiki wiki = wikis.get(context.getWikiId()); |
333 |
|
|
334 |
64 |
if (wiki == null) { |
335 |
0 |
return Collections.<DocumentReference>emptySet(); |
336 |
|
} |
337 |
|
|
338 |
64 |
final Collection<String> groupNames = wiki.getGroupsForUser(userReference); |
339 |
|
|
340 |
64 |
final SpaceReference userSpaceReference = new SpaceReference("XWiki", new WikiReference(wiki.getName())); |
341 |
|
|
342 |
64 |
return new AbstractCollection<DocumentReference>() |
343 |
|
{ |
344 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
345 |
23 |
@Override... |
346 |
|
public int size() |
347 |
|
{ |
348 |
23 |
return groupNames.size(); |
349 |
|
} |
350 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
351 |
64 |
@Override... |
352 |
|
public Iterator<DocumentReference> iterator() |
353 |
|
{ |
354 |
64 |
return new Iterator<DocumentReference>() |
355 |
|
{ |
356 |
|
|
357 |
|
private final Iterator<String> groupNamesIterator = groupNames.iterator(); |
358 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
359 |
80 |
@Override... |
360 |
|
public boolean hasNext() |
361 |
|
{ |
362 |
80 |
return groupNamesIterator.hasNext(); |
363 |
|
} |
364 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
365 |
16 |
@Override... |
366 |
|
public DocumentReference next() |
367 |
|
{ |
368 |
16 |
String groupName = groupNamesIterator.next(); |
369 |
|
|
370 |
16 |
return documentReferenceResolver.resolve(groupName, userSpaceReference); |
371 |
|
} |
372 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
373 |
0 |
@Override... |
374 |
|
public void remove() |
375 |
|
{ |
376 |
0 |
throw new UnsupportedOperationException(); |
377 |
|
} |
378 |
|
}; |
379 |
|
} |
380 |
|
}; |
381 |
|
} |
382 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
383 |
28 |
@Override... |
384 |
|
public XWikiContext getXWikiContext() |
385 |
|
{ |
386 |
28 |
return context; |
387 |
|
} |
388 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
389 |
71 |
public boolean isReadOnly(String wikiName)... |
390 |
|
{ |
391 |
71 |
return wikis.get(wikiName).isReadOnly(); |
392 |
|
} |
393 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
394 |
0 |
public String getWikiPrettyName(WikiReference wikiReference)... |
395 |
|
{ |
396 |
0 |
TestWiki wiki = wikis.get(wikiReference.getName()); |
397 |
|
|
398 |
0 |
return (wiki != null) ? wiki.getPrettyName() : wikiReference.getName(); |
399 |
|
} |
400 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
401 |
0 |
public String getSpacePrettyName(SpaceReference spaceReference)... |
402 |
|
{ |
403 |
0 |
TestWiki wiki = wikis.get(spaceReference.getParent().getName()); |
404 |
|
|
405 |
0 |
if (wiki == null) { |
406 |
0 |
return null; |
407 |
|
} |
408 |
|
|
409 |
0 |
TestSpace space = wiki.getTestSpace(spaceReference.getName()); |
410 |
|
|
411 |
0 |
return (space != null) ? space.getPrettyName() : spaceReference.getName(); |
412 |
|
} |
413 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
414 |
0 |
public String getDocumentPrettyName(DocumentReference documentReference)... |
415 |
|
{ |
416 |
0 |
TestWiki wiki = wikis.get(documentReference.getWikiReference().getName()); |
417 |
|
|
418 |
0 |
if (wiki == null) { |
419 |
0 |
return null; |
420 |
|
} |
421 |
|
|
422 |
0 |
TestDocument doc = wiki.getTestDocument(documentReference.getParent().getName(), documentReference.getName()); |
423 |
|
|
424 |
0 |
return (doc != null) ? doc.getPrettyName() : documentReference.getName(); |
425 |
|
} |
426 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
427 |
167 |
private XWikiDocument getDocument(DocumentReference documentReference)... |
428 |
|
{ |
429 |
167 |
TestWiki wiki = wikis.get(documentReference.getWikiReference().getName()); |
430 |
167 |
return wiki.getDocument(documentReference); |
431 |
|
} |
432 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
433 |
68 |
private XWikiDocument getDocument(EntityReference entityReference, XWikiContext context)... |
434 |
|
{ |
435 |
68 |
return getDocument(new DocumentReference(entityReference.appendParent(new WikiReference(context.getWikiId())))); |
436 |
|
} |
437 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
438 |
32 |
private XWikiDocument getDocument(String name)... |
439 |
|
{ |
440 |
32 |
DocumentReference documentReference = documentReferenceResolver.resolve(name, getCurrentWikiReference()); |
441 |
|
|
442 |
32 |
TestWiki wiki = wikis.get(documentReference.getWikiReference().getName()); |
443 |
|
|
444 |
32 |
if (wiki == null) { |
445 |
0 |
return null; |
446 |
|
} |
447 |
|
|
448 |
32 |
return wiki.getDocument(documentReference); |
449 |
|
} |
450 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
451 |
58 |
private XWikiDocument getDocument(String spaceName, String documentName)... |
452 |
|
{ |
453 |
58 |
DocumentReference documentReference = new DocumentReference(this.context.getWikiId(), spaceName, documentName); |
454 |
|
|
455 |
58 |
TestWiki wiki = wikis.get(documentReference.getWikiReference().getName()); |
456 |
|
|
457 |
58 |
if (wiki == null) { |
458 |
0 |
return null; |
459 |
|
} |
460 |
|
|
461 |
58 |
return wiki.getDocument(documentReference); |
462 |
|
} |
463 |
|
|
|
|
| 62.9% |
Uncovered Elements: 53 (143) |
Complexity: 40 |
Complexity Density: 0.44 |
|
464 |
|
private class TestWiki extends TestAcl implements HasWikiContents |
465 |
|
{ |
466 |
|
private final SpaceReference userSpaceReference; |
467 |
|
|
468 |
|
private final String name; |
469 |
|
|
470 |
|
private final String owner; |
471 |
|
|
472 |
|
private final String alt; |
473 |
|
|
474 |
|
private final Map<String, TestSpace> spaces = new HashMap<String, TestSpace>(); |
475 |
|
|
476 |
|
private final Set<String> users = new HashSet<String>(); |
477 |
|
|
478 |
|
private final Map<String, Set<String>> groups = new HashMap<String, Set<String>>(); |
479 |
|
|
480 |
|
private final Map<String, Set<String>> groupsForUser = new HashMap<String, Set<String>>(); |
481 |
|
|
482 |
|
private final boolean isReadOnly; |
483 |
|
|
484 |
|
private final boolean isMainWiki; |
485 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
486 |
0 |
TestWiki(String name, String owner, boolean isReadOnly)... |
487 |
|
{ |
488 |
0 |
this(name, owner, isReadOnly, false); |
489 |
|
} |
490 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
491 |
0 |
TestWiki(String name, String owner, boolean isReadOnly, boolean isMainWiki)... |
492 |
|
{ |
493 |
0 |
this(name, owner, isReadOnly, isMainWiki, null); |
494 |
|
} |
495 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
496 |
26 |
TestWiki(String name, String owner, boolean isReadOnly, boolean isMainWiki, String alt)... |
497 |
|
{ |
498 |
26 |
this.name = name; |
499 |
26 |
this.owner = owner; |
500 |
26 |
this.isReadOnly = isReadOnly; |
501 |
26 |
this.isMainWiki = isMainWiki; |
502 |
26 |
this.alt = alt; |
503 |
26 |
this.userSpaceReference = new SpaceReference("XWiki", new WikiReference(name)); |
504 |
|
|
505 |
|
|
506 |
|
|
507 |
26 |
mockDocument("XWiki", "XWikiPreferences", "XWiki.Admin", false); |
508 |
|
} |
509 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
510 |
22 |
@Override... |
511 |
|
public HasDocuments addSpace(String name, String alt) |
512 |
|
{ |
513 |
22 |
return mockSpace(name, alt); |
514 |
|
} |
515 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
516 |
26 |
TestDocument mockDocument(String spaceName, String name, String creator, boolean isNew)... |
517 |
|
{ |
518 |
26 |
TestSpace space = mockSpace(spaceName); |
519 |
|
|
520 |
26 |
return space.mockDocument(name, creator, isNew, alt); |
521 |
|
} |
522 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
523 |
306 |
TestSpace mockSpace(String name)... |
524 |
|
{ |
525 |
306 |
return mockSpace(name, null); |
526 |
|
} |
527 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
528 |
328 |
TestSpace mockSpace(String name, String alt)... |
529 |
|
{ |
530 |
328 |
TestSpace space = spaces.get(name); |
531 |
|
|
532 |
328 |
if (space == null) { |
533 |
42 |
space = new TestSpace(name, this, alt); |
534 |
42 |
spaces.put(name, space); |
535 |
|
} |
536 |
|
|
537 |
328 |
return space; |
538 |
|
} |
539 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
540 |
0 |
XWikiDocument removeDocument(DocumentReference documentReference)... |
541 |
|
{ |
542 |
0 |
return removeDocument(documentReference.getParent().getName(), documentReference.getName()); |
543 |
|
} |
544 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
545 |
1 |
XWikiDocument removeDocument(String spaceName, String documentName)... |
546 |
|
{ |
547 |
1 |
TestSpace space = mockSpace(spaceName); |
548 |
|
|
549 |
1 |
return space.removeDocument(documentName); |
550 |
|
} |
551 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
552 |
257 |
XWikiDocument getDocument(DocumentReference documentReference)... |
553 |
|
{ |
554 |
257 |
TestSpace space = mockSpace(documentReference.getParent().getName()); |
555 |
|
|
556 |
257 |
return space.getDocument(documentReference); |
557 |
|
} |
558 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
559 |
0 |
TestSpace getTestSpace(String spaceName)... |
560 |
|
{ |
561 |
0 |
if (spaces.containsKey(spaceName)) { |
562 |
0 |
TestSpace space = mockSpace(spaceName); |
563 |
|
|
564 |
0 |
return space; |
565 |
|
} |
566 |
|
|
567 |
0 |
return null; |
568 |
|
} |
569 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
570 |
1 |
TestDocument getTestDocument(String spaceName, String documentName)... |
571 |
|
{ |
572 |
1 |
if (spaces.containsKey(spaceName)) { |
573 |
1 |
TestSpace space = mockSpace(spaceName); |
574 |
|
|
575 |
1 |
return space.getTestDocument(documentName); |
576 |
|
} |
577 |
|
|
578 |
0 |
return null; |
579 |
|
} |
580 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
581 |
0 |
@Override... |
582 |
|
EntityType getType() |
583 |
|
{ |
584 |
0 |
if (isMainWiki) { |
585 |
0 |
return null; |
586 |
|
} else { |
587 |
0 |
return EntityType.WIKI; |
588 |
|
} |
589 |
|
} |
590 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
591 |
669 |
@Override... |
592 |
|
String getName() |
593 |
|
{ |
594 |
669 |
return name; |
595 |
|
} |
596 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
597 |
0 |
@Override... |
598 |
|
String getPrettyName() |
599 |
|
{ |
600 |
0 |
return (this.alt != null) ? this.alt : this.name; |
601 |
|
} |
602 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
603 |
88 |
String getOwner()... |
604 |
|
{ |
605 |
88 |
return owner; |
606 |
|
} |
607 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
608 |
71 |
public boolean isReadOnly()... |
609 |
|
{ |
610 |
71 |
return isReadOnly; |
611 |
|
} |
612 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
613 |
0 |
Collection<String> getGroupsForUser(String userName)... |
614 |
|
{ |
615 |
0 |
DocumentReference userDoc = documentReferenceResolver.resolve(userName, userSpaceReference); |
616 |
0 |
return getGroupsForUser(userDoc); |
617 |
|
} |
618 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
619 |
64 |
Collection<String> getGroupsForUser(DocumentReference userDoc)... |
620 |
|
{ |
621 |
64 |
Set<String> groups; |
622 |
64 |
if (userDoc.getWikiReference().getName().equals(getName())) { |
623 |
43 |
groups = groupsForUser.get(userDoc.getName()); |
624 |
|
} else { |
625 |
21 |
groups = groupsForUser.get(entityReferenceSerializer.serialize(userDoc)); |
626 |
|
} |
627 |
|
|
628 |
64 |
return groups == null ? Collections.<String>emptySet() : groups; |
629 |
|
} |
630 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
631 |
21 |
void notifyCreatedDocument(XWikiDocument document)... |
632 |
|
{ |
633 |
|
|
634 |
|
|
635 |
21 |
if (context.getMainXWiki() == null) { |
636 |
0 |
observationManager.notify(new DocumentCreatedEvent(document.getDocumentReference()), document, context); |
637 |
|
} |
638 |
|
} |
639 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
640 |
1 |
void notifyDeleteDocument(XWikiDocument document)... |
641 |
|
{ |
642 |
1 |
XWikiDocument newDocument = new XWikiDocument(document.getDocumentReference()); |
643 |
1 |
newDocument.setOriginalDocument(document); |
644 |
|
|
645 |
|
|
646 |
1 |
observationManager.notify(new DocumentDeletedEvent(newDocument.getDocumentReference()), newDocument, |
647 |
|
context); |
648 |
|
} |
649 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
650 |
16 |
@Override... |
651 |
|
public void addUser(String userName) |
652 |
|
{ |
653 |
16 |
DocumentReference userDoc = documentReferenceResolver.resolve(userName, userSpaceReference); |
654 |
16 |
users.add(userDoc.getName()); |
655 |
16 |
if (groupsForUser.get(userDoc.getName()) == null) { |
656 |
16 |
groupsForUser.put(userDoc.getName(), new HashSet<String>()); |
657 |
|
} |
658 |
|
|
659 |
16 |
TestSpace testSpace = mockSpace(userDoc.getParent().getName()); |
660 |
|
|
661 |
16 |
UserTestDocument userTestDocument = new UserTestDocument(userDoc.getName(), testSpace, null, false); |
662 |
|
|
663 |
16 |
testSpace.documents.put(userDoc.getName(), userTestDocument); |
664 |
|
|
665 |
|
|
666 |
16 |
notifyCreatedDocument(userTestDocument.getDocument()); |
667 |
|
} |
668 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
669 |
1 |
void deleteUser(String userName)... |
670 |
|
{ |
671 |
1 |
DocumentReference userDoc = documentReferenceResolver.resolve(userName, userSpaceReference); |
672 |
1 |
if (users.contains(userDoc.getName())) { |
673 |
1 |
users.remove(userDoc.getName()); |
674 |
1 |
groupsForUser.remove(userDoc.getName()); |
675 |
1 |
for (Map.Entry<String, Set<String>> entry : groups.entrySet()) { |
676 |
1 |
entry.getValue().remove(userDoc.getName()); |
677 |
1 |
((GroupTestDocument) getTestDocument(userDoc.getParent().getName(), entry.getKey())) |
678 |
|
.removeUser(userDoc.getName()); |
679 |
|
} |
680 |
|
|
681 |
|
|
682 |
1 |
XWikiDocument userDocument = removeDocument(userDoc.getParent().getName(), userDoc.getName()); |
683 |
|
|
684 |
|
|
685 |
1 |
notifyDeleteDocument(userDocument); |
686 |
|
} |
687 |
|
} |
688 |
|
|
|
|
| 91.7% |
Uncovered Elements: 1 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
689 |
5 |
@Override... |
690 |
|
public GroupTestDocument addGroup(final String groupName) |
691 |
|
{ |
692 |
5 |
DocumentReference groupDoc = documentReferenceResolver.resolve(groupName, userSpaceReference); |
693 |
5 |
Set<String> groupMembers = groups.get(groupDoc.getName()); |
694 |
|
|
695 |
5 |
if (groupMembers == null) { |
696 |
5 |
groupMembers = new HashSet<String>(); |
697 |
5 |
groups.put(groupDoc.getName(), groupMembers); |
698 |
|
} |
699 |
|
|
700 |
5 |
TestSpace testSpace = mockSpace(groupDoc.getParent().getName()); |
701 |
|
|
702 |
5 |
GroupTestDocument groupTestDocument = new GroupTestDocument(groupDoc.getName(), testSpace, null, false); |
703 |
|
|
704 |
5 |
testSpace.documents.put(groupDoc.getName(), groupTestDocument); |
705 |
|
|
706 |
|
|
707 |
5 |
notifyCreatedDocument(groupTestDocument.getDocument()); |
708 |
|
|
709 |
5 |
return groupTestDocument; |
710 |
|
} |
711 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
712 |
0 |
void deleteGroup(String groupName)... |
713 |
|
{ |
714 |
0 |
DocumentReference groupDoc = documentReferenceResolver.resolve(groupName, userSpaceReference); |
715 |
0 |
if (groups.containsKey(groupDoc.getName())) { |
716 |
0 |
groups.remove(groupDoc.getName()); |
717 |
0 |
for (Set<String> groups : groupsForUser.values()) { |
718 |
0 |
groups.remove(groupDoc.getName()); |
719 |
|
} |
720 |
|
|
721 |
|
|
722 |
0 |
XWikiDocument groupDocument = removeDocument(groupDoc.getParent().getName(), groupDoc.getName()); |
723 |
|
|
724 |
|
|
725 |
0 |
notifyDeleteDocument(groupDocument); |
726 |
|
} |
727 |
|
} |
728 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
729 |
0 |
TestDocument addDocument(DocumentReference documentReference, String creator, boolean isNew)... |
730 |
|
{ |
731 |
0 |
TestDocument document = mockDocument(documentReference.getParent().getName(), creator, creator, isNew); |
732 |
|
|
733 |
|
|
734 |
0 |
notifyCreatedDocument(document.getDocument()); |
735 |
|
|
736 |
0 |
return document; |
737 |
|
} |
738 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
739 |
0 |
void deleteDocument(DocumentReference documentReference)... |
740 |
|
{ |
741 |
0 |
XWikiDocument document = removeDocument(documentReference); |
742 |
|
|
743 |
0 |
if (document != null) { |
744 |
|
|
745 |
0 |
notifyDeleteDocument(document); |
746 |
|
} |
747 |
|
} |
748 |
|
} |
749 |
|
|
|
|
| 72.7% |
Uncovered Elements: 12 (44) |
Complexity: 16 |
Complexity Density: 0.67 |
|
750 |
|
private class TestSpace extends TestAcl implements HasDocuments |
751 |
|
{ |
752 |
|
private final String name; |
753 |
|
|
754 |
|
private final String alt; |
755 |
|
|
756 |
|
private final TestWiki wiki; |
757 |
|
|
758 |
|
private final Map<String, TestDocument> documents = new HashMap<String, TestDocument>(); |
759 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
760 |
0 |
TestSpace(String name, TestWiki wiki)... |
761 |
|
{ |
762 |
0 |
this(name, wiki, null); |
763 |
|
} |
764 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
765 |
42 |
TestSpace(String name, TestWiki wiki, String alt)... |
766 |
|
{ |
767 |
42 |
this.name = name; |
768 |
42 |
this.alt = alt; |
769 |
42 |
this.wiki = wiki; |
770 |
|
} |
771 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
772 |
24 |
@Override... |
773 |
|
public HasAcl addDocument(String name, String creator, String alt) |
774 |
|
{ |
775 |
24 |
return mockDocument(name, creator, false, alt); |
776 |
|
} |
777 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
778 |
1 |
@Override... |
779 |
|
public XWikiDocument removeDocument(String name) |
780 |
|
{ |
781 |
1 |
TestDocument document = documents.get(name); |
782 |
|
|
783 |
1 |
if (document == null) { |
784 |
0 |
return null; |
785 |
|
} |
786 |
|
|
787 |
1 |
return document.getDocument(); |
788 |
|
} |
789 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
790 |
257 |
TestDocument mockDocument(String name, String creator, boolean isNew)... |
791 |
|
{ |
792 |
257 |
return mockDocument(name, creator, isNew, null); |
793 |
|
} |
794 |
|
|
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
795 |
307 |
TestDocument mockDocument(String name, String creator, boolean isNew, String alt)... |
796 |
|
{ |
797 |
307 |
TestDocument document = getTestDocument(name); |
798 |
|
|
799 |
307 |
if (document == null) { |
800 |
76 |
if (creator == null) { |
801 |
0 |
creator = "XWiki.Admin"; |
802 |
|
} |
803 |
76 |
document = new TestDocument(name, this, creator, isNew, alt); |
804 |
76 |
documents.put(name, document); |
805 |
|
} |
806 |
|
|
807 |
307 |
return document; |
808 |
|
} |
809 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
810 |
257 |
XWikiDocument getDocument(DocumentReference documentReference)... |
811 |
|
{ |
812 |
257 |
TestDocument document = mockDocument(documentReference.getName(), context.getUser(), true); |
813 |
|
|
814 |
257 |
return document.getDocument(); |
815 |
|
} |
816 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
817 |
308 |
public TestDocument getTestDocument(String name)... |
818 |
|
{ |
819 |
308 |
return documents.get(name); |
820 |
|
} |
821 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
822 |
0 |
@Override... |
823 |
|
EntityType getType() |
824 |
|
{ |
825 |
0 |
return EntityType.SPACE; |
826 |
|
} |
827 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
828 |
254 |
@Override... |
829 |
|
String getName() |
830 |
|
{ |
831 |
254 |
return name; |
832 |
|
} |
833 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
834 |
0 |
@Override... |
835 |
|
String getPrettyName() |
836 |
|
{ |
837 |
0 |
return (this.alt != null) ? this.alt : this.name; |
838 |
|
} |
839 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
840 |
496 |
TestWiki getWiki()... |
841 |
|
{ |
842 |
496 |
return wiki; |
843 |
|
} |
844 |
|
} |
845 |
|
|
|
|
| 68.4% |
Uncovered Elements: 6 (19) |
Complexity: 6 |
Complexity Density: 0.46 |
|
846 |
|
private class UserTestDocument extends TestDocument |
847 |
|
{ |
848 |
|
private BaseObject userObject; |
849 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
850 |
16 |
UserTestDocument(String name, TestSpace space, String creator, Boolean isNew)... |
851 |
|
{ |
852 |
16 |
this(name, space, creator, isNew, null); |
853 |
|
} |
854 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
855 |
16 |
UserTestDocument(String name, TestSpace space, String creator, Boolean isNew, String alt)... |
856 |
|
{ |
857 |
16 |
super(name, space, creator, isNew, alt); |
858 |
|
|
859 |
16 |
this.userObject = mockUserBaseObject(); |
860 |
|
|
861 |
16 |
mockery.checking(new Expectations() |
862 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
863 |
16 |
{... |
864 |
16 |
allowing(mockedDocument).getXObject(with(equal(new LocalDocumentReference("XWiki", "XWikiUsers")))); |
865 |
16 |
will(new CustomAction("return the user object") |
866 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
867 |
0 |
@Override... |
868 |
|
public Object invoke(Invocation invocation) |
869 |
|
{ |
870 |
0 |
return userObject; |
871 |
|
} |
872 |
|
}); |
873 |
|
} |
874 |
|
}); |
875 |
|
} |
876 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
877 |
16 |
private BaseObject mockUserBaseObject()... |
878 |
|
{ |
879 |
16 |
++objectNumber; |
880 |
|
|
881 |
16 |
final BaseObject userBaseObject = mockery.mock(BaseObject.class, getName() + objectNumber); |
882 |
|
|
883 |
16 |
return userBaseObject; |
884 |
|
} |
885 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
886 |
0 |
@Override... |
887 |
|
public Map<DocumentReference, List<BaseObject>> getLegacyXObjects() |
888 |
|
{ |
889 |
0 |
Map<DocumentReference, List<BaseObject>> xobjects = super.getLegacyXObjects(); |
890 |
|
|
891 |
0 |
xobjects.put(new DocumentReference(this.space.wiki.getName(), "XWiki", "XWikiUsers"), |
892 |
|
Arrays.asList(this.userObject)); |
893 |
|
|
894 |
0 |
return xobjects; |
895 |
|
} |
896 |
|
} |
897 |
|
|
|
|
| 82.6% |
Uncovered Elements: 8 (46) |
Complexity: 11 |
Complexity Density: 0.34 |
|
898 |
|
private class GroupTestDocument extends TestDocument implements HasUsers |
899 |
|
{ |
900 |
|
private Map<String, BaseObject> memberObjects = new LinkedHashMap<String, BaseObject>(); |
901 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
902 |
5 |
GroupTestDocument(String name, TestSpace space, String creator, Boolean isNew)... |
903 |
|
{ |
904 |
5 |
this(name, space, creator, isNew, null); |
905 |
|
} |
906 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
907 |
5 |
GroupTestDocument(String name, TestSpace space, String creator, Boolean isNew, String alt)... |
908 |
|
{ |
909 |
5 |
super(name, space, creator, isNew, alt); |
910 |
|
|
911 |
5 |
mockery.checking(new Expectations() |
912 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
913 |
5 |
{... |
914 |
5 |
allowing(mockedDocument) |
915 |
|
.getXObjects(with(equal(new LocalDocumentReference("XWiki", "XWikiGroups")))); |
916 |
5 |
will(new CustomAction("return a vector of group members") |
917 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
918 |
0 |
@Override... |
919 |
|
public Object invoke(Invocation invocation) |
920 |
|
{ |
921 |
0 |
return new Vector<BaseObject>(memberObjects.values()); |
922 |
|
} |
923 |
|
}); |
924 |
|
} |
925 |
|
}); |
926 |
|
} |
927 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
928 |
6 |
private BaseObject mockGroupBaseObject(String user)... |
929 |
|
{ |
930 |
6 |
++objectNumber; |
931 |
|
|
932 |
6 |
final BaseObject userBaseObject = mockery.mock(BaseObject.class, getName() + objectNumber); |
933 |
|
|
934 |
6 |
return userBaseObject; |
935 |
|
} |
936 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
937 |
0 |
@Override... |
938 |
|
public Map<DocumentReference, List<BaseObject>> getLegacyXObjects() |
939 |
|
{ |
940 |
0 |
Map<DocumentReference, List<BaseObject>> xobjects = super.getLegacyXObjects(); |
941 |
|
|
942 |
0 |
xobjects.put(new DocumentReference(this.space.wiki.getName(), "XWiki", "XWikiUsers"), |
943 |
|
new ArrayList<BaseObject>(this.memberObjects.values())); |
944 |
|
|
945 |
0 |
return xobjects; |
946 |
|
} |
947 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 3 |
Complexity Density: 0.23 |
|
948 |
6 |
@Override... |
949 |
|
public void addUser(String userName) |
950 |
|
{ |
951 |
6 |
TestWiki testWiki = space.getWiki(); |
952 |
6 |
DocumentReference userDoc = documentReferenceResolver.resolve(userName, |
953 |
|
new SpaceReference("XWiki", new WikiReference(testWiki.getName()))); |
954 |
|
|
955 |
6 |
String uname; |
956 |
6 |
if (userDoc.getWikiReference().getName().equals(testWiki.getName())) { |
957 |
4 |
uname = userDoc.getName(); |
958 |
|
} else { |
959 |
2 |
uname = entityReferenceSerializer.serialize(userDoc); |
960 |
|
} |
961 |
|
|
962 |
6 |
Set<String> groups = testWiki.groupsForUser.get(uname); |
963 |
6 |
if (groups == null) { |
964 |
2 |
groups = new HashSet<String>(); |
965 |
2 |
testWiki.groupsForUser.put(uname, groups); |
966 |
|
} |
967 |
6 |
groups.add(getName()); |
968 |
|
|
969 |
6 |
testWiki.groups.get(getName()).add(uname); |
970 |
|
|
971 |
6 |
this.memberObjects.put(uname, mockGroupBaseObject(uname)); |
972 |
|
} |
973 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
974 |
1 |
public void removeUser(String userName)... |
975 |
|
{ |
976 |
1 |
TestWiki testWiki = space.getWiki(); |
977 |
1 |
DocumentReference userDoc = documentReferenceResolver.resolve(userName, |
978 |
|
new SpaceReference("XWiki", new WikiReference(testWiki.getName()))); |
979 |
|
|
980 |
1 |
String uname; |
981 |
1 |
if (userDoc.getWikiReference().getName().equals(testWiki.getName())) { |
982 |
1 |
uname = userDoc.getName(); |
983 |
|
} else { |
984 |
0 |
uname = entityReferenceSerializer.serialize(userDoc); |
985 |
|
} |
986 |
|
|
987 |
1 |
this.memberObjects.remove(uname); |
988 |
|
} |
989 |
|
} |
990 |
|
|
|
|
| 69.7% |
Uncovered Elements: 27 (89) |
Complexity: 24 |
Complexity Density: 0.41 |
|
991 |
|
private class TestDocument extends TestAcl |
992 |
|
{ |
993 |
|
protected final XWikiDocument mockedDocument; |
994 |
|
|
995 |
|
protected final TestSpace space; |
996 |
|
|
997 |
|
protected final String name; |
998 |
|
|
999 |
|
protected final String alt; |
1000 |
|
|
1001 |
|
protected final String creator; |
1002 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1003 |
0 |
TestDocument(final String name, final TestSpace space, final String creator, final Boolean isNew)... |
1004 |
|
{ |
1005 |
0 |
this(name, space, creator, isNew, null); |
1006 |
|
} |
1007 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
1008 |
97 |
TestDocument(final String name, final TestSpace space, final String creator, final Boolean isNew, String alt)... |
1009 |
|
{ |
1010 |
97 |
this.space = space; |
1011 |
97 |
this.name = name; |
1012 |
97 |
this.creator = creator; |
1013 |
97 |
this.alt = alt; |
1014 |
|
|
1015 |
97 |
mockedDocument = mockery.mock(XWikiDocument.class, new Formatter() |
1016 |
|
.format("%s:%s.%s", getSpace().getWiki().getName(), getSpace().getName(), getName()).toString()); |
1017 |
|
|
1018 |
97 |
final DocumentReference documentReference = |
1019 |
|
new DocumentReference(getSpace().getWiki().getName(), getSpace().getName(), getName()); |
1020 |
|
|
1021 |
97 |
mockery.checking(new Expectations() |
1022 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
|
1023 |
97 |
{... |
1024 |
97 |
allowing(mockedDocument) |
1025 |
|
.getXObjects(with(equal(new LocalDocumentReference("XWiki", "XWikiRights")))); |
1026 |
97 |
will(new CustomAction("return a vector of rights") |
1027 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1028 |
66 |
@Override... |
1029 |
|
public Object invoke(Invocation invocation) |
1030 |
|
{ |
1031 |
66 |
return getLegacyDocumentRights(); |
1032 |
|
} |
1033 |
|
}); |
1034 |
97 |
allowing(mockedDocument) |
1035 |
|
.getXObjects(with(equal(new LocalDocumentReference("XWiki", "XWikiGlobalRights")))); |
1036 |
97 |
will(new CustomAction("return a vector of rights") |
1037 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1038 |
153 |
@Override... |
1039 |
|
public Object invoke(Invocation invocation) |
1040 |
|
{ |
1041 |
153 |
return getLegacyGlobalRights(); |
1042 |
|
} |
1043 |
|
}); |
1044 |
97 |
allowing(mockedDocument) |
1045 |
|
.getXObjects(new DocumentReference(space.wiki.getName(), "XWiki", "XWikiRights")); |
1046 |
97 |
will(new CustomAction("return a vector of rights") |
1047 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1048 |
36 |
@Override... |
1049 |
|
public Object invoke(Invocation invocation) |
1050 |
|
{ |
1051 |
36 |
return getLegacyDocumentRights(); |
1052 |
|
} |
1053 |
|
}); |
1054 |
97 |
allowing(mockedDocument) |
1055 |
|
.getXObjects(new DocumentReference(space.wiki.getName(), "XWiki", "XWikiGlobalRights")); |
1056 |
97 |
will(new CustomAction("return a vector of rights") |
1057 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1058 |
28 |
@Override... |
1059 |
|
public Object invoke(Invocation invocation) |
1060 |
|
{ |
1061 |
28 |
return getLegacyGlobalRights(); |
1062 |
|
} |
1063 |
|
}); |
1064 |
97 |
allowing(mockedDocument).getCreatorReference(); |
1065 |
97 |
will(returnValue(documentReferenceResolver.resolve(TestDocument.this.creator, documentReference))); |
1066 |
97 |
allowing(mockedDocument).getDocumentReference(); |
1067 |
97 |
will(returnValue(documentReference)); |
1068 |
97 |
allowing(mockedDocument).isNew(); |
1069 |
97 |
will(returnValue(isNew)); |
1070 |
|
} |
1071 |
|
}); |
1072 |
|
|
1073 |
97 |
if (legacymock) { |
1074 |
58 |
mockery.checking(new Expectations() |
1075 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
1076 |
58 |
{... |
1077 |
58 |
allowing(mockedDocument).getObjects("XWiki.XWikiGlobalRights"); |
1078 |
58 |
will(new CustomAction("return a vector of global rights") |
1079 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1080 |
0 |
@Override... |
1081 |
|
public Object invoke(Invocation invocation) |
1082 |
|
{ |
1083 |
0 |
return getLegacyGlobalRights(); |
1084 |
|
} |
1085 |
|
}); |
1086 |
58 |
allowing(mockedDocument).getObjects("XWiki.XWikiRights"); |
1087 |
58 |
will(new CustomAction("return a vector of document rights") |
1088 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1089 |
0 |
@Override... |
1090 |
|
public Object invoke(Invocation invocation) |
1091 |
|
{ |
1092 |
0 |
return getLegacyDocumentRights(); |
1093 |
|
} |
1094 |
|
}); |
1095 |
58 |
allowing(mockedDocument).getWikiName(); |
1096 |
58 |
will(returnValue(getSpace().getWiki().getName())); |
1097 |
58 |
allowing(mockedDocument).getDatabase(); |
1098 |
58 |
will(returnValue(getSpace().getWiki().getName())); |
1099 |
58 |
allowing(mockedDocument).getSpace(); |
1100 |
58 |
will(returnValue(getSpace().getName())); |
1101 |
|
} |
1102 |
|
}); |
1103 |
|
} |
1104 |
|
} |
1105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1106 |
279 |
public XWikiDocument getDocument()... |
1107 |
|
{ |
1108 |
279 |
return mockedDocument; |
1109 |
|
} |
1110 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
1111 |
181 |
public Vector<BaseObject> getLegacyGlobalRights()... |
1112 |
|
{ |
1113 |
181 |
if ("XWikiPreferences".equals(getName())) { |
1114 |
179 |
return getSpace().getWiki().getLegacyRightObjects(); |
1115 |
2 |
} else if ("WebPreferences".equals(getName())) { |
1116 |
2 |
return getSpace().getLegacyRightObjects(); |
1117 |
|
} |
1118 |
0 |
return null; |
1119 |
|
} |
1120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1121 |
102 |
public Vector<BaseObject> getLegacyDocumentRights()... |
1122 |
|
{ |
1123 |
102 |
return getLegacyRightObjects(); |
1124 |
|
} |
1125 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
1126 |
0 |
public Map<DocumentReference, List<BaseObject>> getLegacyXObjects()... |
1127 |
|
{ |
1128 |
0 |
Map<DocumentReference, List<BaseObject>> objects = new HashMap<DocumentReference, List<BaseObject>>(); |
1129 |
|
|
1130 |
0 |
Vector<BaseObject> globalRights = getLegacyGlobalRights(); |
1131 |
0 |
if (globalRights != null) { |
1132 |
0 |
objects.put(new DocumentReference(this.space.wiki.getName(), "XWiki", "XWikiGlobalRights"), |
1133 |
|
globalRights); |
1134 |
|
} |
1135 |
0 |
Vector<BaseObject> rights = getLegacyDocumentRights(); |
1136 |
0 |
if (globalRights != null) { |
1137 |
0 |
objects.put(new DocumentReference(this.space.wiki.getName(), "XWiki", "XWikiRights"), rights); |
1138 |
|
} |
1139 |
|
|
1140 |
0 |
return objects; |
1141 |
|
} |
1142 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1143 |
0 |
@Override... |
1144 |
|
EntityType getType() |
1145 |
|
{ |
1146 |
0 |
return EntityType.DOCUMENT; |
1147 |
|
} |
1148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1149 |
415 |
@Override... |
1150 |
|
public String getName() |
1151 |
|
{ |
1152 |
415 |
return this.name; |
1153 |
|
} |
1154 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
1155 |
0 |
@Override... |
1156 |
|
public String getPrettyName() |
1157 |
|
{ |
1158 |
0 |
return (this.alt != null) ? this.alt : this.name; |
1159 |
|
} |
1160 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1161 |
743 |
TestSpace getSpace()... |
1162 |
|
{ |
1163 |
743 |
return this.space; |
1164 |
|
} |
1165 |
|
} |
1166 |
|
|
1167 |
|
public static int objectNumber = 0; |
1168 |
|
|
|
|
| 89.4% |
Uncovered Elements: 7 (66) |
Complexity: 16 |
Complexity Density: 0.37 |
|
1169 |
|
private abstract class TestAcl implements HasAcl |
1170 |
|
{ |
1171 |
|
private final Map<String, Set<String>> allowUser = new HashMap<String, Set<String>>(); |
1172 |
|
|
1173 |
|
private final Map<String, Set<String>> denyUser = new HashMap<String, Set<String>>(); |
1174 |
|
|
1175 |
|
private final Map<String, Set<String>> allowGroup = new HashMap<String, Set<String>>(); |
1176 |
|
|
1177 |
|
private final Map<String, Set<String>> denyGroup = new HashMap<String, Set<String>>(); |
1178 |
|
|
1179 |
|
private List<BaseObject> mockedObjects = null; |
1180 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
1181 |
30 |
private void addType(Map<String, Set<String>> map, String key, String type)... |
1182 |
|
{ |
1183 |
30 |
Set<String> types = map.get(key); |
1184 |
|
|
1185 |
30 |
if (types == null) { |
1186 |
23 |
types = new HashSet<String>(); |
1187 |
23 |
map.put(key, types); |
1188 |
|
} |
1189 |
|
|
1190 |
30 |
types.add(type); |
1191 |
|
} |
1192 |
|
|
|
|
| 50% |
Uncovered Elements: 3 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1193 |
30 |
private void addRightType(Map<String, Set<String>> map, String key, String type)... |
1194 |
|
{ |
1195 |
30 |
if (type == null) { |
1196 |
0 |
for (Right right : Right.getEnabledRights(getType())) { |
1197 |
0 |
addType(map, key, right.toString()); |
1198 |
|
} |
1199 |
|
} else { |
1200 |
30 |
addType(map, key, type); |
1201 |
|
} |
1202 |
|
} |
1203 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1204 |
18 |
@Override... |
1205 |
|
public void addAllowUser(String name, String type) |
1206 |
|
{ |
1207 |
18 |
addRightType(this.allowUser, name, type); |
1208 |
|
} |
1209 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1210 |
2 |
@Override... |
1211 |
|
public void addDenyUser(String name, String type) |
1212 |
|
{ |
1213 |
2 |
addRightType(this.denyUser, name, type); |
1214 |
|
} |
1215 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1216 |
10 |
@Override... |
1217 |
|
public void addAllowGroup(String name, String type) |
1218 |
|
{ |
1219 |
10 |
addRightType(this.allowGroup, name, type); |
1220 |
|
} |
1221 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1222 |
0 |
@Override... |
1223 |
|
public void addDenyGroup(String name, String type) |
1224 |
|
{ |
1225 |
0 |
addRightType(this.denyGroup, name, type); |
1226 |
|
} |
1227 |
|
|
1228 |
|
abstract EntityType getType(); |
1229 |
|
|
1230 |
|
abstract String getName(); |
1231 |
|
|
1232 |
|
abstract String getPrettyName(); |
1233 |
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 3 |
Complexity Density: 0.2 |
|
1234 |
283 |
public Vector<BaseObject> getLegacyRightObjects()... |
1235 |
|
{ |
1236 |
283 |
if (this.mockedObjects == null) { |
1237 |
64 |
this.mockedObjects = new ArrayList<BaseObject>(); |
1238 |
64 |
for (Map.Entry<String, Set<String>> entry : this.allowUser.entrySet()) { |
1239 |
11 |
for (String type : entry.getValue()) { |
1240 |
17 |
this.mockedObjects.add(mockRightBaseObject(entry.getKey(), type, true, true)); |
1241 |
|
} |
1242 |
|
} |
1243 |
64 |
for (Map.Entry<String, Set<String>> entry : this.denyUser.entrySet()) { |
1244 |
1 |
for (String type : entry.getValue()) { |
1245 |
2 |
this.mockedObjects.add(mockRightBaseObject(entry.getKey(), type, true, false)); |
1246 |
|
} |
1247 |
|
} |
1248 |
|
|
1249 |
64 |
for (Map.Entry<String, Set<String>> entry : this.allowGroup.entrySet()) { |
1250 |
10 |
for (String type : entry.getValue()) { |
1251 |
10 |
this.mockedObjects.add(mockRightBaseObject(entry.getKey(), type, false, true)); |
1252 |
|
} |
1253 |
|
} |
1254 |
|
|
1255 |
64 |
for (Map.Entry<String, Set<String>> entry : this.denyGroup.entrySet()) { |
1256 |
0 |
for (String type : entry.getValue()) { |
1257 |
0 |
this.mockedObjects.add(mockRightBaseObject(entry.getKey(), type, false, false)); |
1258 |
|
} |
1259 |
|
} |
1260 |
|
} |
1261 |
|
|
1262 |
283 |
return this.mockedObjects.size() == 0 ? null : new Vector<BaseObject>(this.mockedObjects); |
1263 |
|
} |
1264 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
1265 |
29 |
private BaseObject mockRightBaseObject(final String name, final String type, final boolean isUser,... |
1266 |
|
final boolean allow) |
1267 |
|
{ |
1268 |
29 |
objectNumber++; |
1269 |
|
|
1270 |
29 |
final BaseObject rightBaseObjects = |
1271 |
|
mockery.mock(BaseObject.class, getName() + objectNumber + ' ' + name + ' ' + type + ' ' + allow); |
1272 |
|
|
1273 |
29 |
final String usersString = isUser ? name : ""; |
1274 |
29 |
final String groupsString = isUser ? "" : name; |
1275 |
29 |
final String levelsString = type; |
1276 |
|
|
1277 |
29 |
mockery.checking(new Expectations() |
1278 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
1279 |
29 |
{... |
1280 |
29 |
allowing(rightBaseObjects).getIntValue("allow"); |
1281 |
29 |
will(returnValue(allow ? 1 : 0)); |
1282 |
|
|
1283 |
29 |
allowing(rightBaseObjects).getStringValue("users"); |
1284 |
29 |
will(returnValue(usersString)); |
1285 |
29 |
allowing(rightBaseObjects).getStringValue("groups"); |
1286 |
29 |
will(returnValue(groupsString)); |
1287 |
29 |
allowing(rightBaseObjects).getStringValue("levels"); |
1288 |
29 |
will(returnValue(levelsString)); |
1289 |
|
} |
1290 |
|
}); |
1291 |
|
|
1292 |
29 |
return rightBaseObjects; |
1293 |
|
} |
1294 |
|
} |
1295 |
|
|
1296 |
|
|
1297 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1298 |
0 |
public void addUser(String userName, String wikiName)... |
1299 |
|
{ |
1300 |
0 |
TestWiki wiki = this.wikis.get(wikiName); |
1301 |
|
|
1302 |
0 |
wiki.addUser(userName); |
1303 |
|
} |
1304 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1305 |
1 |
public void deleteUser(String userName, String wikiName)... |
1306 |
|
{ |
1307 |
1 |
TestWiki wiki = this.wikis.get(wikiName); |
1308 |
|
|
1309 |
1 |
wiki.deleteUser(userName); |
1310 |
|
} |
1311 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1312 |
0 |
public void addGroup(String groupName, String wikiName)... |
1313 |
|
{ |
1314 |
0 |
TestWiki wiki = wikis.get(wikiName); |
1315 |
|
|
1316 |
0 |
wiki.addGroup(groupName); |
1317 |
|
} |
1318 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1319 |
0 |
public void deleteGroup(String groupName, String wikiName)... |
1320 |
|
{ |
1321 |
0 |
TestWiki wiki = wikis.get(wikiName); |
1322 |
|
|
1323 |
0 |
wiki.deleteGroup(groupName); |
1324 |
|
} |
1325 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1326 |
0 |
public TestDocument addDocument(DocumentReference documentReference, String creator, boolean isNew)... |
1327 |
|
{ |
1328 |
0 |
TestWiki wiki = wikis.get(documentReference.getWikiReference().getName()); |
1329 |
|
|
1330 |
0 |
return wiki.addDocument(documentReference, creator, isNew); |
1331 |
|
} |
1332 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1333 |
0 |
public void deleteDocument(DocumentReference documentReference)... |
1334 |
|
{ |
1335 |
0 |
TestWiki wiki = wikis.get(documentReference.getWikiReference().getName()); |
1336 |
|
|
1337 |
0 |
wiki.deleteDocument(documentReference); |
1338 |
|
} |
1339 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
1340 |
0 |
public void notifyDocumentModified(DocumentReference documentReference)... |
1341 |
|
{ |
1342 |
0 |
TestWiki wiki = wikis.get(documentReference.getWikiReference().getName()); |
1343 |
|
|
1344 |
0 |
XWikiDocument document = wiki.getDocument(documentReference); |
1345 |
|
|
1346 |
|
|
1347 |
0 |
observationManager.notify(new DocumentUpdatedEvent(documentReference), document, context); |
1348 |
|
} |
1349 |
|
} |