Package com.google.common.truth
Class MapSubject.UsingCorrespondence<A,E>
java.lang.Object
com.google.common.truth.MapSubject.UsingCorrespondence<A,E>
- Enclosing class:
MapSubject
A partially specified check in which the actual values (i.e. the values of the
Map
under test) are compared to expected values using a Correspondence
. The expected values
are of type E
. Call methods on this object to actually execute the check.
Note that keys will always be compared with regular object equality (Object.equals(java.lang.Object)
).
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
UsingCorrespondence
(Correspondence<? super A, ? super E> correspondence) -
Method Summary
Modifier and TypeMethodDescriptioncontainsAtLeast
(Object k0, E v0, Object... rest) Fails if the map does not contain at least the given set of keys mapping to values that correspond to the given values.containsAtLeastEntriesIn
(Map<?, ? extends E> expectedMap) Fails if the map does not contain at least the keys in the given map, mapping to values that correspond to the values of the given map.void
containsEntry
(Object expectedKey, E expectedValue) Fails if the map does not contain an entry with the given key and a value that corresponds to the given value.containsExactly
(Object k0, E v0, Object... rest) Fails if the map does not contain exactly the given set of keys mapping to values that correspond to the given values.containsExactlyEntriesIn
(Map<?, ? extends E> expectedMap) Fails if the map does not contain exactly the keys in the given map, mapping to values that correspond to the values of the given map.void
doesNotContainEntry
(Object excludedKey, E excludedValue) Fails if the map contains an entry with the given key and a value that corresponds to the given value.internalContainsEntriesIn
(String modifier, Map<K, V> expectedMap, boolean allowUnexpected) private final <V extends E>
com.google.common.base.Function<MapSubject.ValueDifference<A, V>, String> valueDiffFormat
(Correspondence.ExceptionStore exceptions) Returns a formatting function for value differences when compared using the current correspondence.
-
Field Details
-
correspondence
-
-
Constructor Details
-
UsingCorrespondence
-
-
Method Details
-
containsEntry
Fails if the map does not contain an entry with the given key and a value that corresponds to the given value. -
doesNotContainEntry
Fails if the map contains an entry with the given key and a value that corresponds to the given value. -
containsExactly
Fails if the map does not contain exactly the given set of keys mapping to values that correspond to the given values.The values must all be of type
E
, and aClassCastException
will be thrown if any other type is encountered.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!
-
containsAtLeast
Fails if the map does not contain at least the given set of keys mapping to values that correspond to the given values.The values must all be of type
E
, and aClassCastException
will be thrown if any other type is encountered.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!
-
containsExactlyEntriesIn
Fails if the map does not contain exactly the keys in the given map, mapping to values that correspond to the values of the given map. -
containsAtLeastEntriesIn
Fails if the map does not contain at least the keys in the given map, mapping to values that correspond to the values of the given map. -
internalContainsEntriesIn
-
valueDiffFormat
private final <V extends E> com.google.common.base.Function<MapSubject.ValueDifference<A,V>, valueDiffFormatString> (Correspondence.ExceptionStore exceptions) Returns a formatting function for value differences when compared using the current correspondence. -
getCastSubject
-