1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.macro.ctsreport; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.HashMap; |
24 |
|
import java.util.Iterator; |
25 |
|
import java.util.List; |
26 |
|
import java.util.Map; |
27 |
|
import java.util.Set; |
28 |
|
import java.util.TreeSet; |
29 |
|
|
30 |
|
import org.apache.commons.lang3.tuple.ImmutablePair; |
31 |
|
import org.apache.commons.lang3.tuple.Pair; |
32 |
|
|
33 |
|
|
34 |
|
@link |
35 |
|
|
36 |
|
@version |
37 |
|
@since |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (47) |
Complexity: 10 |
Complexity Density: 0.31 |
|
39 |
|
public class ResultExtractor |
40 |
|
{ |
41 |
|
|
42 |
|
@param@link |
43 |
|
@return |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
45 |
3 |
public Set<String> extractByTestName(List<Result> results)... |
46 |
|
{ |
47 |
3 |
Set<String> testNames = new TreeSet<String>(); |
48 |
3 |
for (Result result : results) { |
49 |
12 |
testNames.add(result.test.prefix); |
50 |
|
} |
51 |
3 |
return testNames; |
52 |
|
} |
53 |
|
|
54 |
|
|
55 |
|
@param@link |
56 |
|
@return |
57 |
|
|
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 3 |
Complexity Density: 0.25 |
|
59 |
3 |
public Map<String, Pair<Set<Test>, Set<Test>>> extractBySyntax(List<Result> results)... |
60 |
|
{ |
61 |
3 |
Map<String, Pair<Set<Test>, Set<Test>>> tests = new HashMap<String, Pair<Set<Test>, Set<Test>>>(); |
62 |
|
|
63 |
3 |
for (Result result : results) { |
64 |
|
|
65 |
|
|
66 |
12 |
Pair<Set<Test>, Set<Test>> inOutTests = tests.get(result.syntaxId); |
67 |
12 |
if (inOutTests == null) { |
68 |
6 |
inOutTests = new ImmutablePair<Set<Test>, Set<Test>>( |
69 |
|
new TreeSet<Test>(), new TreeSet<Test>()); |
70 |
6 |
tests.put(result.syntaxId, inOutTests); |
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
12 |
Set<Test> typeTests; |
75 |
12 |
if (result.isSyntaxInputTest) { |
76 |
9 |
typeTests = inOutTests.getLeft(); |
77 |
|
} else { |
78 |
3 |
typeTests = inOutTests.getRight(); |
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
12 |
typeTests.add(result.test); |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
3 |
return tests; |
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
@param |
93 |
|
@param |
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
95 |
2 |
public void normalize(Set<String> testNames, Map<String, Pair<Set<Test>, Set<Test>>> tests)... |
96 |
|
{ |
97 |
2 |
for (Pair<Set<Test>, Set<Test>> inOutTests : tests.values()) { |
98 |
4 |
addNotApplicableTests(testNames, inOutTests.getLeft()); |
99 |
4 |
addNotApplicableTests(testNames, inOutTests.getRight()); |
100 |
|
} |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
@param |
107 |
|
@param |
108 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
109 |
8 |
private void addNotApplicableTests(Set<String> testNames, Set<Test> tests)... |
110 |
|
{ |
111 |
8 |
List<String> inTestNames = extractTestNames(tests); |
112 |
|
|
113 |
|
|
114 |
|
|
115 |
8 |
if (!inTestNames.isEmpty()) { |
116 |
6 |
for (String testName : testNames) { |
117 |
12 |
if (!inTestNames.contains(testName)) { |
118 |
|
|
119 |
4 |
Test test = new Test(); |
120 |
4 |
test.prefix = testName; |
121 |
4 |
test.state = State.NOT_APPLICABLE; |
122 |
4 |
tests.add(test); |
123 |
|
} |
124 |
|
} |
125 |
|
} |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
@param |
132 |
|
@return |
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
134 |
8 |
private List<String> extractTestNames(Set<Test> tests)... |
135 |
|
{ |
136 |
8 |
List<String> inTestNames = new ArrayList<String>(); |
137 |
8 |
Iterator<Test> it = tests.iterator(); |
138 |
16 |
while (it.hasNext()) { |
139 |
8 |
inTestNames.add(it.next().prefix); |
140 |
|
} |
141 |
8 |
return inTestNames; |
142 |
|
} |
143 |
|
} |