Package com.google.common.truth
Class MapSubject.UsingCorrespondence<A,E>
- java.lang.Object
-
- com.google.common.truth.MapSubject.UsingCorrespondence<A,E>
-
- Enclosing class:
- MapSubject
public final class MapSubject.UsingCorrespondence<A,E> extends java.lang.ObjectA partially specified check in which the actual values (i.e. the values of theMapunder test) are compared to expected values using aCorrespondence. The expected values are of typeE. 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 Modifier and Type Field Description private Correspondence<? super A,? super E>correspondence
-
Constructor Summary
Constructors Modifier Constructor Description privateUsingCorrespondence(Correspondence<? super A,? super E> correspondence)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OrderedcontainsAtLeast(java.lang.Object k0, E v0, java.lang.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.OrderedcontainsAtLeastEntriesIn(java.util.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.voidcontainsEntry(java.lang.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.OrderedcontainsExactly(java.lang.Object k0, E v0, java.lang.Object... rest)Fails if the map does not contain exactly the given set of keys mapping to values that correspond to the given values.OrderedcontainsExactlyEntriesIn(java.util.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.voiddoesNotContainEntry(java.lang.Object excludedKey, E excludedValue)Fails if the map contains an entry with the given key and a value that corresponds to the given value.private java.util.Map<?,A>getCastSubject()private <K,V extends E>
OrderedinternalContainsEntriesIn(java.lang.String modifier, java.util.Map<K,V> expectedMap, boolean allowUnexpected)private <V extends E>
com.google.common.base.Function<MapSubject.ValueDifference<A,V>,java.lang.String>valueDiffFormat(Correspondence.ExceptionStore exceptions)Returns a formatting function for value differences when compared using the current correspondence.
-
-
-
Field Detail
-
correspondence
private final Correspondence<? super A,? super E> correspondence
-
-
Constructor Detail
-
UsingCorrespondence
private UsingCorrespondence(Correspondence<? super A,? super E> correspondence)
-
-
Method Detail
-
containsEntry
public void containsEntry(java.lang.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.
-
doesNotContainEntry
public void doesNotContainEntry(java.lang.Object excludedKey, E excludedValue)Fails if the map contains an entry with the given key and a value that corresponds to the given value.
-
containsExactly
public Ordered containsExactly(java.lang.Object k0, E v0, java.lang.Object... rest)
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 aClassCastExceptionwill 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
public Ordered containsAtLeast(java.lang.Object k0, E v0, java.lang.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.The values must all be of type
E, and aClassCastExceptionwill 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
public Ordered containsExactlyEntriesIn(java.util.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.
-
containsAtLeastEntriesIn
public Ordered containsAtLeastEntriesIn(java.util.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.
-
internalContainsEntriesIn
private <K,V extends E> Ordered internalContainsEntriesIn(java.lang.String modifier, java.util.Map<K,V> expectedMap, boolean allowUnexpected)
-
valueDiffFormat
private final <V extends E> com.google.common.base.Function<MapSubject.ValueDifference<A,V>,java.lang.String> valueDiffFormat(Correspondence.ExceptionStore exceptions)
Returns a formatting function for value differences when compared using the current correspondence.
-
getCastSubject
private java.util.Map<?,A> getCastSubject()
-
-