Package org.assertj.vavr.api
Class OptionAssert<VALUE>
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.AbstractObjectAssert<SELF,ACTUAL>
-
- org.assertj.vavr.api.OptionAssert<VALUE>
-
- Type Parameters:
VALUE- type of the value contained in theOption.
- 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 forOption.- Author:
- Grzegorz Piwowarek
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ACTUALactual()SELFcontains(VALUE expectedValue)Verifies that the actualOptioncontains the given value.SELFcontainsInstanceOf(Class<?> clazz)Verifies that the actualOptioncontains a value that is an instance of the argument.SELFcontainsSame(VALUE expectedValue)Verifies that the actualOptioncontains the instance given as an argument.<U> org.assertj.vavr.api.AbstractOptionAssert<?,U>flatMap(Function<? super VALUE,io.vavr.control.Option<U>> mapper)CallflatMapon theOptionunder test, assertions chained afterwards are performed on theOptionresulting from the flatMap call.SELFhasValueSatisfying(Consumer<VALUE> requirement)Verifies that the actualOptioncontains a value and gives this value to the givenConsumerfor further assertions.SELFhasValueSatisfying(org.assertj.core.api.Condition<? super VALUE> condition)Verifies that the actualOptioncontains a value which satisfies the givenCondition.org.assertj.core.api.WritableAssertionInfoinfo()SELFisDefined()Verifies that there is a value present in the actualOption.SELFisEmpty()Verifies that the actualOptionis empty.<U> org.assertj.vavr.api.AbstractOptionAssert<?,U>map(Function<? super VALUE,? extends U> mapper)Callmapon theOptionunder test, assertions chained afterwards are performed on theOptionresulting from the map call.org.assertj.core.internal.Objectsobjects()SELFusingDefaultValueComparator()Revert to standard comparison for incoming assertionOptionvalue checks.SELFusingFieldByFieldValueComparator()Use field/property by field/property comparison (including inherited fields/properties) instead of relying on actual type Aequalsmethod to compare theOptionvalue's object for incoming assertion checks.SELFusingValueComparator(Comparator<? super VALUE> customComparator)Use given custom comparator instead of relying on actual type Aequalsmethod to compare theOptionvalue's object for incoming assertion checks.SELFwithAssertionState(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
-
-
-
-
Method Detail
-
isDefined
public SELF isDefined()
Verifies that there is a value present in the actualOption.- Returns:
- this assertion object.
-
isEmpty
public SELF isEmpty()
Verifies that the actualOptionis empty.- Returns:
- this assertion object.
-
contains
public SELF contains(VALUE expectedValue)
Verifies that the actualOptioncontains the given value.- Parameters:
expectedValue- the expected value inside theOption.- Returns:
- this assertion object.
-
hasValueSatisfying
public SELF hasValueSatisfying(Consumer<VALUE> requirement)
Verifies that the actualOptioncontains a value and gives this value to the givenConsumerfor 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 theOption.- Returns:
- this assertion object.
-
hasValueSatisfying
public SELF hasValueSatisfying(org.assertj.core.api.Condition<? super VALUE> condition)
Verifies that the actualOptioncontains a value which satisfies the givenCondition.- Parameters:
condition- the given condition.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOptionis null or empty.NullPointerException- if the given condition isnull.AssertionError- if the actual value does not satisfy the given condition.
-
containsInstanceOf
public SELF containsInstanceOf(Class<?> clazz)
Verifies that the actualOptioncontains a value that is an instance of the argument.- Parameters:
clazz- the expected class of the value inside theOption.- 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 Aequalsmethod to compare theOptionvalue's object for incoming assertion checks. Private fields are included but this can be disabled usingAssertions.setAllowExtractingPrivateFields(boolean).- Returns:
thisassertion object.
-
usingValueComparator
public SELF usingValueComparator(Comparator<? super VALUE> customComparator)
Use given custom comparator instead of relying on actual type Aequalsmethod to compare theOptionvalue's object for incoming assertion checks.- Parameters:
customComparator- the comparator to use for incoming assertion checks.- Returns:
thisassertion object.- Throws:
NullPointerException- if the given comparator isnull.
-
usingDefaultValueComparator
public SELF usingDefaultValueComparator()
Revert to standard comparison for incoming assertionOptionvalue checks.This method should be used to disable a custom comparison strategy set by calling
usingValueComparator(Comparator).- Returns:
thisassertion object.
-
containsSame
public SELF containsSame(VALUE expectedValue)
Verifies that the actualOptioncontains the instance given as an argument.- Parameters:
expectedValue- the expected value inside theOption.- Returns:
- this assertion object.
-
flatMap
public <U> org.assertj.vavr.api.AbstractOptionAssert<?,U> flatMap(Function<? super VALUE,io.vavr.control.Option<U>> mapper)
CallflatMapon theOptionunder test, assertions chained afterwards are performed on theOptionresulting from the flatMap call.- Type Parameters:
U- the type of a value contained inOption.- Parameters:
mapper- theFunctionto use in theflatMapoperation.- Returns:
- a new
AbstractOptionAssertfor assertions chaining on the flatMap of the Option. - Throws:
AssertionError- if the actualOptionis null.
-
map
public <U> org.assertj.vavr.api.AbstractOptionAssert<?,U> map(Function<? super VALUE,? extends U> mapper)
Callmapon theOptionunder test, assertions chained afterwards are performed on theOptionresulting from the map call.- Type Parameters:
U- the type of a value contained inOption.- Parameters:
mapper- theFunctionto use in themapoperation.- Returns:
- a new
AbstractOptionAssertfor assertions chaining on the map of the Option. - Throws:
AssertionError- if the actualOptionis 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()
-
-