|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ClosureConstraintMatcher.java | - | 0% | 0% | 0% |
|
1 |
package groovy.mock;
|
|
2 |
|
|
3 |
import groovy.lang.Closure;
|
|
4 |
|
|
5 |
import com.mockobjects.constraint.Constraint;
|
|
6 |
|
|
7 |
/**
|
|
8 |
*
|
|
9 |
* @author Joe Walnes
|
|
10 |
* @author Chris Stevenson
|
|
11 |
* @version $Revision: 1.1 $
|
|
12 |
*/
|
|
13 |
public class ClosureConstraintMatcher implements Constraint { |
|
14 |
private Closure closure;
|
|
15 |
private String message = "closure"; |
|
16 |
|
|
17 | 0 |
public ClosureConstraintMatcher(Closure closure) {
|
18 | 0 |
this.closure = closure;
|
19 |
} |
|
20 |
|
|
21 | 0 |
public boolean eval(Object object) { |
22 | 0 |
try {
|
23 | 0 |
closure.call(object); |
24 | 0 |
return true; |
25 |
} |
|
26 |
catch (AssertionError e) {
|
|
27 | 0 |
message = e.getMessage(); |
28 | 0 |
return false; |
29 |
} |
|
30 |
} |
|
31 |
|
|
32 | 0 |
public String toString() {
|
33 | 0 |
return message;
|
34 |
} |
|
35 |
|
|
36 |
} |
|
37 |
|
|