Package org.assertj.core.api
Class AbstractBigIntegerAssert<SELF extends AbstractBigIntegerAssert<SELF>>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,BigInteger>
org.assertj.core.api.AbstractObjectAssert<SELF,BigInteger>
org.assertj.core.api.AbstractComparableAssert<SELF,BigInteger>
org.assertj.core.api.AbstractBigIntegerAssert<SELF>
- All Implemented Interfaces:
Assert<SELF,
,BigInteger> ComparableAssert<SELF,
,BigInteger> Descriptable<SELF>
,ExtensionPoints<SELF,
,BigInteger> NumberAssert<SELF,
BigInteger>
- Direct Known Subclasses:
BigIntegerAssert
public class AbstractBigIntegerAssert<SELF extends AbstractBigIntegerAssert<SELF>>
extends AbstractComparableAssert<SELF,BigInteger>
implements NumberAssert<SELF,BigInteger>
Base class for all implementations of assertions for
BigInteger
s.- Since:
- 2.7.0 / 3.7.0
-
Field Summary
FieldsFields inherited from class org.assertj.core.api.AbstractComparableAssert
comparables
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, conditions, info, myself, objects
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionisBetween
(BigInteger start, BigInteger end) Verifies that the actual value is in [start, end] range (start and end included).isCloseTo
(BigInteger expected, Offset<BigInteger> offset) Verifies that the actual number is close to the given one within the given offset.
If difference is equal to offset value, assertion is considered valid.isCloseTo
(BigInteger expected, Percentage percentage) Verifies that the actual number is close to the given one within the given percentage.
If difference is equal to the percentage value, assertion is considered valid.isEqualTo
(int expected) Same asisEqualTo(BigInteger)
but takes care of converting given int toBigInteger
for you.isEqualTo
(long expected) Same asisEqualTo(BigInteger)
but takes care of converting given int toBigInteger
for you.Same asisEqualTo(BigInteger)
but takes care of converting given String toBigInteger
for you.Verifies that the actual value is negative.isNotCloseTo
(BigInteger expected, Offset<BigInteger> offset) Verifies that the actual number is not close to the given one by less than the given offset.
If the difference is equal to the offset value, the assertion fails.isNotCloseTo
(BigInteger expected, Percentage percentage) Verifies that the actual number is not close to the given one by the given percentage.
If difference is equal to the percentage value, the assertion fails.Verifies that the actual value is non negative (positive or equal zero).Verifies that the actual value is non positive (negative or equal zero).Verifies that the actual value is not equal to zero.isOne()
Verifies that the actual value is equal to one.Verifies that the actual value is positive.isStrictlyBetween
(BigInteger start, BigInteger end) Verifies that the actual value is in ]start, end[ range (start excluded, end excluded).isZero()
Verifies that the actual value is equal to zero.usingComparator
(Comparator<? super BigInteger> customComparator) Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks.Revert to standard comparison for incoming assertion checks.Methods inherited from class org.assertj.core.api.AbstractComparableAssert
inBinary, inHexadecimal, isEqualByComparingTo, isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, isNotEqualByComparingTo
Methods inherited from class org.assertj.core.api.AbstractObjectAssert
as, as, defaultTypeComparators, extracting, extracting, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, returns, usingComparatorForFields, usingComparatorForType
Methods inherited from class org.assertj.core.api.AbstractAssert
asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasToString, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, overridingErrorMessage, satisfies, setCustomRepresentation, throwAssertionError, withFailMessage, withRepresentation, withThreadDumpOnError
-
Field Details
-
bigIntegers
BigIntegers bigIntegers
-
-
Constructor Details
-
AbstractBigIntegerAssert
-
-
Method Details
-
isZero
Verifies that the actual value is equal to zero.Example:
// assertion will pass assertThat(BigInteger.ZERO).isZero(); // assertion will fail assertThat(new BigInteger("8")).isZero();
- Specified by:
isZero
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Returns:
- this assertion object.
- Since:
- 2.7.0 / 3.7.0
-
isNotZero
Verifies that the actual value is not equal to zero.Example:
// assertion will pass assertThat(new BigInteger("8")).isNotZero(); // assertion will fail assertThat(BigInteger.ZERO).isNotZero();
- Specified by:
isNotZero
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Returns:
- this assertion object.
- Since:
- 2.7.0 / 3.7.0
-
isOne
Verifies that the actual value is equal to one.Example:
// assertion will pass assertThat(BigInteger.ONE).isOne(); // assertion will fail assertThat(new BigInteger("8")).isOne();
- Specified by:
isOne
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Returns:
- this assertion object.
- Since:
- 2.7.0 / 3.7.0
-
isPositive
Verifies that the actual value is positive.Example:
// assertion will pass assertThat(new BigInteger("8")).isPositive(); // assertion will fail assertThat(new BigInteger("-8")).isPositive();
- Specified by:
isPositive
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Returns:
- this assertion object.
- Since:
- 2.7.0 / 3.7.0
-
isNegative
Verifies that the actual value is negative.Example:
// assertion will pass assertThat(new BigInteger("-8")).isNegative(); // assertion will fail assertThat(new BigInteger("8")).isNegative();
- Specified by:
isNegative
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Returns:
- this assertion object.
- Since:
- 2.7.0 / 3.7.0
-
isNotNegative
Verifies that the actual value is non negative (positive or equal zero).Example:
// assertion will pass assertThat(new BigInteger("8")).isNotNegative(); // assertion will fail assertThat(new BigInteger("-8")).isNotNegative();
- Specified by:
isNotNegative
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Returns:
this
assertion object.- Since:
- 2.7.0 / 3.7.0
-
isNotPositive
Verifies that the actual value is non positive (negative or equal zero).Example:
// assertion will pass assertThat(new BigInteger("-8")).isNotPositive(); // assertion will fail assertThat(new BigInteger("8")).isNotPositive();
- Specified by:
isNotPositive
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Returns:
this
assertion object.- Since:
- 2.7.0 / 3.7.0
-
isCloseTo
Verifies that the actual number is close to the given one within the given offset.
If difference is equal to offset value, assertion is considered valid.Example:
import static org.assertj.core.api.Assertions.within; final BigInteger actual = new BigInteger("8"); final BigInteger other = new BigInteger("10"); // valid assertion assertThat(actual).isCloseTo(other, within(new BigInteger("3"))); // if difference is exactly equals to given offset value, it's ok assertThat(actual).isCloseTo(other, within(new BigInteger("2"))); // but if difference is greater than given offset value assertion will fail : assertThat(actual).isCloseTo(other, within(new BigInteger("1")));
- Specified by:
isCloseTo
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Parameters:
expected
- the given number to compare the actual value to.offset
- the given positive offset.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given offset isnull
.NullPointerException
- if the expected number isnull
.AssertionError
- if the actual value is not close to the given one.- Since:
- 2.7.0 / 3.7.0
-
isNotCloseTo
Verifies that the actual number is not close to the given one by less than the given offset.
If the difference is equal to the offset value, the assertion fails.Example:
import static org.assertj.core.api.Assertions.byLessThan; final BigInteger actual = new BigInteger("8"); final BigInteger other = new BigInteger("10"); // this assertion succeeds assertThat(actual).isNotCloseTo(other, byLessThan(new BigInteger("1"))); // the assertion fails if the difference is equal to the given offset value assertThat(actual).isNotCloseTo(other, byLessThan(new BigInteger("2"))); // the assertion fails if the difference is greater than the given offset value assertThat(actual).isNotCloseTo(other, byLessThan(new BigInteger("3")));
- Specified by:
isNotCloseTo
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Parameters:
expected
- the given number to compare the actual value to.offset
- the given positive offset.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given offset isnull
.NullPointerException
- if the expected number isnull
.AssertionError
- if the actual value is close to the given one within the offset value.- Since:
- 2.7.0 / 3.7.0
- See Also:
-
isCloseTo
Verifies that the actual number is close to the given one within the given percentage.
If difference is equal to the percentage value, assertion is considered valid.Example with BigInteger:
import static org.assertj.core.api.Assertions.withinPercentage; // assertions will pass: assertThat(new BigInteger("11")).isCloseTo(BigInteger.TEN, withinPercentage(20)); // if difference is exactly equals to the computed offset (1), it's ok assertThat(new BigInteger("11")).isCloseTo(BigInteger.TEN, withinPercentage(10)); // assertion will fail assertThat(new BigInteger("11")).isCloseTo(BigInteger.TEN, withinPercentage(5));
- Specified by:
isCloseTo
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Parameters:
expected
- the given number to compare the actual value to.percentage
- the given positive percentage.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given offset isnull
.NullPointerException
- if the expected number isnull
.AssertionError
- if the actual value is not close to the given one.- Since:
- 2.7.0 / 3.7.0
-
isNotCloseTo
Verifies that the actual number is not close to the given one by the given percentage.
If difference is equal to the percentage value, the assertion fails.Example with BigInteger:
import static org.assertj.core.api.Assertions.withinPercentage; BigInteger eleven = new BigInteger("11"); // assertion will pass: assertThat(eleven).isNotCloseTo(BigInteger.TEN, withinPercentage(5)); // assertion will fail as the difference is exactly equals to the computed offset (1) assertThat(eleven).isNotCloseTo(BigInteger.TEN, withinPercentage(10)); // assertion will fail assertThat(eleven).isNotCloseTo(BigInteger.TEN, withinPercentage(20));
- Specified by:
isNotCloseTo
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Parameters:
expected
- the given number to compare the actual value to.percentage
- the given positive percentage.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given offset isnull
.NullPointerException
- if the expected number isnull
.AssertionError
- if the actual value is close to the given one.- Since:
- 2.7.0 / 3.7.0
-
isBetween
Verifies that the actual value is in [start, end] range (start and end included).Example:
// assertions will pass assertThat(new BigInteger("8")).isBetween(new BigInteger("7"), new BigInteger("9")); assertThat(new BigInteger("8")).isBetween(new BigInteger("8"), new BigInteger("9")); assertThat(new BigInteger("8")).isBetween(new BigInteger("7"), new BigInteger("8")); // assertion will fail assertThat(new BigInteger("8")).isBetween(new BigInteger("6"), new BigInteger("7"));
- Specified by:
isBetween
in interfaceComparableAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Specified by:
isBetween
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Overrides:
isBetween
in classAbstractComparableAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Parameters:
start
- the start value (inclusive), expected not to be null.end
- the end value (inclusive), expected not to be null.- Returns:
- this assertion object.
- Since:
- 2.7.0 / 3.7.0
-
isStrictlyBetween
Verifies that the actual value is in ]start, end[ range (start excluded, end excluded).Example:
// assertion will pass assertThat(new BigInteger("8")).isStrictlyBetween(new BigInteger("7"), new BigInteger("9")); // assertions will fail assertThat(new BigInteger("8")).isStrictlyBetween(new BigInteger("8"), new BigInteger("9")); assertThat(new BigInteger("8")).isStrictlyBetween(new BigInteger("7"), new BigInteger("8"));
- Specified by:
isStrictlyBetween
in interfaceComparableAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Specified by:
isStrictlyBetween
in interfaceNumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Overrides:
isStrictlyBetween
in classAbstractComparableAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Parameters:
start
- the start value (exclusive), expected not to be null.end
- the end value (exclusive), expected not to be null.- Returns:
- this assertion object.
- Since:
- 2.7.0 / 3.7.0
-
isEqualTo
Same asisEqualTo(BigInteger)
but takes care of converting given String toBigInteger
for you.Example:
// assertion will pass assertThat(new BigInteger("8")).isEqualTo("8"); // assertion will fail assertThat(new BigInteger("8")).isEqualTo("2");
- Since:
- 2.7.0 / 3.7.0
-
isEqualTo
Same asisEqualTo(BigInteger)
but takes care of converting given int toBigInteger
for you.Example:
// assertion will pass assertThat(new BigInteger("8")).isEqualTo(8); // assertion will fail assertThat(new BigInteger("8")).isEqualTo(2);
- Since:
- 2.7.0 / 3.7.0
-
isEqualTo
Same asisEqualTo(BigInteger)
but takes care of converting given int toBigInteger
for you.Example:
// assertion will pass assertThat(new BigInteger("8")).isEqualTo(8L); // assertion will fail assertThat(new BigInteger("8")).isEqualTo(2L);
- Since:
- 2.7.0 / 3.7.0
-
usingComparator
Description copied from class:AbstractAssert
Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks.Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy. Examples :
// frodo and sam are instances of Character with Hobbit race (obviously :). // raceComparator implements Comparator<Character> assertThat(frodo).usingComparator(raceComparator).isEqualTo(sam);
- Specified by:
usingComparator
in interfaceAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Overrides:
usingComparator
in classAbstractComparableAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Parameters:
customComparator
- the comparator to use for incoming assertion checks.- Returns:
this
assertion object.
-
usingDefaultComparator
Description copied from class:AbstractAssert
Revert to standard comparison for incoming assertion checks.This method should be used to disable a custom comparison strategy set by calling
Assert.usingComparator(Comparator)
.- Specified by:
usingDefaultComparator
in interfaceAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Overrides:
usingDefaultComparator
in classAbstractComparableAssert<SELF extends AbstractBigIntegerAssert<SELF>,
BigInteger> - Returns:
this
assertion object.
-