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.regex.Matcher; |
23 |
|
import java.util.regex.Pattern; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
@version |
30 |
|
@since |
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 5 |
Complexity Density: 0.25 |
|
32 |
|
public class TestParser |
33 |
|
{ |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
private static final Pattern PATTERN = Pattern.compile("(.*) \\[(.*), (.*):(.*), CTS:(.*)\\](.*)"); |
38 |
|
|
39 |
|
|
40 |
|
@param |
41 |
|
@return |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (28) |
Complexity: 5 |
Complexity Density: 0.25 |
|
43 |
21 |
public Result parse(String syntaxTest)... |
44 |
|
{ |
45 |
21 |
Result data = new Result(); |
46 |
21 |
Matcher matcher = PATTERN.matcher(syntaxTest); |
47 |
21 |
if (matcher.matches()) { |
48 |
20 |
data.syntaxId = matcher.group(2); |
49 |
20 |
data.isSyntaxInputTest = "IN".equals(matcher.group(3)); |
50 |
|
|
51 |
20 |
Test test = new Test(); |
52 |
20 |
data.test = test; |
53 |
20 |
test.prefix = matcher.group(1); |
54 |
20 |
test.syntaxExtension = matcher.group(4); |
55 |
20 |
test.ctsExtension = matcher.group(5); |
56 |
|
|
57 |
20 |
String cause = matcher.group(6); |
58 |
20 |
if (cause.contains("Failing")) { |
59 |
1 |
test.state = State.FAILING; |
60 |
19 |
} else if (cause.contains("Missing")) { |
61 |
1 |
test.state = State.MISSING; |
62 |
18 |
} else if (cause.contains("Passed")) { |
63 |
17 |
test.state = State.PASSED; |
64 |
|
} else { |
65 |
1 |
test.state = State.UNKNOWN; |
66 |
|
} |
67 |
|
} else { |
68 |
1 |
throw new RuntimeException(String.format("Invalid Syntax Test format for [%s]", syntaxTest)); |
69 |
|
} |
70 |
20 |
return data; |
71 |
|
} |
72 |
|
} |