|
2 | 2 |
|
3 | 3 | import org.hamcrest.AbstractMatcherTest; |
4 | 4 | import org.hamcrest.Matcher; |
5 | | -import static org.hamcrest.collection.IsCollectionContaining.collectionContaining; |
6 | | -import static org.hamcrest.collection.IsCollectionContaining.collectionContainingAllOf; |
| 5 | +import static org.hamcrest.collection.IsCollectionContaining.hasItems; |
7 | 6 | import static org.hamcrest.core.IsEqual.equalTo; |
8 | 7 |
|
9 | 8 | import java.util.ArrayList; |
|
12 | 11 | public class IsCollectionContainingTest extends AbstractMatcherTest { |
13 | 12 |
|
14 | 13 | protected Matcher<?> createMatcher() { |
15 | | - return collectionContaining(equalTo("irrelevant")); |
| 14 | + return IsCollectionContaining.hasItem(equalTo("irrelevant")); |
16 | 15 | } |
17 | 16 |
|
18 | 17 | public void testMatchesACollectionThatContainsAnElementMatchingTheGivenMatcher() { |
19 | 18 | assertMatches("should matches list that contains 'a'", |
20 | | - collectionContaining(equalTo("a")), asList("a", "b", "c")); |
| 19 | + IsCollectionContaining.hasItem(equalTo("a")), asList("a", "b", "c")); |
21 | 20 | } |
22 | 21 |
|
23 | 22 | public void testDoesNotMatchCollectionThatDoesntContainAnElementMatchingTheGivenMatcher() { |
24 | 23 | assertDoesNotMatch("should not matches list that doesn't contain 'a'", |
25 | | - collectionContaining(equalTo("a")), asList("b", "c")); |
| 24 | + IsCollectionContaining.hasItem(equalTo("a")), asList("b", "c")); |
26 | 25 | assertDoesNotMatch("should not matches empty list", |
27 | | - collectionContaining(equalTo("a")), new ArrayList<String>()); |
| 26 | + IsCollectionContaining.hasItem(equalTo("a")), new ArrayList<String>()); |
28 | 27 | } |
29 | 28 |
|
30 | 29 | public void testDoesNotMatchNull() { |
31 | | - assertDoesNotMatch("should not matches null", collectionContaining(equalTo("a")), null); |
| 30 | + assertDoesNotMatch("should not matches null", IsCollectionContaining.hasItem(equalTo("a")), null); |
32 | 31 | } |
33 | 32 |
|
34 | 33 | public void testHasAReadableDescription() { |
35 | | - assertDescription("a collection containing \"a\"", collectionContaining(equalTo("a"))); |
| 34 | + assertDescription("a collection containing \"a\"", IsCollectionContaining.hasItem(equalTo("a"))); |
36 | 35 | } |
37 | 36 |
|
38 | 37 | public void testMatchesAllItemsInCollection() { |
39 | 38 | assertMatches("should match list containing all of items", |
40 | | - collectionContainingAllOf(equalTo("a"), equalTo("b"), equalTo("c")), |
| 39 | + hasItems(equalTo("a"), equalTo("b"), equalTo("c")), |
41 | 40 | asList("a", "b", "c")); |
42 | 41 | assertMatches("should match list containing all of items in any order", |
43 | | - collectionContainingAllOf(equalTo("a"), equalTo("b"), equalTo("c")), |
| 42 | + hasItems(equalTo("a"), equalTo("b"), equalTo("c")), |
44 | 43 | asList("c", "b", "a")); |
45 | 44 | assertMatches("should match list containing all of items plus others", |
46 | | - collectionContainingAllOf(equalTo("a"), equalTo("b"), equalTo("c")), |
| 45 | + hasItems(equalTo("a"), equalTo("b"), equalTo("c")), |
47 | 46 | asList("e", "c", "b", "a", "d")); |
48 | 47 | assertDoesNotMatch("should not match list unless it contains all items", |
49 | | - collectionContainingAllOf(equalTo("a"), equalTo("b"), equalTo("c")), |
| 48 | + hasItems(equalTo("a"), equalTo("b"), equalTo("c")), |
50 | 49 | asList("e", "c", "b", "d")); // 'a' missing |
51 | 50 | } |
52 | 51 | } |
0 commit comments