|
2 | 2 |
|
3 | 3 | import org.hamcrest.AbstractMatcherTest;
|
4 | 4 | import org.hamcrest.Matcher;
|
5 |
| -import static org.hamcrest.collection.IsMapContaining.mapContaining; |
| 5 | +import static org.hamcrest.collection.IsMapContaining.hasEntry; |
6 | 6 | import static org.hamcrest.core.IsAnything.anything;
|
7 | 7 | import static org.hamcrest.core.IsEqual.equalTo;
|
8 | 8 |
|
|
12 | 12 | public class IsMapContainingTest extends AbstractMatcherTest {
|
13 | 13 |
|
14 | 14 | protected Matcher<?> createMatcher() {
|
15 |
| - return mapContaining("irrelevant", "irrelevant"); |
| 15 | + return IsMapContaining.hasEntry("irrelevant", "irrelevant"); |
16 | 16 | }
|
17 | 17 |
|
18 | 18 | public void testMatchesMapContainingMatchingKeyAndValue() {
|
19 | 19 | Map<String,Integer> map = new HashMap<String,Integer>();
|
20 | 20 | map.put("a", 1);
|
21 | 21 | map.put("b", 2);
|
22 | 22 |
|
23 |
| - assertMatches("matcherA", mapContaining(equalTo("a"), equalTo(1)), map); |
24 |
| - assertMatches("matcherB", mapContaining(equalTo("b"), equalTo(2)), map); |
25 |
| - assertDoesNotMatch("matcherC", mapContaining(equalTo("c"), equalTo(3)), map); |
| 23 | + assertMatches("matcherA", hasEntry(equalTo("a"), equalTo(1)), map); |
| 24 | + assertMatches("matcherB", hasEntry(equalTo("b"), equalTo(2)), map); |
| 25 | + assertDoesNotMatch("matcherC", hasEntry(equalTo("c"), equalTo(3)), map); |
26 | 26 | }
|
27 | 27 |
|
28 | 28 | public void testDoesNotMatchNull() {
|
29 | 29 | assertDoesNotMatch("should not matches null",
|
30 |
| - mapContaining(anything(), anything()), null); |
| 30 | + hasEntry(anything(), anything()), null); |
31 | 31 | }
|
32 | 32 |
|
33 | 33 | public void testHasReadableDescription() {
|
34 | 34 | assertDescription("map containing [\"a\"-><2>]",
|
35 |
| - mapContaining(equalTo("a"), (equalTo(2)))); |
| 35 | + hasEntry(equalTo("a"), (equalTo(2)))); |
36 | 36 | }
|
37 | 37 |
|
38 | 38 | // Remaining code no longer compiles, thanks to generics. I think that's a good thing, but
|
|
0 commit comments