1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.csrf; |
21 |
|
|
22 |
|
import org.hamcrest.BaseMatcher; |
23 |
|
import org.hamcrest.Description; |
24 |
|
import org.jmock.api.Action; |
25 |
|
import org.jmock.api.Invocation; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
@version |
32 |
|
@since |
33 |
|
|
|
|
| 36.8% |
Uncovered Elements: 12 (19) |
Complexity: 6 |
Complexity Density: 0.55 |
|
34 |
|
public final class CopyStringMatcher extends BaseMatcher<String> implements Action |
35 |
|
{ |
36 |
|
|
37 |
|
private String value = null; |
38 |
|
|
39 |
|
|
40 |
|
private String prefix; |
41 |
|
|
42 |
|
|
43 |
|
private String suffix; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
@param |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
51 |
9 |
public CopyStringMatcher(String prefix, String suffix)... |
52 |
|
{ |
53 |
9 |
this.prefix = prefix; |
54 |
9 |
this.suffix = suffix; |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
@see |
59 |
|
|
|
|
| 50% |
Uncovered Elements: 3 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
60 |
1 |
@Override... |
61 |
|
public boolean matches(Object argument) |
62 |
|
{ |
63 |
1 |
if (argument instanceof String) { |
64 |
0 |
this.value = (String) argument; |
65 |
0 |
return true; |
66 |
|
} |
67 |
1 |
return false; |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
@see |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
73 |
0 |
@Override... |
74 |
|
public void describeTo(Description d) |
75 |
|
{ |
76 |
0 |
d.appendText("COPY VALUE: "); |
77 |
0 |
d.appendValue(this.value); |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
@see |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
83 |
0 |
@Override... |
84 |
|
public String invoke(Invocation invocation) throws Throwable |
85 |
|
{ |
86 |
0 |
if (this.value == null) { |
87 |
0 |
return this.prefix + this.suffix; |
88 |
|
} |
89 |
0 |
return this.prefix + this.value + this.suffix; |
90 |
|
} |
91 |
|
} |