Class MapAssert<KEY,​VALUE>

  • Type Parameters:
    KEY - key type of the Map.
    VALUE - value type of the Map.
    All Implemented Interfaces:
    org.assertj.core.api.Assert<MapAssert<KEY,​VALUE>,​io.vavr.collection.Map<KEY,​VALUE>>, org.assertj.core.api.Descriptable<MapAssert<KEY,​VALUE>>, org.assertj.core.api.EnumerableAssert<MapAssert<KEY,​VALUE>,​io.vavr.Tuple2<? extends KEY,​? extends VALUE>>, org.assertj.core.api.ExtensionPoints<MapAssert<KEY,​VALUE>,​io.vavr.collection.Map<KEY,​VALUE>>

    public class MapAssert<KEY,​VALUE>
    extends org.assertj.core.api.AbstractObjectAssert<SELF,​ACTUAL>
    Assertions for Map.
    Author:
    MichaƂ Chmielarz
    • Field Summary

      • Fields inherited from class org.assertj.core.api.AbstractAssert

        actual, info, myself, throwUnsupportedExceptionOnEquals
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ACTUAL actual()  
      SELF allSatisfy​(BiConsumer<? super KEY,​? super VALUE> entryRequirements)
      Verifies that all the actual map entries satisfy the given entryRequirements.
      SELF contains​(io.vavr.Tuple2<KEY,​VALUE>... entries)
      Verifies that the actual map contains the given entries, in any order.
      SELF containsAllEntriesOf​(Iterable<io.vavr.Tuple2<KEY,​VALUE>> other)
      Verifies that the actual map contains all entries of the given iterable, in any order.
      SELF containsAnyOf​(io.vavr.Tuple2<KEY,​VALUE>... entries)
      Verifies that the actual map contains at least one of the given entries.
      SELF containsEntry​(KEY key, VALUE value)
      Verifies that the actual map contains the given entry.
      SELF containsExactly​(io.vavr.Tuple2<? extends KEY,​? extends VALUE>... entries)
      Verifies that the actual map contains only the given entries and nothing else, in order.
      This assertion should only be used with maps that have a consistent iteration order (i.e.
      SELF containsKey​(KEY key)
      Verifies that the actual map contains the given key.
      SELF containsKeys​(KEY... keys)
      Verifies that the actual map contains the given keys.
      SELF containsOnly​(Iterable<io.vavr.Tuple2<KEY,​VALUE>> entries)  
      SELF containsOnlyKeys​(KEY... keys)
      Verifies that the actual map contains only the given keys and nothing else, in any order.
      SELF containsValue​(VALUE value)
      Verifies that the actual map contains the given value.
      SELF containsValues​(VALUE... values)
      Verifies that the actual map contains the given values.
      SELF doesNotContain​(io.vavr.Tuple2<KEY,​VALUE>... entries)
      Verifies that the actual map does not contain the given entries.
      SELF doesNotContainEntry​(KEY key, VALUE value)
      Verifies that the actual map does not contain the given entry.
      SELF doesNotContainKey​(KEY key)
      Verifies that the actual map does not contain the given key.
      SELF doesNotContainKeys​(KEY... keys)
      Verifies that the actual map does not contain the given keys.
      SELF doesNotContainValue​(VALUE value)
      Verifies that the actual map does not contain the given value.
      SELF doesNotContainValues​(VALUE... values)
      Verifies that the actual map does not contain the given values.
      SELF hasEntrySatisfying​(KEY key, org.assertj.core.api.Condition<? super VALUE> valueCondition)
      Verifies that the actual map contains a value for the given key that satisfies the given valueCondition.
      SELF hasSameSizeAs​(Iterable<?> other)  
      SELF hasSameSizeAs​(Object array)  
      SELF hasSize​(int expectedSize)  
      SELF hasSizeBetween​(int lowerBoundary, int higherBoundary)  
      SELF hasSizeGreaterThan​(int boundary)  
      SELF hasSizeGreaterThanOrEqualTo​(int boundary)  
      SELF hasSizeLessThan​(int boundary)  
      SELF hasSizeLessThanOrEqualTo​(int boundary)  
      org.assertj.core.api.WritableAssertionInfo info()  
      void isEmpty()  
      SELF isNotEmpty()  
      void isNullOrEmpty()  
      org.assertj.core.internal.Objects objects()  
      SELF usingDefaultElementComparator()  
      SELF usingElementComparator​(Comparator<? super io.vavr.Tuple2<? extends KEY,​? extends VALUE>> customComparator)  
      SELF withAssertionState​(org.assertj.vavr.api.AbstractVavrAssert assertInstance)  
      • Methods inherited from class org.assertj.core.api.AbstractObjectAssert

        as, as, extracting, extracting, extracting, extracting, extracting, extracting, getComparatorsByType, hasAllNullFieldsOrProperties, hasAllNullFieldsOrPropertiesExcept, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, hasOnlyFields, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveComparison, usingRecursiveComparison
      • Methods inherited from class org.assertj.core.api.AbstractAssert

        asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
      • Methods inherited from interface org.assertj.core.api.Descriptable

        as, describedAs
    • Method Detail

      • allSatisfy

        public SELF allSatisfy​(BiConsumer<? super KEY,​? super VALUE> entryRequirements)
        Verifies that all the actual map entries satisfy the given entryRequirements. If the actual map is empty, this assertion succeeds as there is nothing to check.
        Parameters:
        entryRequirements - the given requirements that each entry must satisfy.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given entryRequirements BiConsumer is null.
        AssertionError - if the actual map is null.
        AssertionError - if one or more entries don't satisfy the given requirements.
      • hasEntrySatisfying

        public SELF hasEntrySatisfying​(KEY key,
                                       org.assertj.core.api.Condition<? super VALUE> valueCondition)
        Verifies that the actual map contains a value for the given key that satisfies the given valueCondition.
        Parameters:
        key - the given key to check.
        valueCondition - the given condition for check value.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given values is null.
        AssertionError - if the actual map is null.
        AssertionError - if the actual map does not contain the given key.
        AssertionError - if the actual map contains the given key, but value does not match the given valueCondition.
      • isNullOrEmpty

        public void isNullOrEmpty()
        Specified by:
        isNullOrEmpty in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • isEmpty

        public void isEmpty()
        Specified by:
        isEmpty in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • isNotEmpty

        public SELF isNotEmpty()
        Specified by:
        isNotEmpty in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • contains

        public SELF contains​(io.vavr.Tuple2<KEY,​VALUE>... entries)
        Verifies that the actual map contains the given entries, in any order.

        This assertion succeeds if both actual map and given entries are empty.

        Parameters:
        entries - the given entries.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        NullPointerException - if any of the entries in the given array is null.
        AssertionError - if the actual map is not empty and the given argument is an empty array.
        AssertionError - if the actual map is null.
        AssertionError - if the actual map does not contain the given entries.
      • containsAnyOf

        public SELF containsAnyOf​(io.vavr.Tuple2<KEY,​VALUE>... entries)
        Verifies that the actual map contains at least one of the given entries.
        Parameters:
        entries - the given entries.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        NullPointerException - if any of the entries in the given array is null.
        AssertionError - if the actual map is not empty and the given argument is an empty array.
        AssertionError - if the actual map is null.
        AssertionError - if the actual map does not contain any of the given entries.
      • containsAllEntriesOf

        public SELF containsAllEntriesOf​(Iterable<io.vavr.Tuple2<KEY,​VALUE>> other)
        Verifies that the actual map contains all entries of the given iterable, in any order.
        Parameters:
        other - the iterable with the given entries.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        NullPointerException - if any of the entries in the given iterable is null.
        AssertionError - if the actual map is not empty and the given argument is an empty iterable.
        AssertionError - if the actual map is null.
        AssertionError - if the actual map does not contain the given entries.
      • containsEntry

        public SELF containsEntry​(KEY key,
                                  VALUE value)
        Verifies that the actual map contains the given entry.
        Parameters:
        key - the given key to check.
        value - the given value to check.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual map is null.
        AssertionError - if the actual map does not contain the given entries.
      • doesNotContain

        public SELF doesNotContain​(io.vavr.Tuple2<KEY,​VALUE>... entries)
        Verifies that the actual map does not contain the given entries.
        Parameters:
        entries - the given entries.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual map is null.
        AssertionError - if the actual map contains any of the given entries.
      • doesNotContainEntry

        public SELF doesNotContainEntry​(KEY key,
                                        VALUE value)
        Verifies that the actual map does not contain the given entry.
        Parameters:
        key - key of the entry.
        value - value of the entry.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual map is null.
        AssertionError - if the actual map contains any of the given entries.
      • containsOnly

        public SELF containsOnly​(Iterable<io.vavr.Tuple2<KEY,​VALUE>> entries)
      • containsExactly

        public SELF containsExactly​(io.vavr.Tuple2<? extends KEY,​? extends VALUE>... entries)
        Verifies that the actual map contains only the given entries and nothing else, in order.
        This assertion should only be used with maps that have a consistent iteration order (i.e. don't use it with HashMap, prefer containsOnly(java.lang.Iterable<io.vavr.Tuple2<KEY, VALUE>>) methods in that case).
        Parameters:
        entries - the given entries.
        Returns:
        this assertions object.
        Throws:
        NullPointerException - if the given entries array is null.
        AssertionError - if the actual map is null.
        IllegalArgumentException - if the given entries array is empty.
        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.
      • containsKey

        public SELF containsKey​(KEY key)
        Verifies that the actual map contains the given key.
        Parameters:
        key - the given key.
        Returns:
        this assertions object.
        Throws:
        AssertionError - if the actual map is null.
        AssertionError - if the actual map does not contain the given key.
      • containsKeys

        public SELF containsKeys​(KEY... keys)
        Verifies that the actual map contains the given keys.
        Parameters:
        keys - the given keys.
        Returns:
        this assertions object.
        Throws:
        AssertionError - if the actual map is null.
        AssertionError - if the actual map does not contain the given key.
        IllegalArgumentException - if the given argument is an empty array.
        NullPointerException - if the array of keys is null.
      • containsOnlyKeys

        public SELF containsOnlyKeys​(KEY... keys)
        Verifies that the actual map contains only the given keys and nothing else, in any order.
        Parameters:
        keys - the given keys that should be in the actual map.
        Returns:
        this assertions object.
        Throws:
        AssertionError - if the actual map is null.
        AssertionError - if the actual map does not contain the given keys, i.e. the actual map contains some or none of the given keys, or the actual map contains more entries than the given ones.
        NullPointerException - if the array of keys is null.
        IllegalArgumentException - if the given argument is an empty array.
      • doesNotContainKey

        public SELF doesNotContainKey​(KEY key)
        Verifies that the actual map does not contain the given key.
        Parameters:
        key - the given key.
        Returns:
        this assertions object.
        Throws:
        AssertionError - if the actual map is null.
        AssertionError - if the actual map contains the given key.
      • doesNotContainKeys

        public SELF doesNotContainKeys​(KEY... keys)
        Verifies that the actual map does not contain the given keys.
        Parameters:
        keys - the given keys.
        Returns:
        this assertions object.
        Throws:
        AssertionError - if the actual map is null.
        AssertionError - if the actual map contains the given key.
        IllegalArgumentException - if the given argument is an empty array.
        NullPointerException - if the array of keys is null.
      • containsValue

        public SELF containsValue​(VALUE value)
        Verifies that the actual map contains the given value.
        Parameters:
        value - the value to look for.
        Returns:
        this assertions object.
        Throws:
        AssertionError - if the actual map is null.
        AssertionError - if the actual map does not contain the given value.
      • containsValues

        public SELF containsValues​(VALUE... values)
        Verifies that the actual map contains the given values.
        Parameters:
        values - the values to look for in the actual map.
        Returns:
        this assertions object.
        Throws:
        AssertionError - if the actual map is null.
        AssertionError - if the actual map does not contain the given values.
      • doesNotContainValue

        public SELF doesNotContainValue​(VALUE value)
        Verifies that the actual map does not contain the given value.
        Parameters:
        value - the value to look for.
        Returns:
        this assertions object.
        Throws:
        AssertionError - if the actual map is null.
        AssertionError - if the actual map contains the given value.
      • doesNotContainValues

        public SELF doesNotContainValues​(VALUE... values)
        Verifies that the actual map does not contain the given values.
        Parameters:
        values - the values to look for in the actual map.
        Returns:
        this assertions object.
        Throws:
        AssertionError - if the actual map is null.
        AssertionError - if the actual map contains the given values.
      • hasSize

        public SELF hasSize​(int expectedSize)
        Specified by:
        hasSize in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • hasSizeGreaterThan

        public SELF hasSizeGreaterThan​(int boundary)
        Specified by:
        hasSizeGreaterThan in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • hasSizeGreaterThanOrEqualTo

        public SELF hasSizeGreaterThanOrEqualTo​(int boundary)
        Specified by:
        hasSizeGreaterThanOrEqualTo in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • hasSizeLessThan

        public SELF hasSizeLessThan​(int boundary)
        Specified by:
        hasSizeLessThan in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • hasSizeLessThanOrEqualTo

        public SELF hasSizeLessThanOrEqualTo​(int boundary)
        Specified by:
        hasSizeLessThanOrEqualTo in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • hasSizeBetween

        public SELF hasSizeBetween​(int lowerBoundary,
                                   int higherBoundary)
        Specified by:
        hasSizeBetween in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • hasSameSizeAs

        public SELF hasSameSizeAs​(Iterable<?> other)
        Specified by:
        hasSameSizeAs in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • hasSameSizeAs

        public SELF hasSameSizeAs​(Object array)
        Specified by:
        hasSameSizeAs in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • usingElementComparator

        public SELF usingElementComparator​(Comparator<? super io.vavr.Tuple2<? extends KEY,​? extends VALUE>> customComparator)
        Specified by:
        usingElementComparator in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • usingDefaultElementComparator

        public SELF usingDefaultElementComparator()
        Specified by:
        usingDefaultElementComparator in interface org.assertj.core.api.EnumerableAssert<SELF extends org.assertj.vavr.api.AbstractMapAssert<SELF,​ACTUAL,​KEY,​VALUE>,​ACTUAL extends io.vavr.collection.Map<KEY,​VALUE>>
      • actual

        public ACTUAL actual()
      • withAssertionState

        public SELF withAssertionState​(org.assertj.vavr.api.AbstractVavrAssert assertInstance)
      • objects

        public org.assertj.core.internal.Objects objects()
      • info

        public org.assertj.core.api.WritableAssertionInfo info()