Class OptionAssert<VALUE>

  • Type Parameters:
    VALUE - type of the value contained in the Option.
    All Implemented Interfaces:
    org.assertj.core.api.Assert<OptionAssert<VALUE>,​io.vavr.control.Option<VALUE>>, org.assertj.core.api.Descriptable<OptionAssert<VALUE>>, org.assertj.core.api.ExtensionPoints<OptionAssert<VALUE>,​io.vavr.control.Option<VALUE>>

    public class OptionAssert<VALUE>
    extends org.assertj.core.api.AbstractObjectAssert<SELF,​ACTUAL>
    Assertions for Option.
    Author:
    Grzegorz Piwowarek
    • 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 contains​(VALUE expectedValue)
      Verifies that the actual Option contains the given value.
      SELF containsInstanceOf​(Class<?> clazz)
      Verifies that the actual Option contains a value that is an instance of the argument.
      SELF containsSame​(VALUE expectedValue)
      Verifies that the actual Option contains the instance given as an argument.
      <U> org.assertj.vavr.api.AbstractOptionAssert<?,​U> flatMap​(Function<? super VALUE,​io.vavr.control.Option<U>> mapper)
      Call flatMap on the Option under test, assertions chained afterwards are performed on the Option resulting from the flatMap call.
      SELF hasValueSatisfying​(Consumer<VALUE> requirement)
      Verifies that the actual Option contains a value and gives this value to the given Consumer for further assertions.
      SELF hasValueSatisfying​(org.assertj.core.api.Condition<? super VALUE> condition)
      Verifies that the actual Option contains a value which satisfies the given Condition.
      org.assertj.core.api.WritableAssertionInfo info()  
      SELF isDefined()
      Verifies that there is a value present in the actual Option.
      SELF isEmpty()
      Verifies that the actual Option is empty.
      <U> org.assertj.vavr.api.AbstractOptionAssert<?,​U> map​(Function<? super VALUE,​? extends U> mapper)
      Call map on the Option under test, assertions chained afterwards are performed on the Option resulting from the map call.
      org.assertj.core.internal.Objects objects()  
      SELF usingDefaultValueComparator()
      Revert to standard comparison for incoming assertion Option value checks.
      SELF usingFieldByFieldValueComparator()
      Use field/property by field/property comparison (including inherited fields/properties) instead of relying on actual type A equals method to compare the Option value's object for incoming assertion checks.
      SELF usingValueComparator​(Comparator<? super VALUE> customComparator)
      Use given custom comparator instead of relying on actual type A equals method to compare the Option value's object for incoming assertion checks.
      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

      • isDefined

        public SELF isDefined()
        Verifies that there is a value present in the actual Option.
        Returns:
        this assertion object.
      • isEmpty

        public SELF isEmpty()
        Verifies that the actual Option is empty.
        Returns:
        this assertion object.
      • contains

        public SELF contains​(VALUE expectedValue)
        Verifies that the actual Option contains the given value.
        Parameters:
        expectedValue - the expected value inside the Option.
        Returns:
        this assertion object.
      • hasValueSatisfying

        public SELF hasValueSatisfying​(Consumer<VALUE> requirement)
        Verifies that the actual Option contains a value and gives this value to the given Consumer for further assertions. Should be used as a way of deeper asserting on the containing object, as further requirement(s) for the value.
        Parameters:
        requirement - to further assert on the object contained inside the Option.
        Returns:
        this assertion object.
      • hasValueSatisfying

        public SELF hasValueSatisfying​(org.assertj.core.api.Condition<? super VALUE> condition)
        Verifies that the actual Option contains a value which satisfies the given Condition.
        Parameters:
        condition - the given condition.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual Option is null or empty.
        NullPointerException - if the given condition is null.
        AssertionError - if the actual value does not satisfy the given condition.
      • containsInstanceOf

        public SELF containsInstanceOf​(Class<?> clazz)
        Verifies that the actual Option contains a value that is an instance of the argument.
        Parameters:
        clazz - the expected class of the value inside the Option.
        Returns:
        this assertion object.
      • usingFieldByFieldValueComparator

        public SELF usingFieldByFieldValueComparator()
        Use field/property by field/property comparison (including inherited fields/properties) instead of relying on actual type A equals method to compare the Option value's object for incoming assertion checks. Private fields are included but this can be disabled using Assertions.setAllowExtractingPrivateFields(boolean).
        Returns:
        this assertion object.
      • usingValueComparator

        public SELF usingValueComparator​(Comparator<? super VALUE> customComparator)
        Use given custom comparator instead of relying on actual type A equals method to compare the Option value's object for incoming assertion checks.
        Parameters:
        customComparator - the comparator to use for incoming assertion checks.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given comparator is null.
      • usingDefaultValueComparator

        public SELF usingDefaultValueComparator()
        Revert to standard comparison for incoming assertion Option value checks.

        This method should be used to disable a custom comparison strategy set by calling usingValueComparator(Comparator).

        Returns:
        this assertion object.
      • containsSame

        public SELF containsSame​(VALUE expectedValue)
        Verifies that the actual Option contains the instance given as an argument.
        Parameters:
        expectedValue - the expected value inside the Option.
        Returns:
        this assertion object.
      • flatMap

        public <U> org.assertj.vavr.api.AbstractOptionAssert<?,​U> flatMap​(Function<? super VALUE,​io.vavr.control.Option<U>> mapper)
        Call flatMap on the Option under test, assertions chained afterwards are performed on the Option resulting from the flatMap call.
        Type Parameters:
        U - the type of a value contained in Option.
        Parameters:
        mapper - the Function to use in the flatMap operation.
        Returns:
        a new AbstractOptionAssert for assertions chaining on the flatMap of the Option.
        Throws:
        AssertionError - if the actual Option is null.
      • map

        public <U> org.assertj.vavr.api.AbstractOptionAssert<?,​U> map​(Function<? super VALUE,​? extends U> mapper)
        Call map on the Option under test, assertions chained afterwards are performed on the Option resulting from the map call.
        Type Parameters:
        U - the type of a value contained in Option.
        Parameters:
        mapper - the Function to use in the map operation.
        Returns:
        a new AbstractOptionAssert for assertions chaining on the map of the Option.
        Throws:
        AssertionError - if the actual Option is null.
      • 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()