|
30 | 30 | import org.mockito.MockitoAnnotations;
|
31 | 31 | import org.mockito.internal.hamcrest.HamcrestArgumentMatcher;
|
32 | 32 |
|
| 33 | +import org.mockito.internal.matchers.Any; |
| 34 | +import org.mockito.internal.matchers.Not; |
| 35 | +import org.mockito.internal.matchers.Or; |
33 | 36 | import org.sakaiproject.event.api.EventTrackingService;
|
34 | 37 | import org.sakaiproject.tags.api.MissingUuidException;
|
35 | 38 | import org.sakaiproject.tags.api.Tag;
|
|
41 | 44 | import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
|
42 | 45 | import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
43 | 46 |
|
44 |
| -import java.io.Serializable; |
45 | 47 | import java.sql.Connection;
|
46 | 48 | import java.sql.SQLException;
|
47 | 49 | import java.util.Date;
|
48 |
| -import java.util.Iterator; |
49 |
| -import java.util.List; |
50 | 50 | import java.util.function.Function;
|
51 | 51 | import java.util.function.Supplier;
|
52 | 52 |
|
53 | 53 | import static org.hamcrest.Matchers.hasProperty;
|
54 | 54 | import static org.mockito.Mockito.argThat;
|
55 | 55 | import static org.mockito.Mockito.when;
|
56 |
| -import static org.mockito.internal.matchers.Null.NULL; |
57 | 56 |
|
58 | 57 | public abstract class BaseStorageTest {
|
59 | 58 |
|
@@ -262,43 +261,15 @@ protected <T> HamcrestArgumentMatcher<T> argHasProperty(String propertyName, Mat
|
262 | 261 | }
|
263 | 262 |
|
264 | 263 | protected <T> T argThatMatchesAnyOf(ArgumentMatcher<?>... matchers) {
|
265 |
| - final Or or = new Or(Lists.newArrayList(matchers)); |
| 264 | + ArgumentMatcher or = new Not(Any.ANY); |
| 265 | + for (ArgumentMatcher<?> matcher : matchers) { |
| 266 | + or = new Or(matcher, or); |
| 267 | + } |
266 | 268 | return (T) argThat(or);
|
267 | 269 | }
|
268 | 270 |
|
269 | 271 | protected long now() {
|
270 | 272 | return new Date().getTime();
|
271 | 273 | }
|
272 | 274 |
|
273 |
| - //This was changed in https://github.com/mockito/mockito/pull/833, using old implementation |
274 |
| - @SuppressWarnings("unchecked") |
275 |
| - public class Or implements ArgumentMatcher, Serializable { |
276 |
| - |
277 |
| - private final List<ArgumentMatcher> matchers; |
278 |
| - |
279 |
| - public Or(List<ArgumentMatcher> matchers) { |
280 |
| - this.matchers = matchers; |
281 |
| - } |
282 |
| - |
283 |
| - public boolean matches(Object actual) { |
284 |
| - for (ArgumentMatcher matcher : matchers) { |
285 |
| - if (matcher.matches(actual)) { |
286 |
| - return true; |
287 |
| - } |
288 |
| - } |
289 |
| - return false; |
290 |
| - } |
291 |
| - |
292 |
| - public String toString() { |
293 |
| - //TODO SF here and in other places we should reuse ValuePrinter |
294 |
| - StringBuilder sb = new StringBuilder("or("); |
295 |
| - for (Iterator<ArgumentMatcher> it = matchers.iterator(); it.hasNext();) { |
296 |
| - sb.append(it.next().toString()); |
297 |
| - if (it.hasNext()) { |
298 |
| - sb.append(", "); |
299 |
| - } |
300 |
| - } |
301 |
| - return sb.append(")").toString(); |
302 |
| - } |
303 |
| - } |
304 | 275 | }
|
0 commit comments