public class MapAssert<K,V> extends AbstractMapAssert<MapAssert<K,V>,Map<K,V>,K,V>
Map
s.
To create a new instance of this class, invoke
.
Assertions.assertThat(Map)
actual, info, myself
Modifier | Constructor and Description |
---|---|
protected |
MapAssert(Map<K,V> actual) |
Modifier and Type | Method and Description |
---|---|
MapAssert<K,V> |
contains(MapEntry<? extends K,? extends V>... entries)
Verifies that the actual map contains the given entries, in any order.
|
MapAssert<K,V> |
containsExactly(MapEntry<? extends K,? extends V>... entries)
Verifies that the actual map contains only the given entries and nothing else, in order.
This assertion should only be used with map that have a consistent iteration order (i.e. |
MapAssert<K,V> |
containsKeys(K... keys)
Verifies that the actual map contains the given keys.
|
MapAssert<K,V> |
containsOnly(MapEntry<? extends K,? extends V>... entries)
Verifies that the actual map contains only the given entries and nothing else, in any order.
|
MapAssert<K,V> |
containsOnlyKeys(K... keys)
Verifies that the actual map contains only the given keys and nothing else, in any order.
|
MapAssert<K,V> |
containsValues(V... values)
Verifies that the actual map contains the given values.
|
MapAssert<K,V> |
doesNotContain(MapEntry<? extends K,? extends V>... entries)
Verifies that the actual map does not contain the given entries.
|
MapAssert<K,V> |
doesNotContainKeys(K... keys)
Verifies that the actual map does not contain any of the given keys.
|
containsEntry, containsKey, containsValue, doesNotContainEntry, doesNotContainKey, doesNotContainValue, hasSameSizeAs, hasSameSizeAs, hasSameSizeAs, hasSize, isEmpty, isNotEmpty, isNullOrEmpty, usingDefaultElementComparator, usingElementComparator
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, overridingErrorMessage, usingComparator, usingDefaultComparator, withThreadDumpOnError
@SafeVarargs public final MapAssert<K,V> contains(MapEntry<? extends K,? extends V>... entries)
AbstractMapAssert
Example :
Map ringBearers = ... // init with elves rings and the one ring
assertThat(ringBearers).contains(entry(oneRing, frodo), entry(nenya, galadriel));
@SafeVarargs public final MapAssert<K,V> containsOnly(MapEntry<? extends K,? extends V>... entries)
AbstractMapAssert
Examples :
Map ringBearers = ... // init with elves rings and the one ring
// assertion will pass
assertThat(ringBearers).containsOnly(entry(oneRing, frodo), entry(nenya, galadriel), entry(narya, gandalf), entry(vilya, elrond));
// assertion will fail
assertThat(ringBearers).containsOnly(entry(oneRing, frodo), entry(nenya, galadriel));
containsOnly
in class AbstractMapAssert<MapAssert<K,V>,Map<K,V>,K,V>
entries
- the entries that should be in the actual map.@SafeVarargs public final MapAssert<K,V> containsExactly(MapEntry<? extends K,? extends V>... entries)
AbstractMapAssert
HashMap
, prefer AbstractMapAssert.containsOnly(org.assertj.core.data.MapEntry...)
in that case).
Example :
Map<Ring, TolkienCharacter> ringBearers = newLinkedHashMap(entry(oneRing, frodo), entry(nenya, galadriel),
entry(narya, gandalf));
// assertion will pass
assertThat(ringBearers).containsExactly(entry(oneRing, frodo), entry(nenya, galadriel), entry(narya, gandalf));
// assertion will fail as actual and expected orders differ.
assertThat(ringBearers).containsExactly(entry(nenya, galadriel), entry(narya, gandalf), entry(oneRing, frodo));
containsExactly
in class AbstractMapAssert<MapAssert<K,V>,Map<K,V>,K,V>
entries
- the given entries.@SafeVarargs public final MapAssert<K,V> containsKeys(K... keys)
AbstractMapAssert
Example :
Map ringBearers = ... // init with elves rings and the one ring
assertThat(ringBearers).containsKeys(nenya, oneRing);
containsKeys
in class AbstractMapAssert<MapAssert<K,V>,Map<K,V>,K,V>
keys
- the given keys@SafeVarargs public final MapAssert<K,V> containsOnlyKeys(K... keys)
AbstractMapAssert
Examples :
Map ringBearers = ... // init with elves rings and the one ring
// assertion will pass
assertThat(ringBearers).containsOnlyKeys(oneRing, nenya, narya, vilya);
// assertion will fail
assertThat(ringBearers).containsOnlyKeys(oneRing, nenya);
containsOnlyKeys
in class AbstractMapAssert<MapAssert<K,V>,Map<K,V>,K,V>
keys
- the given keys that should be in the actual map.@SafeVarargs public final MapAssert<K,V> containsValues(V... values)
AbstractMapAssert
Example :
Map ringBearers = ... // init with elves rings and the one ring
assertThat(ringBearers).containsValues(frodo, galadriel);
containsValues
in class AbstractMapAssert<MapAssert<K,V>,Map<K,V>,K,V>
values
- the values to look for in the actual map.@SafeVarargs public final MapAssert<K,V> doesNotContainKeys(K... keys)
AbstractMapAssert
Example :
Map ringBearers = ... // init with elves rings only
assertThat(ringBearers).doesNotContainKeys(oneRing, someManRing);
doesNotContainKeys
in class AbstractMapAssert<MapAssert<K,V>,Map<K,V>,K,V>
@SafeVarargs public final MapAssert<K,V> doesNotContain(MapEntry<? extends K,? extends V>... entries)
AbstractMapAssert
Example :
Map ringBearers = ... // init omitted
assertThat(ringBearers).doesNotContain(entry(oneRing, aragorn));
doesNotContain
in class AbstractMapAssert<MapAssert<K,V>,Map<K,V>,K,V>
entries
- the given entries.this
assertion object.Copyright © 2013-2015 AssertJ. All Rights Reserved.