public class MapAssert<K,V> extends AbstractAssert<MapAssert<K,V>,Map<K,V>> implements EnumerableAssert<MapAssert<K,V>,MapEntry>
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... entries)
Verifies that the actual map contains the given entries, in any order.
|
MapAssert<K,V> |
containsKey(K key)
Verifies that the actual map contains the given key.
|
MapAssert<K,V> |
containsValue(V value)
Verifies that the actual map contains the given value.
|
MapAssert<K,V> |
doesNotContain(MapEntry... entries)
Verifies that the actual map does not contain the given entries.
|
MapAssert<K,V> |
doesNotContainKey(K key)
Verifies that the actual map does not contain the given key.
|
MapAssert<K,V> |
doesNotContainValue(V value)
Verifies that the actual map does not contain the given value.
|
MapAssert<K,V> |
hasSameSizeAs(Iterable<?> other)
Verifies that the actual group has the same size as given
Iterable . |
MapAssert<K,V> |
hasSameSizeAs(Object[] other)
Verifies that the actual group has the same size as given array.
|
MapAssert<K,V> |
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.
|
MapAssert<K,V> |
isNotEmpty()
Verifies that the actual group of values is not empty.
|
void |
isNullOrEmpty()
Verifies that the actual group of values is
null or empty. |
MapAssert<K,V> |
usingDefaultElementComparator()
Revert to standard comparison for incoming assertion group element checks.
|
MapAssert<K,V> |
usingElementComparator(Comparator<? super MapEntry> customComparator)
Use given custom comparator instead of relying on actual type A
equals method to compare group elements for
incoming assertion checks. |
as, as, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, 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<MapAssert<K,V>,MapEntry>
public void isEmpty()
public MapAssert<K,V> isNotEmpty()
isNotEmpty
in interface EnumerableAssert<MapAssert<K,V>,MapEntry>
this
assertion object.public MapAssert<K,V> hasSize(int expected)
public MapAssert<K,V> hasSameSizeAs(Object[] other)
hasSameSizeAs
in interface EnumerableAssert<MapAssert<K,V>,MapEntry>
other
- the array to compare size with actual group.this
assertion object.public MapAssert<K,V> hasSameSizeAs(Iterable<?> other)
Iterable
.hasSameSizeAs
in interface EnumerableAssert<MapAssert<K,V>,MapEntry>
other
- the Iterable
to compare size with actual group.this
assertion object.public MapAssert<K,V> contains(MapEntry... entries)
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 MapAssert<K,V> doesNotContain(MapEntry... entries)
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 MapAssert<K,V> 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 MapAssert<K,V> doesNotContainKey(K key)
key
- the given keyAssertionError
- if the actual map is null
.AssertionError
- if the actual map contains the given key.public MapAssert<K,V> containsValue(V value)
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 MapAssert<K,V> doesNotContainValue(V value)
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 MapAssert<K,V> usingElementComparator(Comparator<? super MapEntry> customComparator)
equals
method to compare group elements for
incoming assertion checks.
Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy.
Examples :
// compares invoices by payee assertThat(invoiceList).usingComparator(invoicePayeeComparator).isEqualTo(expectedInvoiceList). // compares invoices by date, doesNotHaveDuplicates and contains both use the given invoice date comparator assertThat(invoiceList).usingComparator(invoiceDateComparator).doesNotHaveDuplicates().contains(may2010Invoice) // as assertThat(invoiceList) creates a new assertion, it falls back to standard comparison strategy // based on Invoice's equal method to compare invoiceList elements to lowestInvoice. assertThat(invoiceList).contains(lowestInvoice). // standard comparison : the fellowshipOfTheRing includes Gandalf but not Sauron (believe me) ... assertThat(fellowshipOfTheRing).contains(gandalf) .doesNotContain(sauron); // ... but if we compare only races, Sauron is in fellowshipOfTheRing because he's a Maia like Gandalf. assertThat(fellowshipOfTheRing).usingElementComparator(raceComparator) .contains(sauron);
usingElementComparator
in interface EnumerableAssert<MapAssert<K,V>,MapEntry>
customComparator
- the comparator to use for incoming assertion checks.this
assertion object.public MapAssert<K,V> usingDefaultElementComparator()
This method should be used to disable a custom comparison strategy set by calling EnumerableAssert.usingElementComparator(Comparator)
.
usingDefaultElementComparator
in interface EnumerableAssert<MapAssert<K,V>,MapEntry>
this
assertion object.Copyright © 2013 AssertJ. All Rights Reserved.