Package org.elasticsearch.test
Class MapMatcher
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<Map<?,?>>
org.elasticsearch.test.MapMatcher
- All Implemented Interfaces:
org.hamcrest.Matcher<Map<?,
,?>> org.hamcrest.SelfDescribing
Matcher for
Maps
that reports all errors at once.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
Assert match.static <T> void
assertMap
(T actual, org.hamcrest.Matcher<? super T> matcher) Assert match.protected void
describeMismatchSafely
(Map<?, ?> item, org.hamcrest.Description description) Expect a value.Expect aMatcher
.extraOk()
Ignore extra entries.static MapMatcher
Create a MapMatcher that matches emptyMap
s.static MapMatcher
matchesMap
(Map<?, ?> map) Create a MapMatcher that matches aMap
.protected boolean
matchesSafely
(Map<?, ?> item) Methods inherited from class org.hamcrest.TypeSafeMatcher
describeMismatch, matches
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
-
Method Details
-
matchesMap
Create a MapMatcher that matches emptyMap
s. -
matchesMap
Create a MapMatcher that matches aMap
.The description and mismatch message are sorted as
Map.entrySet()
because error messages with a consistent order are easier to debug. So you should care about this order and provideLinkedHashMap
or aTreeMap
or some otherMap
that has a nice order. Or build an empty matcher withmatchesMap()
and fill it in the order you like by callingentry
. -
assertMap
public static <T> void assertMap(T actual, org.hamcrest.Matcher<? super T> matcher) Assert match. Shorter output on failure thanMatcherAssert.assertThat(Object, Matcher)
that looks better forMapMatcher
andListMatcher
. -
assertMap
Assert match. Shorter output on failure thanMatcherAssert.assertThat(Object, Matcher)
that looks better forMapMatcher
andListMatcher
. -
extraOk
Ignore extra entries.- Returns:
- a new
MapMatcher
that will not fail if it encounters extra entries
-
entry
Expect a value.Passing a
Matcher
to this method will function as though you passed it directly toentry(Object, Matcher)
.- Returns:
- a new
MapMatcher
that expects another entry
-
entry
Expect aMatcher
.- Returns:
- a new
MapMatcher
that expects another entry
-
matchesSafely
- Specified by:
matchesSafely
in classorg.hamcrest.TypeSafeMatcher<Map<?,
?>>
-
describeMismatchSafely
- Overrides:
describeMismatchSafely
in classorg.hamcrest.TypeSafeMatcher<Map<?,
?>>
-