Class AbstractComparableAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>

    • Field Detail

      • comparables

        org.assertj.core.internal.Comparables comparables
    • Constructor Detail

      • AbstractComparableAssert

        protected AbstractComparableAssert​(ACTUAL actual,
                                           Class<?> selfType)
    • Method Detail

      • isLessThan

        public SELF isLessThan​(ACTUAL other)
        Verifies that the actual value is less than the given one.

        Example:

         // assertions will pass
         assertThat('a').isLessThan('b');
         assertThat(BigInteger.ZERO).isLessThan(BigInteger.ONE);
         
         // assertions will fail
         assertThat('a').isLessThan('a');
         assertThat(BigInteger.ONE).isLessThan(BigInteger.ZERO);
        Specified by:
        isLessThan in interface ComparableAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Parameters:
        other - the given value to compare the actual value to.
        Returns:
        this assertion object.
      • isLessThanOrEqualTo

        public SELF isLessThanOrEqualTo​(ACTUAL other)
        Verifies that the actual value is less than or equal to the given one.

        Example:

         // assertions will pass
         assertThat('a').isLessThanOrEqualTo('b');
         assertThat('a').isLessThanOrEqualTo('a');
         assertThat(BigInteger.ZERO).isLessThanOrEqualTo(BigInteger.ZERO);
         
         // assertions will fail
         assertThat('b').isLessThanOrEqualTo('a');
         assertThat(BigInteger.ONE).isLessThanOrEqualTo(BigInteger.ZERO);
        Specified by:
        isLessThanOrEqualTo in interface ComparableAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Parameters:
        other - the given value to compare the actual value to.
        Returns:
        this assertion object.
      • isGreaterThan

        public SELF isGreaterThan​(ACTUAL other)
        Verifies that the actual value is greater than the given one.

        Example:

         // assertions will pass
         assertThat('b').isGreaterThan('a');
         assertThat(BigInteger.ONE).isGreaterThan(BigInteger.ZERO);
         
         // assertions will fail
         assertThat('b').isGreaterThan('a');
         assertThat(BigInteger.ZERO).isGreaterThan(BigInteger.ZERO);
        Specified by:
        isGreaterThan in interface ComparableAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Parameters:
        other - the given value to compare the actual value to.
        Returns:
        this assertion object.
      • isGreaterThanOrEqualTo

        public SELF isGreaterThanOrEqualTo​(ACTUAL other)
        Verifies that the actual value is greater than or equal to the given one.

        Example:

         // assertions will pass
         assertThat('b').isGreaterThanOrEqualTo('a');
         assertThat(BigInteger.ONE).isGreaterThanOrEqualTo(BigInteger.ONE);
         
         // assertions will fail
         assertThat('a').isGreaterThanOrEqualTo('b');
         assertThat(BigInteger.ZERO).isGreaterThanOrEqualTo(BigInteger.ONE);
        Specified by:
        isGreaterThanOrEqualTo in interface ComparableAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Parameters:
        other - the given value to compare the actual value to.
        Returns:
        this assertion object.
      • isBetween

        public SELF isBetween​(ACTUAL startInclusive,
                              ACTUAL endInclusive)
        Verifies that the actual value is in [start, end] range (start included, end included).

        Example:

         // assertions succeed
         assertThat('b').isBetween('a', 'c');
         assertThat('a').isBetween('a', 'b');
         assertThat('b').isBetween('a', 'b');
         
         // assertions fail
         assertThat('a').isBetween('b', 'c');
         assertThat('c').isBetween('a', 'b');
        Specified by:
        isBetween in interface ComparableAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Parameters:
        startInclusive - the start value (inclusive), expected not to be null.
        endInclusive - the end value (inclusive), expected not to be null.
        Returns:
        this assertion object.
      • isStrictlyBetween

        public SELF isStrictlyBetween​(ACTUAL startExclusive,
                                      ACTUAL endExclusive)
        Verifies that the actual value is in ]start, end[ range (start excluded, end excluded).

        Example:

         // assertion succeeds
         assertThat('b').isStrictlyBetween('a', 'c');
         
         // assertions fail
         assertThat('d').isStrictlyBetween('a', 'c');
         assertThat('a').isStrictlyBetween('b', 'd');
         assertThat('a').isStrictlyBetween('a', 'b');
         assertThat('b').isStrictlyBetween('a', 'b');
        Specified by:
        isStrictlyBetween in interface ComparableAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Parameters:
        startExclusive - the start value (exclusive), expected not to be null.
        endExclusive - the end value (exclusive), expected not to be null.
        Returns:
        this assertion object.
      • usingComparator

        public SELF usingComparator​(Comparator<? super ACTUAL> 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 AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Overrides:
        usingComparator in class AbstractAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Parameters:
        customComparator - the comparator to use for the incoming assertion checks.
        Returns:
        this assertion object.
      • usingComparator

        public SELF usingComparator​(Comparator<? super ACTUAL> 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 AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Overrides:
        usingComparator in class AbstractAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        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.
      • inHexadecimal

        public SELF inHexadecimal()
        Description copied from class: AbstractAssert
        Use hexadecimal object representation instead of standard representation in error messages.

        It can be useful when comparing UNICODE characters - many unicode chars have duplicate characters assigned, it is thus impossible to find differences from the standard error message:

        With standard message:

         assertThat("µµµ").contains("μμμ");
        
         java.lang.AssertionError:
         Expecting:
           <"µµµ">
         to contain:
           <"μμμ">
        With Hexadecimal message:
         assertThat("µµµ").inHexadecimal().contains("μμμ");
        
         java.lang.AssertionError:
         Expecting:
           <"['00B5', '00B5', '00B5']">
         to contain:
           <"['03BC', '03BC', '03BC']">
        Overrides:
        inHexadecimal in class AbstractAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Returns:
        this assertion object.
      • inBinary

        public SELF inBinary()
        Description copied from class: AbstractAssert
        Use binary object representation instead of standard representation in error messages.

        Example:

         assertThat(1).inBinary().isEqualTo(2);
        
         org.junit.ComparisonFailure:
         Expected :0b00000000_00000000_00000000_00000010
         Actual   :0b00000000_00000000_00000000_00000001
        Overrides:
        inBinary in class AbstractAssert<SELF extends AbstractComparableAssert<SELF,​ACTUAL>,​ACTUAL extends Comparable<? super ACTUAL>>
        Returns:
        this assertion object.