Package org.elasticsearch.test
Class 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> voidAssert match.static <T> voidassertMap(T actual, org.hamcrest.Matcher<? super T> matcher) Assert match.protected voiddescribeMismatchSafely(Map<?, ?> item, org.hamcrest.Description description) Expect a value.Expect aMatcher.extraOk()Ignore extra entries.static MapMatcherCreate a MapMatcher that matches emptyMaps.static MapMatchermatchesMap(Map<?, ?> map) Create a MapMatcher that matches aMap.protected booleanmatchesSafely(Map<?, ?> item) Methods inherited from class org.hamcrest.TypeSafeMatcher
describeMismatch, matchesMethods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
-
Method Details
-
matchesMap
Create a MapMatcher that matches emptyMaps. -
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 provideLinkedHashMapor aTreeMapor some otherMapthat 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 forMapMatcherandListMatcher. -
assertMap
Assert match. Shorter output on failure thanMatcherAssert.assertThat(Object, Matcher)that looks better forMapMatcherandListMatcher. -
extraOk
Ignore extra entries.- Returns:
- a new
MapMatcherthat will not fail if it encounters extra entries
-
entry
Expect a value.Passing a
Matcherto this method will function as though you passed it directly toentry(Object, Matcher).- Returns:
- a new
MapMatcherthat expects another entry
-
entry
Expect aMatcher.- Returns:
- a new
MapMatcherthat expects another entry
-
matchesSafely
- Specified by:
matchesSafelyin classorg.hamcrest.TypeSafeMatcher<Map<?,?>>
-
describeMismatchSafely
- Overrides:
describeMismatchSafelyin classorg.hamcrest.TypeSafeMatcher<Map<?,?>>
-