S
- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation"
for more details.A
- the type of the "actual" value.K
- the type of keys in map.V
- the type of values in map.public abstract class AbstractMapAssert<S extends AbstractMapAssert<S,A,K,V>,A extends Map<K,V>,K,V> extends AbstractAssert<S,A> implements EnumerableAssert<S,MapEntry>
Map
s.actual, info, myself
Modifier | Constructor and Description |
---|---|
protected |
AbstractMapAssert(A actual,
Class<?> selfType) |
Modifier and Type | Method and Description |
---|---|
S |
contains(MapEntry... entries)
Verifies that the actual map contains the given entries, in any order.
|
S |
containsEntry(K key,
V value)
Verifies that the actual map contains the given entry.
|
S |
containsExactly(MapEntry... 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. |
S |
containsKey(K key)
Verifies that the actual map contains the given key.
|
S |
containsKeys(K... keys)
Verifies that the actual map contains the given keys.
|
S |
containsOnly(MapEntry... entries)
Verifies that the actual map contains only the given entries and nothing else, in any order.
|
S |
containsOnlyKeys(K... keys)
Verifies that the actual map contains only the given keys and nothing else, in any order.
|
S |
containsValue(V value)
Verifies that the actual map contains the given value.
|
S |
doesNotContain(MapEntry... entries)
Verifies that the actual map does not contain the given entries.
|
S |
doesNotContainEntry(K key,
V value)
Verifies that the actual map does not contain the given entry.
|
S |
doesNotContainKey(K key)
Verifies that the actual map does not contain the given key.
|
S |
doesNotContainValue(V value)
Verifies that the actual map does not contain the given value.
|
S |
hasSameSizeAs(Iterable<?> other)
Verifies that the actual group has the same size as given
Iterable . |
S |
hasSameSizeAs(Map<?,?> other)
Verifies that the actual map has the same size as the given
Map . |
S |
hasSameSizeAs(Object other)
Verifies that the actual group has the same size as given array.
|
S |
hasSize(int expected)
Verifies that the number of values in the actual group is equal to the given one.
|
void |
isEmpty()
Verifies that the actual group of values is empty.
|
S |
isNotEmpty()
Verifies that the actual group of values is not empty.
|
void |
isNullOrEmpty()
Verifies that the actual group of values is
null or empty. |
S |
usingDefaultElementComparator()
Deprecated.
Custom element Comparator is not supported for MapEntry comparison.
|
S |
usingElementComparator(Comparator<? super MapEntry> customComparator)
Deprecated.
Custom element Comparator is not supported for MapEntry comparison.
|
as, as, 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
public void isNullOrEmpty()
null
or empty.isNullOrEmpty
in interface EnumerableAssert<S extends AbstractMapAssert<S,A,K,V>,MapEntry>
public void isEmpty()
isEmpty
in interface EnumerableAssert<S extends AbstractMapAssert<S,A,K,V>,MapEntry>
public S isNotEmpty()
isNotEmpty
in interface EnumerableAssert<S extends AbstractMapAssert<S,A,K,V>,MapEntry>
this
assertion object.public S hasSize(int expected)
hasSize
in interface EnumerableAssert<S extends AbstractMapAssert<S,A,K,V>,MapEntry>
expected
- the expected number of values in the actual group.this
assertion object.public S hasSameSizeAs(Object other)
hasSameSizeAs
in interface EnumerableAssert<S extends AbstractMapAssert<S,A,K,V>,MapEntry>
other
- the array to compare size with actual group.this
assertion object.public S hasSameSizeAs(Iterable<?> other)
Iterable
.hasSameSizeAs
in interface EnumerableAssert<S extends AbstractMapAssert<S,A,K,V>,MapEntry>
other
- the Iterable
to compare size with actual group.this
assertion object.public S hasSameSizeAs(Map<?,?> other)
Map
.
Example :
MapringBearers = ... // init with elves rings and the one ring assertThat(ringBearers).hasSameSizeAs(mapOf(entry(oneRing, frodo), entry(narya, gandalf), entry(nenya, galadriel), entry(vilya, elrond)));
other
- the Map
to compare size with actual mapthis
assertion objectNullPointerException
- if the other Map
is null
AssertionError
- if the actual map is null
AssertionError
- if the actual map and the given Map
don't have the same sizepublic S contains(MapEntry... entries)
Example :
MapringBearers = ... // init with elves rings and the one ring assertThat(ringBearers).contains(entry(oneRing, frodo), entry(nenya, galadriel));
entries
- the given entries.this
assertion object.NullPointerException
- if the given argument is null
.IllegalArgumentException
- if the given argument is an empty array.NullPointerException
- if any of the entries in the given array is null
.AssertionError
- if the actual map is null
.AssertionError
- if the actual map does not contain the given entries.public S containsEntry(K key, V value)
Example :
MapringBearers = ... // init with elves rings and the one ring assertThat(ringBearers).containsEntry(oneRing, frodo).containsEntry(nenya, galadriel);
key
- the given key to check.value
- the given value to check.this
assertion object.NullPointerException
- if the given argument is null
.IllegalArgumentException
- if the given argument is an empty array.NullPointerException
- if any of the entries in the given array is null
.AssertionError
- if the actual map is null
.AssertionError
- if the actual map does not contain the given entries.public S doesNotContain(MapEntry... entries)
Example :
MapringBearers = ... // init omitted assertThat(ringBearers).doesNotContain(entry(oneRing, aragorn));
entries
- the given entries.this
assertion object.NullPointerException
- if the given argument is null
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual map is null
.AssertionError
- if the actual map contains any of the given entries.public S doesNotContainEntry(K key, V value)
Example :
MapringBearers = ... // init with elves rings and the one ring assertThat(ringBearers).doesNotContainEntry(oneRing, aragorn);
key
- key of the entry.value
- value of the entry.this
assertion object.NullPointerException
- if the given argument is null
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual map is null
.AssertionError
- if the actual map contains any of the given entries.public S containsKey(K key)
key
- the given keyAssertionError
- if the actual map is null
.AssertionError
- if the actual map does not contain the given key.public S containsKeys(K... keys)
keys
- the given keysAssertionError
- if the actual map is null
.AssertionError
- if the actual map does not contain the given key.IllegalArgumentException
- if the given argument is an empty array.public S doesNotContainKey(K key)
key
- the given keyAssertionError
- if the actual map is null
.AssertionError
- if the actual map contains the given key.public S containsOnlyKeys(K... keys)
Examples :
MapringBearers = ... // 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);
keys
- the given keys that should be in the actual map.AssertionError
- if the actual map is null
.AssertionError
- if the actual map does not contain the given keys, i.e. the actual map contains some or none
of the given keys, or the actual map contains more entries than the given ones.IllegalArgumentException
- if the given argument is an empty array.public S containsValue(V value)
MapringBearers = ... // init with elves rings and the one ring assertThat(ringBearers).containsValue(frodo);
value
- the value to look for.AssertionError
- if the actual map is null
.AssertionError
- if the actual map does not contain the given value.public S doesNotContainValue(V value)
MapringBearers = ... // init with elves rings and the one ring assertThat(ringBearers).doesNotContainValue(aragorn);
value
- the value that should not be in actual map.AssertionError
- if the actual map is null
.AssertionError
- if the actual map contains the given value.public S containsOnly(MapEntry... entries)
Examples :
MapringBearers = ... // 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));
entries
- the entries that should be in the actual map.AssertionError
- if the actual map is null
.NullPointerException
- if the given argument is null
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual map does not contain the given entries, i.e. the actual map contains some or
none of the given entries, or the actual map contains more entries than the given ones.public S containsExactly(MapEntry... entries)
HashMap
, prefer 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));
entries
- the given entries.NullPointerException
- if the given entries array is null
.AssertionError
- if the actual map is null
.IllegalArgumentException
- if the given entries array is empty.AssertionError
- if the actual map does not contain the given entries with same order, i.e. the actual map
contains some or none of the given entries, or the actual map contains more entries than the given ones
or entries are the same but the order is not.@Deprecated public final S usingElementComparator(Comparator<? super MapEntry> customComparator)
usingElementComparator
in interface EnumerableAssert<S extends AbstractMapAssert<S,A,K,V>,MapEntry>
customComparator
- the comparator to use for incoming assertion checks.this
assertion object.UnsupportedOperationException
- if this method is called.@Deprecated public final S usingDefaultElementComparator()
usingDefaultElementComparator
in interface EnumerableAssert<S extends AbstractMapAssert<S,A,K,V>,MapEntry>
this
assertion object.UnsupportedOperationException
- if this method is called.Copyright © 2013–2014 AssertJ. All rights reserved.