public final class MapContentMatchers<T,V> extends org.hamcrest.TypeSafeMatcher<MapSE<? super T,? super V>>
Map
SE の内容を調べるマッチャー。次のように、値またはマッチャーによって単一のエントリを照合することができます。
assertThat(map, hasEntry(SOME_KEY, is(SOME_VALUE))); assertThat(map, hasEntry(SOME_KEY, is(String.class))); assertThat(map, hasEntry(SOME_KEY, notNullValue()));
マップ内の複数のエントリを照合することもできます。
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));
キーの存在を確認するだけでよい場合:
assertThat(map, hasKey(SOME_KEY));
修飾子と型 | メソッドと説明 |
---|---|
void | describeTo(org.hamcrest.Description description) |
static <T,V> org.hamcrest.Matcher<MapSE<T,V>> | hasAllEntries(MapSE<T,V> entries) |
boolean | matchesSafely(MapSE<? super T,? super V> item) |
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE