Class AbstractMapTester<K,V>
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
com.google.common.collect.testing.AbstractTester<OneSizeTestContainerGenerator<Map<K,V>,Map.Entry<K,V>>>
com.google.common.collect.testing.AbstractContainerTester<Map<K,V>,Map.Entry<K,V>>
com.google.common.collect.testing.AbstractMapTester<K,V>
- Type Parameters:
K- the key type of the map to be tested.V- the value type of the map to be tested.
- All Implemented Interfaces:
junit.framework.Test
- Direct Known Subclasses:
AbstractBiMapTester,ConcurrentMapPutIfAbsentTester,ConcurrentMapRemoveTester,ConcurrentMapReplaceEntryTester,ConcurrentMapReplaceTester,MapClearTester,MapComputeIfAbsentTester,MapComputeIfPresentTester,MapComputeTester,MapContainsKeyTester,MapContainsValueTester,MapCreationTester,MapEntrySetTester,MapEqualsTester,MapForEachTester,MapGetOrDefaultTester,MapGetTester,MapHashCodeTester,MapIsEmptyTester,MapMergeTester,MapPutAllTester,MapPutIfAbsentTester,MapPutTester,MapRemoveEntryTester,MapRemoveTester,MapReplaceAllTester,MapReplaceEntryTester,MapReplaceTester,MapSerializationTester,MapSizeTester,MapToStringTester,NavigableMapNavigationTester,SortedMapNavigationTester
public abstract class AbstractMapTester<K,V>
extends AbstractContainerTester<Map<K,V>,Map.Entry<K,V>>
Base class for map testers.
TODO: see how much of this is actually needed once Map testers are written. (It was cloned from AbstractCollectionTester.)
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.collect.testing.AbstractContainerTester
AbstractContainerTester.ArrayWithDuplicate<E> -
Field Summary
Fields inherited from class com.google.common.collect.testing.AbstractContainerTester
container, samples -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<Map.Entry<K, V>> protected MinimalCollection<Map.Entry<K, V>> private static booleanprotected voidexpectContents(Collection<Map.Entry<K, V>> expected) Asserts that the collection under test contains exactly the given elements, respecting cardinality but not order.protected voidexpectMissing(Map.Entry<K, V>... entries) protected voidexpectMissingKeys(K... elements) protected voidexpectMissingValues(V... elements) protected voidEquivalent toexpectMissingKeys(null)except that the call tocontains(null)is permitted to throw aNullPointerException.protected voidEquivalent toexpectMissingValues(null)except that the call tocontains(null)is permitted to throw aNullPointerException.protected final voidexpectReplacement(Map.Entry<K, V> newEntry) protected VWrapper forMap.get(Object)that forces the caller to pass in a key of the same type as the map.protected KgetMap()protected intprotected Collection<Map.Entry<K, V>> protected Collection<Map.Entry<K, V>> getSampleEntries(int howMany) protected Vprotected voidprotected voidprotected final Kk0()protected final Kk1()protected final Kk2()protected final Kk3()protected final Kk4()private voidprotected final voidresetMap()protected voidprotected final Vv0()protected final Vv1()protected final Vv2()protected final Vv3()protected final Vv4()Methods inherited from class com.google.common.collect.testing.AbstractContainerTester
createArrayWithDuplicateElement, createOrderedArray, createSamplesArray, e0, e1, e2, e3, e4, emptyCollection, expectAdded, expectAdded, expectAdded, expectContents, expectUnchanged, getNullLocation, getNumElements, getOrderedElements, getSampleElements, getSampleElements, resetContainer, resetContainer, setUpMethods inherited from class com.google.common.collect.testing.AbstractTester
getName, getSubjectGenerator, getTestMethodName, init, init, tearDownMethods inherited from class junit.framework.TestCase
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, run, run, runBare, runTest, setName, toString
-
Constructor Details
-
AbstractMapTester
public AbstractMapTester()
-
-
Method Details
-
getMap
-
actualContents
- Specified by:
actualContentsin classAbstractContainerTester<Map<K,V>, Map.Entry<K, V>> - Returns:
- the contents of the container under test, for use by
expectContents(E...)and its friends.
-
resetMap
protected final void resetMap()- See Also:
-
resetMap
-
expectMissingKeys
-
expectMissingValues
-
createArrayWithNullKey
- Returns:
- an array of the proper size with
nullas the key of the middle element.
-
getValueForNullKey
-
getKeyForNullValue
-
getEntryNullReplaces
-
createArrayWithNullValue
- Returns:
- an array of the proper size with
nullas the value of the middle element.
-
initMapWithNullKey
protected void initMapWithNullKey() -
initMapWithNullValue
protected void initMapWithNullValue() -
expectNullKeyMissingWhenNullKeysUnsupported
Equivalent toexpectMissingKeys(null)except that the call tocontains(null)is permitted to throw aNullPointerException.- Parameters:
message- message to use upon assertion failure
-
expectNullValueMissingWhenNullValuesUnsupported
Equivalent toexpectMissingValues(null)except that the call tocontains(null)is permitted to throw aNullPointerException.- Parameters:
message- message to use upon assertion failure
-
createDisjointCollection
- Overrides:
createDisjointCollectionin classAbstractContainerTester<Map<K,V>, Map.Entry<K, V>>
-
getNumEntries
protected int getNumEntries() -
getSampleEntries
-
getSampleEntries
-
expectMissing
- Overrides:
expectMissingin classAbstractContainerTester<Map<K,V>, Map.Entry<K, V>>
-
equal
-
entry
-
expectContents
Description copied from class:AbstractContainerTesterAsserts that the collection under test contains exactly the given elements, respecting cardinality but not order. Subclasses may override this method to provide stronger assertions, e.g., to check ordering in lists, but realize that unless a test extendsAbstractListTester, a call toexpectContents()invokes this version.- Overrides:
expectContentsin classAbstractContainerTester<Map<K,V>, Map.Entry<K, V>> - Parameters:
expected- expected value ofAbstractContainerTester.container
-
expectReplacement
-
replaceValue
-
get
Wrapper forMap.get(Object)that forces the caller to pass in a key of the same type as the map. Besides being slightly shorter than code that usesgetMap(), it also ensures that callers don't pass anMap.Entryby mistake. -
k0
-
v0
-
k1
-
v1
-
k2
-
v2
-
k3
-
v3
-
k4
-
v4
-