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; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
import java.util.Set; |
24 |
|
import java.util.TreeSet; |
25 |
|
|
26 |
|
import org.junit.runner.RunWith; |
27 |
|
import org.junit.runners.AllTests; |
28 |
|
|
29 |
|
import com.google.common.collect.testing.SampleElements; |
30 |
|
import com.google.common.collect.testing.SetTestSuiteBuilder; |
31 |
|
import com.google.common.collect.testing.TestSetGenerator; |
32 |
|
import com.google.common.collect.testing.features.CollectionFeature; |
33 |
|
import com.google.common.collect.testing.features.CollectionSize; |
34 |
|
import com.google.common.collect.testing.features.SetFeature; |
35 |
|
|
36 |
|
import junit.framework.Test; |
37 |
|
import junit.framework.TestSuite; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@version |
43 |
|
@since |
44 |
|
|
45 |
|
@RunWith(AllTests.class) |
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 5 |
Complexity Density: 0.5 |
|
46 |
|
public class RightSetTest |
47 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
48 |
1 |
public static Test suite() {... |
49 |
1 |
TestSuite suite = new TestSuite(); |
50 |
|
|
51 |
1 |
suite.addTest(SetTestSuiteBuilder.using(new TestSetGenerator<Right>() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
1259 |
@Override... |
53 |
|
public SampleElements<Right> samples() |
54 |
|
{ |
55 |
1259 |
return new SampleElements<Right>( |
56 |
|
Right.VIEW, |
57 |
|
Right.EDIT, |
58 |
|
Right.DELETE, |
59 |
|
Right.COMMENT, |
60 |
|
Right.ADMIN |
61 |
|
); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
64 |
931 |
@Override... |
65 |
|
public Set<Right> create(Object... elements) |
66 |
|
{ |
67 |
931 |
Set<Right> set = new RightSet(); |
68 |
931 |
for (Object e : elements) { |
69 |
2765 |
set.add((Right) e); |
70 |
|
} |
71 |
931 |
return set; |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
65 |
@Override... |
75 |
|
public Right[] createArray(int length) |
76 |
|
{ |
77 |
65 |
return new Right[length]; |
78 |
|
} |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
19 |
@Override... |
81 |
|
public Iterable<Right> order(List<Right> insertionOrder) |
82 |
|
{ |
83 |
19 |
return new TreeSet<Right>(insertionOrder); |
84 |
|
} |
85 |
|
}) |
86 |
|
.named("RightSet") |
87 |
|
.withFeatures(SetFeature.GENERAL_PURPOSE, |
88 |
|
CollectionSize.ANY, |
89 |
|
CollectionFeature.ALLOWS_NULL_QUERIES, |
90 |
|
CollectionFeature.KNOWN_ORDER) |
91 |
|
.suppressing(com.google.common.collect.testing.testers.SetHashCodeTester.getHashCodeMethods()) |
92 |
|
.createTestSuite()); |
93 |
1 |
return suite; |
94 |
|
} |
95 |
|
} |