Class TryAssert<VALUE>

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

    public class TryAssert<VALUE>
    extends org.assertj.core.api.AbstractObjectAssert<SELF,​ACTUAL>
    Assertions for Try.
    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 Try contains the given value.
      SELF containsInstanceOf​(Class<?> clazz)
      Verifies that the actual Try contains a value that is an instance of the argument.
      SELF containsSame​(VALUE expectedValue)
      Verifies that the actual Try contains the instance given as an argument.
      <U extends Throwable>
      SELF
      failBecauseOf​(Class<U> reason)
      Verifies that the actual Try fails because of specific Throwable.
      SELF failReasonHasMessage​(String exceptionMessage)
      Verifies that the actual @Try fails with specific message.
      <U> org.assertj.vavr.api.AbstractTryAssert<?,​U> flatMap​(Function<? super VALUE,​io.vavr.control.Try<U>> mapper)
      Call flatMap on the Try under test, assertions chained afterwards are performed on the Try resulting from the flatMap call.
      SELF hasValueSatisfying​(Consumer<VALUE> requirement)
      Verifies that the actual Try 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 Try contains a value which satisfies the given Condition.
      org.assertj.core.api.WritableAssertionInfo info()  
      SELF isFailure()
      Verifies that the actual Try is a failed {code Try}.
      SELF isSuccess()
      Verifies that the actual Try is a succeeded {code Try}.
      <U> org.assertj.vavr.api.AbstractTryAssert<?,​U> map​(Function<? super VALUE,​? extends U> mapper)
      Call map on the Try under test, assertions chained afterwards are performed on the Try resulting from the map call.
      org.assertj.core.internal.Objects objects()  
      SELF usingDefaultValueComparator()
      Revert to standard comparison for incoming assertion Try 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 Try 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 Try 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

      • isSuccess

        public SELF isSuccess()
        Verifies that the actual Try is a succeeded {code Try}.
        Returns:
        this assertion object.
      • isFailure

        public SELF isFailure()
        Verifies that the actual Try is a failed {code Try}.
        Returns:
        this assertion object.
      • contains

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

        public SELF hasValueSatisfying​(Consumer<VALUE> requirement)
        Verifies that the actual Try 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 Try.
        Returns:
        this assertion object.
      • hasValueSatisfying

        public SELF hasValueSatisfying​(org.assertj.core.api.Condition<? super VALUE> condition)
        Verifies that the actual Try contains a value which satisfies the given Condition.
        Parameters:
        condition - the given condition.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual Try 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 Try contains a value that is an instance of the argument.
        Parameters:
        clazz - the expected class of the value inside the Try.
        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 Try 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 Try 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 Try 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 Try contains the instance given as an argument.
        Parameters:
        expectedValue - the expected value inside the Try.
        Returns:
        this assertion object.
      • flatMap

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

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

        public <U extends Throwable> SELF failBecauseOf​(Class<U> reason)
        Verifies that the actual Try fails because of specific Throwable.
        Type Parameters:
        U - specific type of Throwable
        Parameters:
        reason - the expected exception class.
        Returns:
        this assertion object.
      • failReasonHasMessage

        public SELF failReasonHasMessage​(String exceptionMessage)
        Verifies that the actual @Try fails with specific message.
        Parameters:
        exceptionMessage - the expected exception message.
        Returns:
        this assertion object.
      • 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()