1
|
|
|
2
|
|
package org.jmock;
|
3
|
|
|
4
|
|
import org.jmock.constraint.*;
|
5
|
|
import org.jmock.dynamic.Invocation;
|
6
|
|
import org.jmock.matcher.ArgumentsMatcher;
|
7
|
|
import org.jmock.matcher.StatelessInvocationMatcher;
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
public abstract class C {
|
13
|
|
public static final IsAnything IS_ANYTHING = new IsAnything();
|
14
|
|
public static final IsNull IS_NULL = new IsNull();
|
15
|
|
public static final Constraint IS_NOT_NULL = not(IS_NULL);
|
16
|
|
public static final Constraint IS_TRUE = eq(new Boolean(true));
|
17
|
|
public static final Constraint IS_FALSE = eq(new Boolean(false));
|
18
|
|
public static final Constraint IS_ZERO = eq(new Integer(0));
|
19
|
|
public static final Constraint IS_NOT_ZERO = not(IS_ZERO);
|
20
|
|
|
21
|
|
public static final InvocationMatcher NO_ARGS =
|
22
|
|
new StatelessInvocationMatcher() {
|
23
|
18
|
public boolean matches(Invocation invocation) {
|
24
|
18
|
return invocation.getParameterValues().isEmpty();
|
25
|
|
}
|
26
|
|
};
|
27
|
|
|
28
|
|
public static final InvocationMatcher ANY_ARGS =
|
29
|
|
new StatelessInvocationMatcher() {
|
30
|
0
|
public boolean matches(Invocation invocation) {
|
31
|
0
|
return true;
|
32
|
|
}
|
33
|
|
};
|
34
|
|
|
35
|
0
|
public static Constraint same(Object o) {
|
36
|
0
|
return new IsSame(o);
|
37
|
|
}
|
38
|
|
|
39
|
76
|
public static Constraint eq(Object o) {
|
40
|
76
|
return new IsEqual(o);
|
41
|
|
}
|
42
|
|
|
43
|
14
|
public static InvocationMatcher eq(Object arg0, Object arg1) {
|
44
|
14
|
return args(eq(arg0), eq(arg1));
|
45
|
|
}
|
46
|
|
|
47
|
0
|
public static InvocationMatcher eq(Object arg0, Object arg1, Object arg2) {
|
48
|
0
|
return args(eq(arg0), eq(arg1), eq(arg2));
|
49
|
|
}
|
50
|
|
|
51
|
0
|
public static InvocationMatcher eq(Object arg0, Object arg1, Object arg2, Object arg3) {
|
52
|
0
|
return args(eq(arg0), eq(arg1), eq(arg2), eq(arg3));
|
53
|
|
}
|
54
|
|
|
55
|
0
|
public static Constraint eq(int n) {
|
56
|
0
|
return new IsEqual(new Integer(n));
|
57
|
|
}
|
58
|
|
|
59
|
0
|
public static Constraint eq(long l) {
|
60
|
0
|
return new IsEqual(new Long(l));
|
61
|
|
}
|
62
|
|
|
63
|
0
|
public static Constraint eq(double d) {
|
64
|
0
|
return new IsEqual(new Double(d));
|
65
|
|
}
|
66
|
|
|
67
|
0
|
public static Constraint gt(int n) {
|
68
|
0
|
return new IsGreaterThan(new Integer(n));
|
69
|
|
}
|
70
|
|
|
71
|
0
|
public static Constraint gt(long l) {
|
72
|
0
|
return new IsGreaterThan(new Long(l));
|
73
|
|
}
|
74
|
|
|
75
|
0
|
public static Constraint gt(double d) {
|
76
|
0
|
return new IsGreaterThan(new Double(d));
|
77
|
|
}
|
78
|
|
|
79
|
0
|
public static Constraint gt(char c) {
|
80
|
0
|
return new IsGreaterThan(new Character(c));
|
81
|
|
}
|
82
|
|
|
83
|
0
|
public static Constraint lt(int n) {
|
84
|
0
|
return new IsLessThan(new Integer(n));
|
85
|
|
}
|
86
|
|
|
87
|
0
|
public static Constraint lt(long l) {
|
88
|
0
|
return new IsLessThan(new Long(l));
|
89
|
|
}
|
90
|
|
|
91
|
0
|
public static Constraint lt(double d) {
|
92
|
0
|
return new IsLessThan(new Double(d));
|
93
|
|
}
|
94
|
|
|
95
|
0
|
public static Constraint lt(char c) {
|
96
|
0
|
return new IsLessThan(new Character(c));
|
97
|
|
}
|
98
|
|
|
99
|
26
|
public static Constraint not(Constraint p) {
|
100
|
26
|
return new IsNot(p);
|
101
|
|
}
|
102
|
|
|
103
|
0
|
public static Constraint and(Constraint p1, Constraint p2) {
|
104
|
0
|
return new And(p1, p2);
|
105
|
|
}
|
106
|
|
|
107
|
0
|
public static Constraint or(Constraint p1, Constraint p2) {
|
108
|
0
|
return new Or(p1, p2);
|
109
|
|
}
|
110
|
|
|
111
|
0
|
public static Constraint isA(Class c) {
|
112
|
0
|
return new IsInstanceOf(c);
|
113
|
|
}
|
114
|
|
|
115
|
|
|
116
|
|
|
117
|
|
|
118
|
0
|
public static InvocationMatcher args() {
|
119
|
0
|
return NO_ARGS;
|
120
|
|
}
|
121
|
|
|
122
|
0
|
public static InvocationMatcher args(Constraint p) {
|
123
|
0
|
return new ArgumentsMatcher(new Constraint[]{p});
|
124
|
|
}
|
125
|
|
|
126
|
14
|
public static InvocationMatcher args(Constraint p1, Constraint p2) {
|
127
|
14
|
return new ArgumentsMatcher(new Constraint[]{p1, p2});
|
128
|
|
}
|
129
|
|
|
130
|
0
|
public static InvocationMatcher args(Constraint p1, Constraint p2, Constraint p3) {
|
131
|
0
|
return new ArgumentsMatcher(new Constraint[]{p1, p2, p3});
|
132
|
|
}
|
133
|
|
|
134
|
0
|
public static InvocationMatcher args(Constraint p1, Constraint p2, Constraint p3, Constraint p4) {
|
135
|
0
|
return new ArgumentsMatcher(new Constraint[]{p1, p2, p3, p4});
|
136
|
|
}
|
137
|
|
|
138
|
0
|
public static InvocationMatcher anyArgs(int argCount) {
|
139
|
0
|
Constraint[] constraints = new Constraint[argCount];
|
140
|
0
|
for (int i = 0; i < constraints.length; i++) {
|
141
|
0
|
constraints[i] = new IsAnything();
|
142
|
|
}
|
143
|
|
|
144
|
0
|
return new ArgumentsMatcher(constraints);
|
145
|
|
}
|
146
|
|
}
|
147
|
|
|