Class MapContentMatchers<T,V>
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<Map<? super T,? super V>>
org.springframework.integration.test.matcher.MapContentMatchers<T,V>
- All Implemented Interfaces:
org.hamcrest.Matcher<Map<? super T,
,? super V>> org.hamcrest.SelfDescribing
public final class MapContentMatchers<T,V>
extends org.hamcrest.TypeSafeMatcher<Map<? super T,? super V>>
Matchers that examine the contents of a
Map
.
It is possible to match a single entry by value or matcher like this:
assertThat(map, hasEntry(SOME_KEY, is(SOME_VALUE))); assertThat(map, hasEntry(SOME_KEY, is(String.class))); assertThat(map, hasEntry(SOME_KEY, notNullValue()));
It's also possible to match multiple entries in a map:
Map<String, Object> expectedInMap = new HashMap<String, Object>();
expectedInMap.put(SOME_KEY, SOME_VALUE);
expectedInMap.put(OTHER_KEY, is(OTHER_VALUE));
assertThat(map, hasAllEntries(expectedInMap));
If you only need to verify the existence of a key:
assertThat(map, hasKey(SOME_KEY));
- Author:
- Alex Peters, Iwein Fuld, Gunnar Hillert, Artem Bilan, Gary Russell
-
Method Summary
Modifier and TypeMethodDescriptionvoid
describeTo
(org.hamcrest.Description description) static <T,
V> org.hamcrest.Matcher<Map<T, V>> hasAllEntries
(Map<T, V> entries) boolean
matchesSafely
(Map<? super T, ? super V> item) Methods inherited from class org.hamcrest.TypeSafeMatcher
describeMismatch, describeMismatchSafely, matches
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString