Class AbstractMapTester<K extends @Nullable Object, V extends @Nullable Object>

java.lang.Object
junit.framework.Assert
junit.framework.TestCase
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

@GwtCompatible @NullMarked public abstract class AbstractMapTester<K extends @Nullable Object, V extends @Nullable Object> 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.)

Author:
George van den Driessche
  • Constructor Details

    • AbstractMapTester

      public AbstractMapTester()
  • Method Details

    • getMap

      protected Map<K,V> getMap()
    • actualContents

      protected Collection<Map.Entry<K,V>> actualContents()
      Specified by:
      actualContents in class AbstractContainerTester<Map<K extends @Nullable Object, V extends @Nullable Object>, Map.Entry<K extends @Nullable Object, V extends @Nullable Object>>
      Returns:
      the contents of the container under test, for use by expectContents(E...) and its friends.
    • resetMap

      protected final void resetMap()
      See Also:
    • resetMap

      protected void resetMap(Map.Entry<K,V>[] entries)
    • expectMissingKeys

      protected void expectMissingKeys(K... elements)
    • expectMissingValues

      protected void expectMissingValues(V... elements)
    • createArrayWithNullKey

      protected Map.Entry<K,V>[] createArrayWithNullKey()
      Returns:
      an array of the proper size with null as the key of the middle element.
    • getValueForNullKey

      protected V getValueForNullKey()
    • getKeyForNullValue

      protected K getKeyForNullValue()
    • createArrayWithNullValue

      protected Map.Entry<K,V>[] 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

      protected void expectNullKeyMissingWhenNullKeysUnsupported(String message)
      Equivalent to expectMissingKeys (null) except that the call to contains(null) is permitted to throw a NullPointerException.
      Parameters:
      message - message to use upon assertion failure
    • expectNullValueMissingWhenNullValuesUnsupported

      protected void expectNullValueMissingWhenNullValuesUnsupported(String message)
      Equivalent to expectMissingValues (null) except that the call to contains(null) is permitted to throw a NullPointerException.
      Parameters:
      message - message to use upon assertion failure
    • createDisjointCollection

      protected MinimalCollection<Map.Entry<K,V>> createDisjointCollection()
      Overrides:
      createDisjointCollection in class AbstractContainerTester<Map<K extends @Nullable Object, V extends @Nullable Object>, Map.Entry<K extends @Nullable Object, V extends @Nullable Object>>
    • getNumEntries

      protected int getNumEntries()
    • getSampleEntries

      protected Collection<Map.Entry<K,V>> getSampleEntries(int howMany)
    • getSampleEntries

      protected Collection<Map.Entry<K,V>> getSampleEntries()
    • expectMissing

      protected void expectMissing(Map.Entry<K,V>... entries)
      Overrides:
      expectMissing in class AbstractContainerTester<Map<K extends @Nullable Object, V extends @Nullable Object>, Map.Entry<K extends @Nullable Object, V extends @Nullable Object>>
    • entry

      protected Map.Entry<K,V> entry(K key, V value)
    • expectContents

      protected void expectContents(Collection<Map.Entry<K,V>> expected)
      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 extends AbstractListTester, a call to expectContents() invokes this version.
      Overrides:
      expectContents in class AbstractContainerTester<Map<K extends @Nullable Object, V extends @Nullable Object>, Map.Entry<K extends @Nullable Object, V extends @Nullable Object>>
      Parameters:
      expected - expected value of AbstractContainerTester.container
    • expectReplacement

      protected final void expectReplacement(Map.Entry<K,V> newEntry)
    • get

      protected V get(K key)
      Wrapper for Map.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 uses getMap(), it also ensures that callers don't pass an Map.Entry by mistake.
    • k0

      protected final K k0()
    • v0

      protected final V v0()
    • k1

      protected final K k1()
    • v1

      protected final V v1()
    • k2

      protected final K k2()
    • v2

      protected final V v2()
    • k3

      protected final K k3()
    • v3

      protected final V v3()
    • k4

      protected final K k4()
    • v4

      protected final V v4()