1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package org.xwiki.security.authorization.testwikis.internal.entities; |
22 |
|
|
23 |
|
import java.util.Collection; |
24 |
|
import java.util.HashMap; |
25 |
|
import java.util.Map; |
26 |
|
|
27 |
|
import org.xwiki.model.reference.EntityReference; |
28 |
|
import org.xwiki.security.authorization.testwikis.TestEntity; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@version |
34 |
|
@since |
35 |
|
|
|
|
| 90.2% |
Uncovered Elements: 4 (41) |
Complexity: 15 |
Complexity Density: 0.62 |
|
36 |
|
public abstract class AbstractTestEntity implements TestEntity |
37 |
|
{ |
38 |
|
|
39 |
|
private final EntityReference reference; |
40 |
|
|
41 |
|
|
42 |
|
private final TestEntity parent; |
43 |
|
|
44 |
|
|
45 |
|
private final Map<EntityReference, TestEntity> entities = new HashMap<EntityReference, TestEntity>(); |
46 |
|
|
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
48 |
15 |
AbstractTestEntity() {... |
49 |
15 |
reference = null; |
50 |
15 |
parent = null; |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
@param |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
58 |
1209 |
AbstractTestEntity(EntityReference reference, TestEntity parent) {... |
59 |
1209 |
this.parent = parent; |
60 |
1209 |
this.reference = reference; |
61 |
|
|
62 |
1209 |
addToParent(parent); |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
@param |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
340 |
protected void addToParent(TestEntity parent) {... |
71 |
340 |
parent.add(this); |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
3156 |
@Override... |
75 |
|
public EntityReference getReference() |
76 |
|
{ |
77 |
3156 |
return reference; |
78 |
|
} |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
340 |
@Override... |
81 |
|
public void add(TestEntity entity) |
82 |
|
{ |
83 |
340 |
entities.put(entity.getReference(), entity); |
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
459 |
@Override... |
87 |
|
public TestEntity getEntity(EntityReference reference) |
88 |
|
{ |
89 |
459 |
return entities.get(reference); |
90 |
|
} |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
84 |
@Override... |
93 |
|
public Collection<TestEntity> getEntities() |
94 |
|
{ |
95 |
84 |
return entities.values(); |
96 |
|
} |
97 |
|
|
|
|
| 90.5% |
Uncovered Elements: 2 (21) |
Complexity: 7 |
Complexity Density: 0.54 |
|
98 |
766 |
@Override... |
99 |
|
public TestEntity searchEntity(EntityReference reference) |
100 |
|
{ |
101 |
766 |
EntityReference parentRef; |
102 |
766 |
EntityReference currentRef = reference; |
103 |
766 |
do { |
104 |
1413 |
parentRef = currentRef.getParent(); |
105 |
1413 |
if (this.reference == parentRef || (this.reference != null && this.reference.equals(parentRef))) { |
106 |
766 |
if (currentRef == reference) { |
107 |
309 |
return entities.get(reference); |
108 |
|
} else { |
109 |
457 |
TestEntity child = entities.get(currentRef); |
110 |
457 |
if (child == null) { |
111 |
6 |
return null; |
112 |
|
} |
113 |
451 |
return child.searchEntity(reference); |
114 |
|
} |
115 |
|
} |
116 |
647 |
currentRef = parentRef; |
117 |
647 |
} while(currentRef != null); |
118 |
0 |
return null; |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
0 |
@Override... |
122 |
|
public TestEntity getParent() |
123 |
|
{ |
124 |
0 |
return parent; |
125 |
|
} |
126 |
|
} |