public class MapSubject extends Subject<MapSubject,Map<?,?>>
Map
subjects.Modifier and Type | Class and Description |
---|---|
class |
MapSubject.UsingCorrespondence<A,E>
A partially specified check in which the actual values (i.e.
|
Subject.Factory<SubjectT extends Subject,ActualT>
Modifier | Constructor and Description |
---|---|
protected |
MapSubject(FailureMetadata metadata,
Map<?,?> map)
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
<A,E> MapSubject.UsingCorrespondence<A,E> |
comparingValuesUsing(Correspondence<? super A,? super E> correspondence)
Starts a method chain for a check in which the actual values (i.e.
|
Ordered |
containsAtLeast(Object k0,
Object v0,
Object... rest) |
Ordered |
containsAtLeastEntriesIn(Map<?,?> expectedMap)
Fails if the map does not contain at least the given set of entries in the given map.
|
void |
containsEntry(Object key,
Object value)
Fails if the map does not contain the given entry.
|
Ordered |
containsExactly()
Fails if the map is not empty.
|
Ordered |
containsExactly(Object k0,
Object v0,
Object... rest)
Fails if the map does not contain exactly the given set of key/value pairs.
|
Ordered |
containsExactlyEntriesIn(Map<?,?> expectedMap)
Fails if the map does not contain exactly the given set of entries in the given map.
|
void |
containsKey(Object key)
Fails if the map does not contain the given key.
|
void |
doesNotContainEntry(Object key,
Object value)
Fails if the map contains the given entry.
|
void |
doesNotContainKey(Object key)
Fails if the map contains the given key.
|
void |
hasSize(int expectedSize)
Fails if the map does not have the given size.
|
void |
isEmpty()
Fails if the map is not empty.
|
void |
isEqualTo(Object other)
Fails if the subject is not equal to the given object.
|
void |
isNotEmpty()
Fails if the map is empty.
|
actual, actualAsString, actualCustomStringRepresentation, check, equals, failWithActual, failWithActual, failWithoutActual, getSubject, hashCode, ignoreCheck, internalCustomName, isAnyOf, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, named, toString
protected MapSubject(FailureMetadata metadata, @NullableDecl Map<?,?> map)
Subject.check()
.that(actual)
.public final void isEqualTo(@NullableDecl Object other)
isEqualTo
in class Subject<MapSubject,Map<?,?>>
public final void isEmpty()
public final void isNotEmpty()
public final void hasSize(int expectedSize)
public final void containsKey(@NullableDecl Object key)
public final void doesNotContainKey(@NullableDecl Object key)
public final void containsEntry(@NullableDecl Object key, @NullableDecl Object value)
public final void doesNotContainEntry(@NullableDecl Object key, @NullableDecl Object value)
@CanIgnoreReturnValue public final Ordered containsExactly()
@CanIgnoreReturnValue public final Ordered containsExactly(@NullableDecl Object k0, @NullableDecl Object v0, Object... rest)
Warning: the use of varargs means that we cannot guarantee an equal number of key/value pairs at compile time. Please make sure you provide varargs in key/value pairs!
The arguments must not contain duplicate keys.
@CanIgnoreReturnValue public final Ordered containsAtLeast(@NullableDecl Object k0, @NullableDecl Object v0, Object... rest)
@CanIgnoreReturnValue public final Ordered containsExactlyEntriesIn(Map<?,?> expectedMap)
@CanIgnoreReturnValue public final Ordered containsAtLeastEntriesIn(Map<?,?> expectedMap)
public final <A,E> MapSubject.UsingCorrespondence<A,E> comparingValuesUsing(Correspondence<? super A,? super E> correspondence)
Map
under test) are compared to expected values using the given Correspondence
. The
actual values must be of type A
, the expected values must be of type E
. The
check is actually executed by continuing the method chain. For example:
assertThat(actualMap)
.comparingValuesUsing(correspondence)
.containsEntry(expectedKey, expectedValue);
where actualMap
is a Map<?, A>
(or, more generally, a Map<?, ? extends
A>
), correspondence
is a Correspondence<A, E>
, and expectedValue
is an
E
.
Note that keys will always be compared with regular object equality (Object.equals(java.lang.Object)
).
Any of the methods on the returned object may throw ClassCastException
if they
encounter an actual value that is not of type A
or an expected value that is not of
type E
.
Copyright © 2019. All rights reserved.