Class AbstractBigIntegerAssert<SELF extends AbstractBigIntegerAssert<SELF>>

    • Constructor Detail

      • AbstractBigIntegerAssert

        public AbstractBigIntegerAssert​(BigInteger actual,
                                        Class<?> selfType)
    • Method Detail

      • isZero

        public SELF 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 interface NumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Returns:
        this assertion object.
        Since:
        2.7.0 / 3.7.0
      • isNotZero

        public SELF 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 interface NumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Returns:
        this assertion object.
        Since:
        2.7.0 / 3.7.0
      • isOne

        public SELF 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 interface NumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Returns:
        this assertion object.
        Since:
        2.7.0 / 3.7.0
      • isPositive

        public SELF 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 interface NumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Returns:
        this assertion object.
        Since:
        2.7.0 / 3.7.0
      • isNegative

        public SELF 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 interface NumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Returns:
        this assertion object.
        Since:
        2.7.0 / 3.7.0
      • isNotNegative

        public SELF 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 interface NumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Returns:
        this assertion object.
        Since:
        2.7.0 / 3.7.0
      • isNotPositive

        public SELF 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 interface NumberAssert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Returns:
        this assertion object.
        Since:
        2.7.0 / 3.7.0
      • isCloseTo

        public SELF isCloseTo​(BigInteger expected,
                              Offset<BigInteger> offset)
        Verifies that the actual number is close to the given one within the given offset.

        When abs(actual - expected) == offset value, the assertion:

        Breaking change since 2.9.0/3.9.0: using Assertions.byLessThan(BigInteger) implies a strict comparison, use Assertions.within(BigInteger) to get the old behavior.

        Example:

         import static org.assertj.core.api.Assertions.within;
          
         final BigInteger eight = new BigInteger("8");
         final BigInteger ten =  BigInteger.TEN;
        
         // valid assertion
         assertThat(eight).isCloseTo(ten, within(new BigInteger("3")));
         assertThat(eight).isCloseTo(ten, byLessThan(new BigInteger("3")));
        
         // if difference is exactly equals to given offset value, it's ok
         assertThat(eight).isCloseTo(ten, within(new BigInteger("2")));
         // ... but not with byLessThan which implies a strict comparison
         assertThat(eight).isCloseTo(ten, byLessThan(new BigInteger("2")));
        
         // assertions will fail:
         assertThat(eight).isCloseTo(ten, within(BigInteger.ONE));
         assertThat(eight).isCloseTo(ten, byLessThan(BigInteger.ONE));
        Specified by:
        isCloseTo in interface NumberAssert<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 is null.
        NullPointerException - if the expected number is null.
        AssertionError - if the actual value is not close to the given one.
        Since:
        2.7.0 / 3.7.0
      • isNotCloseTo

        public SELF isNotCloseTo​(BigInteger expected,
                                 Offset<BigInteger> offset)
        Verifies that the actual number is not close to the given one by less than the given offset.

        When abs(actual - expected) == offset value, the assertion:

        Breaking change since 2.9.0/3.9.0: using Assertions.byLessThan(BigInteger) implies a strict comparison, use Assertions.within(BigInteger) to get the old behavior.

        Examples:

         import static org.assertj.core.api.Assertions.byLessThan;
          
         final BigInteger eight = new BigInteger("8");
         final BigInteger ten =  BigInteger.TEN;
        
         // this assertion succeeds
         assertThat(eight).isNotCloseTo(ten, byLessThan(BigInteger.ONE));
         assertThat(eight).isNotCloseTo(ten, within(BigInteger.ONE));
        
         // diff == offset but isNotCloseTo succeeds as we use byLessThan
         assertThat(eight).isNotCloseTo(ten, byLessThan(new BigInteger("2")));
        
         // the assertion fails as the difference is equal to the offset value and we use 'within'
         assertThat(eight).isNotCloseTo(ten, within(new BigInteger("2")));
         // the assertion fails if the difference is greater than the given offset value
         assertThat(eight).isNotCloseTo(ten, within(new BigInteger("3")));
         assertThat(eight).isNotCloseTo(ten, byLessThan(new BigInteger("3")));
        Specified by:
        isNotCloseTo in interface NumberAssert<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 is null.
        NullPointerException - if the expected number is null.
        AssertionError - if the actual value is close to the given one within the offset value.
        Since:
        2.7.0 / 3.7.0
        See Also:
        Assertions.byLessThan(BigInteger)
      • isCloseTo

        public SELF 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.

        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 interface NumberAssert<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 is null.
        NullPointerException - if the expected number is null.
        AssertionError - if the actual value is not close to the given one.
        Since:
        2.7.0 / 3.7.0
      • isNotCloseTo

        public SELF 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.

        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 interface NumberAssert<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 is null.
        NullPointerException - if the expected number is null.
        AssertionError - if the actual value is close to the given one.
        Since:
        2.7.0 / 3.7.0
      • isEqualTo

        public SELF isEqualTo​(String expected)
        Same as isEqualTo(BigInteger) but takes care of converting given String to BigInteger for you.

        Example:

         // assertion will pass
         assertThat(new BigInteger("8")).isEqualTo("8");
        
         // assertion will fail
         assertThat(new BigInteger("8")).isEqualTo("2");
        Parameters:
        expected - the given number to compare the actual value to.
        Returns:
        this assertion object.
        Since:
        2.7.0 / 3.7.0
      • isEqualTo

        public SELF isEqualTo​(int expected)
        Same as isEqualTo(BigInteger) but takes care of converting given int to BigInteger for you.

        Example:

         // assertion will pass
         assertThat(new BigInteger("8")).isEqualTo(8);
        
         // assertion will fail
         assertThat(new BigInteger("8")).isEqualTo(2);
        Parameters:
        expected - the expected value
        Returns:
        this assertion object.
        Since:
        2.7.0 / 3.7.0
      • isEqualTo

        public SELF isEqualTo​(long expected)
        Same as isEqualTo(BigInteger) but takes care of converting given int to BigInteger for you.

        Example:

         // assertion will pass
         assertThat(new BigInteger("8")).isEqualTo(8L);
        
         // assertion will fail
         assertThat(new BigInteger("8")).isEqualTo(2L);
        Parameters:
        expected - the expected value
        Returns:
        this assertion object.
        Since:
        2.7.0 / 3.7.0
      • usingComparator

        public SELF usingComparator​(Comparator<? super BigInteger> customComparator)
        Description copied from class: AbstractAssert
        Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.

        The custom comparator is bound to assertion instance, meaning that if a new assertion instance is created, the default comparison strategy will be used.

        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 interface Assert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Overrides:
        usingComparator in class AbstractComparableAssert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Parameters:
        customComparator - the comparator to use for the incoming assertion checks.
        Returns:
        this assertion object.
      • usingComparator

        public SELF usingComparator​(Comparator<? super BigInteger> customComparator,
                                    String customComparatorDescription)
        Description copied from class: AbstractAssert
        Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.

        The custom comparator is bound to assertion instance, meaning that if a new assertion instance is created, the default comparison strategy will be used.

        Examples :

         // frodo and sam are instances of Character with Hobbit race (obviously :).
         // raceComparator implements Comparator<Character>
         assertThat(frodo).usingComparator(raceComparator, "Hobbit Race Comparator").isEqualTo(sam);
        Specified by:
        usingComparator in interface Assert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Overrides:
        usingComparator in class AbstractComparableAssert<SELF extends AbstractBigIntegerAssert<SELF>,​BigInteger>
        Parameters:
        customComparator - the comparator to use for the incoming assertion checks.
        customComparatorDescription - comparator description to be used in assertion error messages
        Returns:
        this assertion object.