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 boolean
protected void
expectContents
(Collection<Map.Entry<K, V>> expected) Asserts that the collection under test contains exactly the given elements, respecting cardinality but not order.protected void
expectMissing
(Map.Entry<K, V>... entries) protected void
expectMissingKeys
(K... elements) protected void
expectMissingValues
(V... elements) protected void
Equivalent toexpectMissingKeys
(null)
except that the call tocontains(null)
is permitted to throw aNullPointerException
.protected void
Equivalent toexpectMissingValues
(null)
except that the call tocontains(null)
is permitted to throw aNullPointerException
.protected final void
expectReplacement
(Map.Entry<K, V> newEntry) protected V
Wrapper forMap.get(Object)
that forces the caller to pass in a key of the same type as the map.protected K
getMap()
protected int
protected Collection
<Map.Entry<K, V>> protected Collection
<Map.Entry<K, V>> getSampleEntries
(int howMany) protected V
protected void
protected void
protected final K
k0()
protected final K
k1()
protected final K
k2()
protected final K
k3()
protected final K
k4()
private void
protected final void
resetMap()
protected void
protected final V
v0()
protected final V
v1()
protected final V
v2()
protected final V
v3()
protected final V
v4()
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, setUp
Methods inherited from class com.google.common.collect.testing.AbstractTester
getName, getSubjectGenerator, getTestMethodName, init, init, tearDown
Methods 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:
actualContents
in 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
null
as the key of the middle element.
-
getValueForNullKey
-
getKeyForNullValue
-
getEntryNullReplaces
-
createArrayWithNullValue
- Returns:
- an array of the proper size with
null
as 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:
createDisjointCollection
in classAbstractContainerTester<Map<K,
V>, Map.Entry<K, V>>
-
getNumEntries
protected int getNumEntries() -
getSampleEntries
-
getSampleEntries
-
expectMissing
- Overrides:
expectMissing
in classAbstractContainerTester<Map<K,
V>, Map.Entry<K, V>>
-
equal
-
entry
-
expectContents
Description copied from class:AbstractContainerTester
Asserts 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:
expectContents
in 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.Entry
by mistake. -
k0
-
v0
-
k1
-
v1
-
k2
-
v2
-
k3
-
v3
-
k4
-
v4
-