Package org.assertj.vavr.api
Class EitherAssert<LEFT,RIGHT>
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.AbstractObjectAssert<SELF,ACTUAL>
-
- org.assertj.vavr.api.EitherAssert<LEFT,RIGHT>
-
- Type Parameters:
LEFT- type of the value on the left contained in theEither.RIGHT- type of the value on the right contained in theEither.
- All Implemented Interfaces:
org.assertj.core.api.Assert<EitherAssert<LEFT,RIGHT>,io.vavr.control.Either<LEFT,RIGHT>>,org.assertj.core.api.Descriptable<EitherAssert<LEFT,RIGHT>>,org.assertj.core.api.ExtensionPoints<EitherAssert<LEFT,RIGHT>,io.vavr.control.Either<LEFT,RIGHT>>
public class EitherAssert<LEFT,RIGHT> extends org.assertj.core.api.AbstractObjectAssert<SELF,ACTUAL>Assertions forEither.- Author:
- Alex Dukhno
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ACTUALactual()SELFcontainsLeftInstanceOf(Class<?> clazz)Verifies that the actual left-sidedEithercontains a value that is an instance of the argument.SELFcontainsLeftSame(LEFT expectedValue)Verifies that the actualEithercontains the instance given as an argument as the left value.SELFcontainsOnLeft(LEFT expectedValue)Verifies that the actualEitherisEither.Leftand contains the given value.SELFcontainsOnRight(RIGHT expectedValue)Verifies that the actualEitherisEither.Rightand contains the given value.SELFcontainsRightInstanceOf(Class<?> clazz)Verifies that the actual right-sidedEithercontains a value that is an instance of the argument.SELFcontainsRightSame(RIGHT expectedValue)Verifies that the actualEithercontains the instance given as an argument as the right value.SELFhasLeftValueSatisfying(Consumer<LEFT> requirement)Verifies that the actualEithercontains a left-sided value and gives this value to the givenConsumerfor further assertions.SELFhasRightValueSatisfying(Consumer<RIGHT> requirement)Verifies that the actualEithercontains a right-sided value and gives this value to the givenConsumerfor further assertions.org.assertj.core.api.WritableAssertionInfoinfo()SELFisLeft()Verifies that the actualEitheris left.SELFisRight()Verifies that the actualEitheris right.org.assertj.core.internal.Objectsobjects()SELFusingDefaultRightValueComparator()Revert to standard comparison for incoming assertionEithervalue checks.SELFusingFieldByFieldValueComparator()Use field/property by field/property comparison (including inherited fields/properties) instead of relying on actual type Aequalsmethod to compare theEithervalue's object for incoming assertion checks.SELFusingValueComparator(Comparator<?> customComparator)Use given custom comparator instead of relying on actual type Aequalsmethod to compare theEithervalue'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
-
isLeft
public SELF isLeft()
Verifies that the actualEitheris left.- Returns:
- this assertion object.
-
isRight
public SELF isRight()
Verifies that the actualEitheris right.- Returns:
- this assertion object.
-
containsOnRight
public SELF containsOnRight(RIGHT expectedValue)
Verifies that the actualEitherisEither.Rightand contains the given value.- Parameters:
expectedValue- the expected value inside theEither.- Returns:
- this assertion object.
-
containsOnLeft
public SELF containsOnLeft(LEFT expectedValue)
Verifies that the actualEitherisEither.Leftand contains the given value.- Parameters:
expectedValue- the expected value inside theEither.- Returns:
- this assertion object.
-
containsRightSame
public SELF containsRightSame(RIGHT expectedValue)
Verifies that the actualEithercontains the instance given as an argument as the right value.- Parameters:
expectedValue- the expected value inside theEither.- Returns:
- this assertion object.
-
containsLeftSame
public SELF containsLeftSame(LEFT expectedValue)
Verifies that the actualEithercontains the instance given as an argument as the left value.- Parameters:
expectedValue- the expected value inside theEither.- Returns:
- this assertion object.
-
containsRightInstanceOf
public SELF containsRightInstanceOf(Class<?> clazz)
Verifies that the actual right-sidedEithercontains a value that is an instance of the argument.- Parameters:
clazz- the expected class of the value inside the right-sidedEither.- Returns:
- this assertion object.
-
containsLeftInstanceOf
public SELF containsLeftInstanceOf(Class<?> clazz)
Verifies that the actual left-sidedEithercontains a value that is an instance of the argument.- Parameters:
clazz- the expected class of the value inside the left-sidedEither.- Returns:
- this assertion object.
-
hasRightValueSatisfying
public SELF hasRightValueSatisfying(Consumer<RIGHT> requirement)
Verifies that the actualEithercontains a right-sided 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.Assertions will pass :
Assertions will fail :// one requirement assertThat(Either.right("something")).hasRightValueSatisfying(it -> assertThat(it).isEqualTo("something")); // multiple requirements assertThat(Either.right("something")).hasRightValueSatisfying(it -> { assertThat(it).isEqualTo("something"); assertThat(it).startsWith("some"); assertThat(it).endsWith("thing"); });assertThat(Either.right("something")).hasRightValueSatisfying(it -> assertThat(it).isEqualTo("something else")); // fail because Either is left-sided, there is no value to perform assertion on assertThat(Either.left(42)).hasRightValueSatisfying(it -> {});- Parameters:
requirement- to further assert on the right-sided object contained inside theEither.- Returns:
- this assertion object.
-
hasLeftValueSatisfying
public SELF hasLeftValueSatisfying(Consumer<LEFT> requirement)
Verifies that the actualEithercontains a left-sided 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.Assertions will pass :
Assertions will fail :// one requirement assertThat(Either.left(42)).hasLeftValueSatisfying(it -> assertThat(it).isEqualTo(42)); // multiple requirements assertThat(Either.left(42)).hasLeftValueSatisfying(it -> { assertThat(it).isEqualTo(42); assertThat(it).isLessThan(100); assertThat(it).isGreaterThan(0); });assertThat(Either.left(42)).hasLeftValueSatisfying(it -> assertThat(it).isEqualTo(24)); // fail because Either is right-sided, there is no value to perform assertion on assertThat(Either.right("something")).hasLeftValueSatisfying(it -> {});- Parameters:
requirement- to further assert on the left-sided object contained inside theEither.- Returns:
- this assertion object.
-
usingValueComparator
public SELF usingValueComparator(Comparator<?> customComparator)
Use given custom comparator instead of relying on actual type Aequalsmethod to compare theEithervalue'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.
-
usingFieldByFieldValueComparator
public SELF usingFieldByFieldValueComparator()
Use field/property by field/property comparison (including inherited fields/properties) instead of relying on actual type Aequalsmethod to compare theEithervalue's object for incoming assertion checks. Private fields are included but this can be disabled usingAssertions.setAllowExtractingPrivateFields(boolean).- Returns:
thisassertion object.
-
usingDefaultRightValueComparator
public SELF usingDefaultRightValueComparator()
Revert to standard comparison for incoming assertionEithervalue checks.This method should be used to disable a custom comparison strategy set by calling
usingValueComparator(Comparator).- Returns:
thisassertion 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()
-
-