Class Maps


  • public class Maps
    extends java.lang.Object
    Reusable assertions for Maps.
    • Constructor Summary

      Constructors 
      Constructor Description
      Maps()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <K,​V>
      void
      assertAllSatisfy​(AssertionInfo info, java.util.Map<K,​V> actual, java.util.function.BiConsumer<? super K,​? super V> entryRequirements)  
      <K,​V>
      void
      assertAnySatisfy​(AssertionInfo info, java.util.Map<K,​V> actual, java.util.function.BiConsumer<? super K,​? super V> entryRequirements)  
      <K,​V>
      void
      assertContains​(AssertionInfo info, java.util.Map<K,​V> actual, java.util.Map.Entry<? extends K,​? extends V>[] entries)
      Asserts that the given Map contains the given entries, in any order.
      <K,​V>
      void
      assertContainsAnyOf​(AssertionInfo info, java.util.Map<K,​V> actual, java.util.Map.Entry<? extends K,​? extends V>[] entries)  
      <K,​V>
      void
      assertContainsExactly​(AssertionInfo info, java.util.Map<K,​V> actual, java.util.Map.Entry<? extends K,​? extends V>... entries)
      Verifies that the actual map contains only the given entries and nothing else, in order.
      This assertion should only be used with map that have a consistent iteration order (i.e.
      <K,​V>
      void
      assertContainsKeys​(AssertionInfo info, java.util.Map<K,​V> actual, K... keys)
      Verifies that the actual map contain the given key.
      <K,​V>
      void
      assertContainsOnly​(AssertionInfo info, java.util.Map<K,​V> actual, java.util.Map.Entry<? extends K,​? extends V>... entries)
      Verifies that the actual map contains only the given entries and nothing else, in any order.
      <K,​V>
      void
      assertContainsOnlyKeys​(AssertionInfo info, java.util.Map<K,​V> actual, java.lang.Iterable<? extends K> keys)
      Verifies that the actual map contains only the given keys and nothing else, in any order.
      <K,​V>
      void
      assertContainsOnlyKeys​(AssertionInfo info, java.util.Map<K,​V> actual, java.lang.String placeholderForErrorMessages, K[] keys)  
      <K,​V>
      void
      assertContainsOnlyKeys​(AssertionInfo info, java.util.Map<K,​V> actual, K... keys)
      Verifies that the actual map contains only the given keys and nothing else, in any order.
      <K,​V>
      void
      assertContainsValue​(AssertionInfo info, java.util.Map<K,​V> actual, V value)
      Verifies that the actual map contain the given value.
      <K,​V>
      void
      assertContainsValues​(AssertionInfo info, java.util.Map<K,​V> actual, V... values)
      Verifies that the actual map contain the given values.
      <K,​V>
      void
      assertDoesNotContain​(AssertionInfo info, java.util.Map<K,​V> actual, java.util.Map.Entry<? extends K,​? extends V>[] entries)
      Asserts that the given Map does not contain the given entries.
      <K,​V>
      void
      assertDoesNotContainKey​(AssertionInfo info, java.util.Map<K,​V> actual, K key)
      Verifies that the actual map not contains the given key.
      <K,​V>
      void
      assertDoesNotContainKeys​(AssertionInfo info, java.util.Map<K,​V> actual, K... keys)
      Verifies that the actual map not contains all the given keys.
      <K,​V>
      void
      assertDoesNotContainValue​(AssertionInfo info, java.util.Map<K,​V> actual, V value)
      Verifies that the actual map not contains the given value.
      void assertEmpty​(AssertionInfo info, java.util.Map<?,​?> actual)
      Asserts that the given Map is empty.
      <K,​V>
      void
      assertHasEntrySatisfying​(AssertionInfo info, java.util.Map<K,​V> actual, K key, java.util.function.Consumer<? super V> valueRequirements)
      Verifies that the Map contains the value for given key that satisfy given valueRequirements.
      <K,​V>
      void
      assertHasEntrySatisfying​(AssertionInfo info, java.util.Map<K,​V> actual, K key, Condition<? super V> valueCondition)
      Verifies that the given Map contains the value for given key that satisfy given valueCondition.
      <K,​V>
      void
      assertHasEntrySatisfying​(AssertionInfo info, java.util.Map<K,​V> actual, Condition<? super java.util.Map.Entry<K,​V>> entryCondition)
      Verifies that the given Map contains an entry satisfying given entryCondition.
      <K,​V>
      void
      assertHasEntrySatisfyingConditions​(AssertionInfo info, java.util.Map<K,​V> actual, Condition<? super K> keyCondition, Condition<? super V> valueCondition)
      Verifies that the given Map contains an entry with key satisfying keyCondition and value satisfying valueCondition.
      <K> void assertHasKeySatisfying​(AssertionInfo info, java.util.Map<K,​?> actual, Condition<? super K> keyCondition)
      Verifies that the given Map contains an entry with key satisfying keyCondition.
      void assertHasSameSizeAs​(AssertionInfo info, java.util.Map<?,​?> map, java.lang.Iterable<?> other)
      Asserts that the number of entries in the given Map has the same size as the other Iterable.
      void assertHasSameSizeAs​(AssertionInfo info, java.util.Map<?,​?> map, java.lang.Object other)
      Asserts that the number of entries in the given Map has the same size as the other array.
      void assertHasSameSizeAs​(AssertionInfo info, java.util.Map<?,​?> map, java.util.Map<?,​?> other)
      Asserts that the size of the given Map is equal to the size of the other Map.
      void assertHasSize​(AssertionInfo info, java.util.Map<?,​?> actual, int expectedSize)
      Asserts that the number of entries in the given Map is equal to the expected one.
      void assertHasSizeBetween​(AssertionInfo info, java.util.Map<?,​?> actual, int lowerBoundary, int higherBoundary)
      Asserts that the number of entries in the given Map is between the given lower and higher boundary (inclusive).
      void assertHasSizeGreaterThan​(AssertionInfo info, java.util.Map<?,​?> actual, int boundary)
      Asserts that the number of entries in the given Map is greater than the boundary.
      void assertHasSizeGreaterThanOrEqualTo​(AssertionInfo info, java.util.Map<?,​?> actual, int boundary)
      Asserts that the number of entries in the given Map is greater than or equal to the boundary.
      void assertHasSizeLessThan​(AssertionInfo info, java.util.Map<?,​?> actual, int boundary)
      Asserts that the number of entries in the given Map is less than the boundary.
      void assertHasSizeLessThanOrEqualTo​(AssertionInfo info, java.util.Map<?,​?> actual, int boundary)
      Asserts that the number of entries in the given Map is less than or equal to the boundary.
      <V> void assertHasValueSatisfying​(AssertionInfo info, java.util.Map<?,​V> actual, Condition<? super V> valueCondition)
      Verifies that the given Map contains an entry with value satisfying valueCondition.
      <K,​V>
      void
      assertNoneSatisfy​(AssertionInfo info, java.util.Map<K,​V> actual, java.util.function.BiConsumer<? super K,​? super V> entryRequirements)  
      void assertNotEmpty​(AssertionInfo info, java.util.Map<?,​?> actual)
      Asserts that the given Map is not empty.
      private void assertNotNull​(AssertionInfo info, java.util.Map<?,​?> actual)  
      void assertNullOrEmpty​(AssertionInfo info, java.util.Map<?,​?> actual)
      Asserts that the given Map is null or empty.
      private <K,​V>
      void
      compareActualMapAndExpectedEntries​(java.util.Map<K,​V> actual, java.util.Map.Entry<? extends K,​? extends V>[] entries, java.util.Set<java.util.Map.Entry<? extends K,​? extends V>> notExpected, java.util.Set<java.util.Map.Entry<? extends K,​? extends V>> notFound)  
      private <K,​V>
      void
      compareActualMapAndExpectedKeys​(java.util.Map<K,​V> actual, K[] keys, java.util.Set<K> notExpected, java.util.Set<K> notFound)  
      private <K,​V>
      boolean
      containsEntry​(java.util.Map<K,​V> actual, java.util.Map.Entry<? extends K,​? extends V> entry)  
      private <K,​V>
      void
      doCommonContainsCheck​(AssertionInfo info, java.util.Map<K,​V> actual, java.util.Map.Entry<? extends K,​? extends V>[] entries)  
      private static <K,​V>
      java.util.Map<K,​V>
      entriesToMap​(java.util.Map.Entry<? extends K,​? extends V>[] entries)  
      private static <K,​V>
      void
      failIfEmpty​(java.util.Map.Entry<? extends K,​? extends V>[] entries)  
      private static <K> void failIfEmpty​(K[] keys, java.lang.String errorMessage)  
      private static <K,​V>
      void
      failIfEmptySinceActualIsNotEmpty​(java.util.Map.Entry<? extends K,​? extends V>[] values)  
      private static <K,​V>
      void
      failIfNull​(java.util.Map.Entry<? extends K,​? extends V>[] entries)  
      private static <K> void failIfNull​(K[] keys, java.lang.String errorMessage)  
      private static <K,​V>
      void
      failIfNullOrEmpty​(java.util.Map.Entry<? extends K,​? extends V>[] entries)  
      private static <K,​V>
      java.util.Optional<ElementsShouldSatisfy.UnsatisfiedRequirement>
      failsRequirements​(java.util.function.BiConsumer<? super K,​? super V> entryRequirements, java.util.Map.Entry<K,​V> entry)  
      private <V,​K>
      java.util.Optional<java.util.Map.Entry<K,​V>>
      failsRestrictions​(java.util.Map.Entry<K,​V> entry, java.util.function.BiConsumer<? super K,​? super V> entryRequirements)  
      static Maps instance()
      Returns the singleton instance of this class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Maps

        Maps()
    • Method Detail

      • instance

        public static Maps instance()
        Returns the singleton instance of this class.
        Returns:
        the singleton instance of this class.
      • assertAllSatisfy

        public <K,​V> void assertAllSatisfy​(AssertionInfo info,
                                                 java.util.Map<K,​V> actual,
                                                 java.util.function.BiConsumer<? super K,​? super V> entryRequirements)
      • failsRequirements

        private static <K,​V> java.util.Optional<ElementsShouldSatisfy.UnsatisfiedRequirement> failsRequirements​(java.util.function.BiConsumer<? super K,​? super V> entryRequirements,
                                                                                                                      java.util.Map.Entry<K,​V> entry)
      • assertAnySatisfy

        public <K,​V> void assertAnySatisfy​(AssertionInfo info,
                                                 java.util.Map<K,​V> actual,
                                                 java.util.function.BiConsumer<? super K,​? super V> entryRequirements)
      • assertNoneSatisfy

        public <K,​V> void assertNoneSatisfy​(AssertionInfo info,
                                                  java.util.Map<K,​V> actual,
                                                  java.util.function.BiConsumer<? super K,​? super V> entryRequirements)
      • failsRestrictions

        private <V,​K> java.util.Optional<java.util.Map.Entry<K,​V>> failsRestrictions​(java.util.Map.Entry<K,​V> entry,
                                                                                                 java.util.function.BiConsumer<? super K,​? super V> entryRequirements)
      • assertNullOrEmpty

        public void assertNullOrEmpty​(AssertionInfo info,
                                      java.util.Map<?,​?> actual)
        Asserts that the given Map is null or empty.
        Parameters:
        info - contains information about the assertion.
        actual - the given map.
        Throws:
        java.lang.AssertionError - if the given Map is not null *and* contains one or more entries.
      • assertEmpty

        public void assertEmpty​(AssertionInfo info,
                                java.util.Map<?,​?> actual)
        Asserts that the given Map is empty.
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        Throws:
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the given Map is not empty.
      • assertNotEmpty

        public void assertNotEmpty​(AssertionInfo info,
                                   java.util.Map<?,​?> actual)
        Asserts that the given Map is not empty.
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        Throws:
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the given Map is empty.
      • assertHasSize

        public void assertHasSize​(AssertionInfo info,
                                  java.util.Map<?,​?> actual,
                                  int expectedSize)
        Asserts that the number of entries in the given Map is equal to the expected one.
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        expectedSize - the expected size of actual.
        Throws:
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the number of entries in the given Map is different than the expected one.
      • assertHasSizeGreaterThan

        public void assertHasSizeGreaterThan​(AssertionInfo info,
                                             java.util.Map<?,​?> actual,
                                             int boundary)
        Asserts that the number of entries in the given Map is greater than the boundary.
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        boundary - the given value to compare the size of actual to.
        Throws:
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the number of entries in the given Map is greater than the boundary.
      • assertHasSizeGreaterThanOrEqualTo

        public void assertHasSizeGreaterThanOrEqualTo​(AssertionInfo info,
                                                      java.util.Map<?,​?> actual,
                                                      int boundary)
        Asserts that the number of entries in the given Map is greater than or equal to the boundary.
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        boundary - the given value to compare the size of actual to.
        Throws:
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the number of entries in the given Map is greater than or equal to the boundary.
      • assertHasSizeLessThan

        public void assertHasSizeLessThan​(AssertionInfo info,
                                          java.util.Map<?,​?> actual,
                                          int boundary)
        Asserts that the number of entries in the given Map is less than the boundary.
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        boundary - the given value to compare the size of actual to.
        Throws:
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the number of entries in the given Map is less than the expected one.
      • assertHasSizeLessThanOrEqualTo

        public void assertHasSizeLessThanOrEqualTo​(AssertionInfo info,
                                                   java.util.Map<?,​?> actual,
                                                   int boundary)
        Asserts that the number of entries in the given Map is less than or equal to the boundary.
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        boundary - the given value to compare the size of actual to.
        Throws:
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the number of entries in the given Map is less than or equal to the boundary.
      • assertHasSizeBetween

        public void assertHasSizeBetween​(AssertionInfo info,
                                         java.util.Map<?,​?> actual,
                                         int lowerBoundary,
                                         int higherBoundary)
        Asserts that the number of entries in the given Map is between the given lower and higher boundary (inclusive).
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        lowerBoundary - the lower boundary compared to which actual size should be greater than or equal to.
        higherBoundary - the higher boundary compared to which actual size should be less than or equal to.
        Throws:
        java.lang.AssertionError - if the given array is null.
        java.lang.AssertionError - if the number of elements in the given array is not between the boundaries.
      • assertHasSameSizeAs

        public void assertHasSameSizeAs​(AssertionInfo info,
                                        java.util.Map<?,​?> map,
                                        java.lang.Iterable<?> other)
        Asserts that the number of entries in the given Map has the same size as the other Iterable.
        Parameters:
        info - contains information about the assertion.
        map - the given Map.
        other - the group to compare
        Throws:
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the given Iterable is null.
        java.lang.AssertionError - if the number of entries in the given Map does not have the same size.
      • assertHasSameSizeAs

        public void assertHasSameSizeAs​(AssertionInfo info,
                                        java.util.Map<?,​?> map,
                                        java.lang.Object other)
        Asserts that the number of entries in the given Map has the same size as the other array.
        Parameters:
        info - contains information about the assertion.
        map - the given Map.
        other - the group to compare
        Throws:
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the given array is null.
        java.lang.AssertionError - if the number of entries in the given Map does not have the same size.
      • assertHasSameSizeAs

        public void assertHasSameSizeAs​(AssertionInfo info,
                                        java.util.Map<?,​?> map,
                                        java.util.Map<?,​?> other)
        Asserts that the size of the given Map is equal to the size of the other Map.
        Parameters:
        info - contains information about the assertion.
        map - the given Map.
        other - the other Map to compare
        Throws:
        java.lang.NullPointerException - if the other Map is null.
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the size of the given Map is not equal to the other Map size
      • assertContains

        public <K,​V> void assertContains​(AssertionInfo info,
                                               java.util.Map<K,​V> actual,
                                               java.util.Map.Entry<? extends K,​? extends V>[] entries)
        Asserts that the given Map contains the given entries, in any order.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        entries - the entries that are expected to be in the given Map.
        Throws:
        java.lang.NullPointerException - if the array of entries is null.
        java.lang.IllegalArgumentException - if the array of entries is empty.
        java.lang.NullPointerException - if any of the entries in the given array is null.
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the given Map does not contain the given entries.
      • assertContainsAnyOf

        public <K,​V> void assertContainsAnyOf​(AssertionInfo info,
                                                    java.util.Map<K,​V> actual,
                                                    java.util.Map.Entry<? extends K,​? extends V>[] entries)
      • assertHasEntrySatisfying

        public <K,​V> void assertHasEntrySatisfying​(AssertionInfo info,
                                                         java.util.Map<K,​V> actual,
                                                         K key,
                                                         Condition<? super V> valueCondition)
        Verifies that the given Map contains the value for given key that satisfy given valueCondition.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        key - he given key to check.
        valueCondition - the given condition for check value.
        Throws:
        java.lang.NullPointerException - if the given values is null.
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if the actual map not contains the given key.
        java.lang.AssertionError - if the actual map contains the given key, but value not match the given valueCondition.
        Since:
        2.6.0 / 3.6.0
      • assertHasEntrySatisfying

        public <K,​V> void assertHasEntrySatisfying​(AssertionInfo info,
                                                         java.util.Map<K,​V> actual,
                                                         K key,
                                                         java.util.function.Consumer<? super V> valueRequirements)
        Verifies that the Map contains the value for given key that satisfy given valueRequirements.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        key - he given key to check.
        valueRequirements - the given requirements for check value.
        Throws:
        java.lang.NullPointerException - if the given values is null.
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if the actual map not contains the given key.
        java.lang.AssertionError - if the actual map contains the given key, but value not pass the given valueRequirements.
      • assertHasEntrySatisfying

        public <K,​V> void assertHasEntrySatisfying​(AssertionInfo info,
                                                         java.util.Map<K,​V> actual,
                                                         Condition<? super java.util.Map.Entry<K,​V>> entryCondition)
        Verifies that the given Map contains an entry satisfying given entryCondition.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        entryCondition - the condition for searching entry.
        Throws:
        java.lang.NullPointerException - if the given condition is null.
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if there is no entry matching given entryCondition.
        Since:
        2.7.0 / 3.7.0
      • assertHasEntrySatisfyingConditions

        public <K,​V> void assertHasEntrySatisfyingConditions​(AssertionInfo info,
                                                                   java.util.Map<K,​V> actual,
                                                                   Condition<? super K> keyCondition,
                                                                   Condition<? super V> valueCondition)
        Verifies that the given Map contains an entry with key satisfying keyCondition and value satisfying valueCondition.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        keyCondition - the condition for entry key.
        valueCondition - the condition for entry value.
        Throws:
        java.lang.NullPointerException - if any of the given conditions is null.
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if there is no entry matching given keyCondition and valueCondition.
        Since:
        2.7.0 / 3.7.0
      • assertHasKeySatisfying

        public <K> void assertHasKeySatisfying​(AssertionInfo info,
                                               java.util.Map<K,​?> actual,
                                               Condition<? super K> keyCondition)
        Verifies that the given Map contains an entry with key satisfying keyCondition.
        Type Parameters:
        K - key type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        keyCondition - the condition for key search.
        Throws:
        java.lang.NullPointerException - if the given condition is null.
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if there is no key matching given keyCondition.
        Since:
        2.7.0 / 3.7.0
      • assertHasValueSatisfying

        public <V> void assertHasValueSatisfying​(AssertionInfo info,
                                                 java.util.Map<?,​V> actual,
                                                 Condition<? super V> valueCondition)
        Verifies that the given Map contains an entry with value satisfying valueCondition.
        Type Parameters:
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        valueCondition - the condition for value search.
        Throws:
        java.lang.NullPointerException - if the given condition is null.
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if there is no value matching given valueCondition.
        Since:
        2.7.0 / 3.7.0
      • assertDoesNotContain

        public <K,​V> void assertDoesNotContain​(AssertionInfo info,
                                                     java.util.Map<K,​V> actual,
                                                     java.util.Map.Entry<? extends K,​? extends V>[] entries)
        Asserts that the given Map does not contain the given entries.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        entries - the entries that are expected to be in the given Map.
        Throws:
        java.lang.NullPointerException - if the array of entries is null.
        java.lang.IllegalArgumentException - if the array of entries is empty.
        java.lang.NullPointerException - if any of the entries in the given array is null.
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the given Map contains any of the given entries.
      • assertContainsKeys

        public <K,​V> void assertContainsKeys​(AssertionInfo info,
                                                   java.util.Map<K,​V> actual,
                                                   K... keys)
        Verifies that the actual map contain the given key.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        keys - the given keys
        Throws:
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if the actual map not contains the given key.
      • assertDoesNotContainKey

        public <K,​V> void assertDoesNotContainKey​(AssertionInfo info,
                                                        java.util.Map<K,​V> actual,
                                                        K key)
        Verifies that the actual map not contains the given key.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        key - the given key
        Throws:
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if the actual map contains the given key.
      • assertDoesNotContainKeys

        public <K,​V> void assertDoesNotContainKeys​(AssertionInfo info,
                                                         java.util.Map<K,​V> actual,
                                                         K... keys)
        Verifies that the actual map not contains all the given keys.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        keys - the given keys
        Throws:
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if the actual map contains all the given keys.
      • assertContainsOnlyKeys

        public <K,​V> void assertContainsOnlyKeys​(AssertionInfo info,
                                                       java.util.Map<K,​V> actual,
                                                       K... keys)
        Verifies that the actual map contains only the given keys and nothing else, in any order.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        keys - the keys that are expected to be in the given Map.
        Throws:
        java.lang.NullPointerException - if the array of keys is null.
        java.lang.IllegalArgumentException - if the array of keys is empty.
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the given Map does not contain the given keys or if the given Map contains keys that are not in the given array.
      • assertContainsOnlyKeys

        public <K,​V> void assertContainsOnlyKeys​(AssertionInfo info,
                                                       java.util.Map<K,​V> actual,
                                                       java.lang.Iterable<? extends K> keys)
        Verifies that the actual map contains only the given keys and nothing else, in any order.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        keys - the keys that are expected to be in the given Map.
        Throws:
        java.lang.NullPointerException - if the array of keys is null.
        java.lang.IllegalArgumentException - if the array of keys is empty.
        java.lang.AssertionError - if the given Map is null.
        java.lang.AssertionError - if the given Map does not contain the given keys or if the given Map contains keys that are not in the given array.
      • assertContainsOnlyKeys

        public <K,​V> void assertContainsOnlyKeys​(AssertionInfo info,
                                                       java.util.Map<K,​V> actual,
                                                       java.lang.String placeholderForErrorMessages,
                                                       K[] keys)
      • assertContainsValue

        public <K,​V> void assertContainsValue​(AssertionInfo info,
                                                    java.util.Map<K,​V> actual,
                                                    V value)
        Verifies that the actual map contain the given value.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        value - the given value
        Throws:
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if the actual map not contains the given value.
      • assertContainsValues

        public <K,​V> void assertContainsValues​(AssertionInfo info,
                                                     java.util.Map<K,​V> actual,
                                                     V... values)
        Verifies that the actual map contain the given values.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        values - the given values
        Throws:
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if the actual map not contains the given values.
        java.lang.NullPointerException - if values vararg is null.
      • assertDoesNotContainValue

        public <K,​V> void assertDoesNotContainValue​(AssertionInfo info,
                                                          java.util.Map<K,​V> actual,
                                                          V value)
        Verifies that the actual map not contains the given value.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        value - the given value
        Throws:
        java.lang.AssertionError - if the actual map is null.
        java.lang.AssertionError - if the actual map contains the given value.
      • assertContainsOnly

        public <K,​V> void assertContainsOnly​(AssertionInfo info,
                                                   java.util.Map<K,​V> actual,
                                                   java.util.Map.Entry<? extends K,​? extends V>... entries)
        Verifies that the actual map contains only the given entries and nothing else, in any order.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        entries - the entries that should be in the actual map.
        Throws:
        java.lang.AssertionError - if the actual map is null.
        java.lang.NullPointerException - if the given entries array is null.
        java.lang.IllegalArgumentException - if the given entries array is empty.
        java.lang.AssertionError - if the actual map does not contain the given entries, i.e. the actual map contains some or none of the given entries, or the actual map contains more entries than the given ones.
      • assertContainsExactly

        public <K,​V> void assertContainsExactly​(AssertionInfo info,
                                                      java.util.Map<K,​V> actual,
                                                      java.util.Map.Entry<? extends K,​? extends V>... entries)
        Verifies that the actual map contains only the given entries and nothing else, in order.
        This assertion should only be used with map that have a consistent iteration order (i.e. don't use it with HashMap).
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        info - contains information about the assertion.
        actual - the given Map.
        entries - the given entries.
        Throws:
        java.lang.NullPointerException - if the given entries array is null.
        java.lang.AssertionError - if the actual map is null.
        java.lang.IllegalArgumentException - if the given entries array is empty.
        java.lang.AssertionError - if the actual map does not contain the given entries with same order, i.e. the actual map contains some or none of the given entries, or the actual map contains more entries than the given ones or entries are the same but the order is not.
      • compareActualMapAndExpectedKeys

        private <K,​V> void compareActualMapAndExpectedKeys​(java.util.Map<K,​V> actual,
                                                                 K[] keys,
                                                                 java.util.Set<K> notExpected,
                                                                 java.util.Set<K> notFound)
      • compareActualMapAndExpectedEntries

        private <K,​V> void compareActualMapAndExpectedEntries​(java.util.Map<K,​V> actual,
                                                                    java.util.Map.Entry<? extends K,​? extends V>[] entries,
                                                                    java.util.Set<java.util.Map.Entry<? extends K,​? extends V>> notExpected,
                                                                    java.util.Set<java.util.Map.Entry<? extends K,​? extends V>> notFound)
      • doCommonContainsCheck

        private <K,​V> void doCommonContainsCheck​(AssertionInfo info,
                                                       java.util.Map<K,​V> actual,
                                                       java.util.Map.Entry<? extends K,​? extends V>[] entries)
      • entriesToMap

        private static <K,​V> java.util.Map<K,​V> entriesToMap​(java.util.Map.Entry<? extends K,​? extends V>[] entries)
      • failIfEmpty

        private static <K> void failIfEmpty​(K[] keys,
                                            java.lang.String errorMessage)
      • failIfEmpty

        private static <K,​V> void failIfEmpty​(java.util.Map.Entry<? extends K,​? extends V>[] entries)
      • failIfNullOrEmpty

        private static <K,​V> void failIfNullOrEmpty​(java.util.Map.Entry<? extends K,​? extends V>[] entries)
      • failIfNull

        private static <K> void failIfNull​(K[] keys,
                                           java.lang.String errorMessage)
      • failIfNull

        private static <K,​V> void failIfNull​(java.util.Map.Entry<? extends K,​? extends V>[] entries)
      • containsEntry

        private <K,​V> boolean containsEntry​(java.util.Map<K,​V> actual,
                                                  java.util.Map.Entry<? extends K,​? extends V> entry)
      • assertNotNull

        private void assertNotNull​(AssertionInfo info,
                                   java.util.Map<?,​?> actual)
      • failIfEmptySinceActualIsNotEmpty

        private static <K,​V> void failIfEmptySinceActualIsNotEmpty​(java.util.Map.Entry<? extends K,​? extends V>[] values)