1
1
package org .hamcrest .collection ;
2
2
3
+ import org .hamcrest .Matcher ;
4
+
5
+ import java .util .Map ;
6
+
7
+ import static org .hamcrest .core .IsEqual .equalTo ;
8
+
3
9
public class MatchingMaps {
4
10
/**
5
11
* Creates a matcher for {@link java.util.Map}s that matches when the <code>size()</code> method returns
@@ -9,8 +15,8 @@ public class MatchingMaps {
9
15
*
10
16
* @param sizeMatcher a matcher for the size of an examined {@link java.util.Map}
11
17
*/
12
- public static <K , V > org . hamcrest . Matcher <java . util . Map <? extends K , ? extends V >> aMapWithSize (org . hamcrest . Matcher <? super java . lang . Integer > sizeMatcher ) {
13
- return org . hamcrest . collection . IsMapWithSize . aMapWithSize (sizeMatcher );
18
+ public static <K , V > Matcher <Map <? extends K , ? extends V >> aMapWithSize (Matcher <? super Integer > sizeMatcher ) {
19
+ return new IsMapWithSize <> (sizeMatcher );
14
20
}
15
21
16
22
/**
@@ -21,8 +27,8 @@ public class MatchingMaps {
21
27
*
22
28
* @param size the expected size of an examined {@link java.util.Map}
23
29
*/
24
- public static <K , V > org . hamcrest . Matcher <java . util . Map <? extends K , ? extends V >> aMapWithSize (int size ) {
25
- return org . hamcrest . collection . IsMapWithSize . aMapWithSize (size );
30
+ public static <K , V > Matcher <Map <? extends K , ? extends V >> aMapWithSize (int size ) {
31
+ return aMapWithSize (equalTo ( size ) );
26
32
}
27
33
28
34
/**
@@ -31,8 +37,8 @@ public class MatchingMaps {
31
37
* For example:
32
38
* <pre>assertThat(myMap, is(anEmptyMap()))</pre>
33
39
*/
34
- public static <K , V > org . hamcrest . Matcher <java . util . Map <? extends K , ? extends V >> anEmptyMap () {
35
- return org . hamcrest . collection . IsMapWithSize . anEmptyMap ( );
40
+ public static <K , V > Matcher <Map <? extends K , ? extends V >> anEmptyMap () {
41
+ return aMapWithSize ( equalTo ( 0 ) );
36
42
}
37
43
38
44
/**
@@ -45,8 +51,8 @@ public class MatchingMaps {
45
51
* @param keyMatcher the key matcher that, in combination with the valueMatcher, must be satisfied by at least one entry
46
52
* @param valueMatcher the value matcher that, in combination with the keyMatcher, must be satisfied by at least one entry
47
53
*/
48
- public static <K , V > org . hamcrest . Matcher <java . util . Map <? extends K , ? extends V >> hasEntry (org . hamcrest . Matcher <? super K > keyMatcher , org . hamcrest . Matcher <? super V > valueMatcher ) {
49
- return org . hamcrest . collection . IsMapContaining .hasEntry (keyMatcher , valueMatcher );
54
+ public static <K , V > Matcher <Map <? extends K , ? extends V >> hasEntry (Matcher <? super K > keyMatcher , Matcher <? super V > valueMatcher ) {
55
+ return IsMapContaining .hasEntry (keyMatcher , valueMatcher );
50
56
}
51
57
52
58
/**
@@ -59,8 +65,8 @@ public class MatchingMaps {
59
65
* @param key the key that, in combination with the value, must be describe at least one entry
60
66
* @param value the value that, in combination with the key, must be describe at least one entry
61
67
*/
62
- public static <K , V > org . hamcrest . Matcher <java . util . Map <? extends K , ? extends V >> hasEntry (K key , V value ) {
63
- return org . hamcrest . collection . IsMapContaining .hasEntry (key , value );
68
+ public static <K , V > Matcher <Map <? extends K , ? extends V >> hasEntry (K key , V value ) {
69
+ return IsMapContaining .hasEntry (key , value );
64
70
}
65
71
66
72
/**
@@ -71,8 +77,8 @@ public class MatchingMaps {
71
77
*
72
78
* @param keyMatcher the matcher that must be satisfied by at least one key
73
79
*/
74
- public static <K > org .hamcrest .Matcher <java . util . Map <? extends K , ?>> hasKey (org . hamcrest . Matcher <? super K > keyMatcher ) {
75
- return org . hamcrest . collection . IsMapContaining .hasKey (keyMatcher );
80
+ public static <K > org .hamcrest .Matcher <Map <? extends K , ?>> hasKey (Matcher <? super K > keyMatcher ) {
81
+ return IsMapContaining .hasKey (keyMatcher );
76
82
}
77
83
78
84
/**
@@ -83,8 +89,8 @@ public class MatchingMaps {
83
89
*
84
90
* @param key the key that satisfying maps must contain
85
91
*/
86
- public static <K > org .hamcrest .Matcher <java . util . Map <? extends K , ?>> hasKey (K key ) {
87
- return org . hamcrest . collection . IsMapContaining .hasKey (key );
92
+ public static <K > org .hamcrest .Matcher <Map <? extends K , ?>> hasKey (K key ) {
93
+ return IsMapContaining .hasKey (key );
88
94
}
89
95
90
96
/**
@@ -95,8 +101,8 @@ public class MatchingMaps {
95
101
*
96
102
* @param valueMatcher the matcher that must be satisfied by at least one value
97
103
*/
98
- public static <V > org .hamcrest .Matcher <java . util . Map <?, ? extends V >> hasValue (org . hamcrest . Matcher <? super V > valueMatcher ) {
99
- return org . hamcrest . collection . IsMapContaining .hasValue (valueMatcher );
104
+ public static <V > org .hamcrest .Matcher <Map <?, ? extends V >> hasValue (Matcher <? super V > valueMatcher ) {
105
+ return IsMapContaining .hasValue (valueMatcher );
100
106
}
101
107
102
108
/**
@@ -107,8 +113,8 @@ public class MatchingMaps {
107
113
*
108
114
* @param value the value that satisfying maps must contain
109
115
*/
110
- public static <V > org .hamcrest .Matcher <java . util . Map <?, ? extends V >> hasValue (V value ) {
111
- return org . hamcrest . collection . IsMapContaining .hasValue (value );
116
+ public static <V > org .hamcrest .Matcher <Map <?, ? extends V >> hasValue (V value ) {
117
+ return IsMapContaining .hasValue (value );
112
118
}
113
119
114
120
}
0 commit comments