Class AbstractPeriodAssert<SELF extends AbstractPeriodAssert<SELF>>

    • Constructor Detail

      • AbstractPeriodAssert

        protected AbstractPeriodAssert​(Period period,
                                       Class<?> selfType)
        Creates a new AbstractPeriodAssert
        Parameters:
        period - the actual value to verify
        selfType - the "self type"
    • Method Detail

      • hasYears

        public SELF hasYears​(int expectedYears)
        Verifies that the actual Period has the given years.

        Example :

         // assertion will pass
         assertThat(Period.ofYears(5)).hasYears(5);
        
         // assertion will fail
         assertThat(Period.ofYears(5)).hasYears(1);
        Parameters:
        expectedYears - the expected years value
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Period is null
        AssertionError - if the actual Period does not have the given years
        Since:
        3.17.0
      • hasMonths

        public SELF hasMonths​(int expectedMonths)
        Verifies that the actual Period has the given months.

        Example :

         // assertion will pass
         assertThat(Period.ofMonths(5)).hasMonths(5);
        
         // assertion will fail
         assertThat(Period.ofMonths(5)).hasMonths(1);
        Parameters:
        expectedMonths - the expected months value
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Period is null
        AssertionError - if the actual Period does not have the given months
        Since:
        3.17.0
      • hasDays

        public SELF hasDays​(int expectedDays)
        Verifies that the actual Period has the given days.

        Example :

         // assertion will pass
         assertThat(Period.ofDays(5)).hasDays(5);
        
         // assertion will fail
         assertThat(Period.ofDays(5)).hasDays(1);
        Parameters:
        expectedDays - the expected days value
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Period is null
        AssertionError - if the actual Period does not have the given days
        Since:
        3.17.0
      • isPositive

        public SELF isPositive()
        Verifies that the actual Period is positive (i.e. is greater than Period.ZERO).

        Example :

         // assertion will pass
         assertThat(Period.ofMonths(5)).isPositive();
        
         // assertion will fail
         assertThat(Period.ofMonths(-2)).isPositive();
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Period is null
        AssertionError - if the actual Period is not greater than Period.ZERO
        Since:
        3.17.0
      • isNegative

        public SELF isNegative()
        Verifies that the actual Period is negative (i.e. is less than Period.ZERO).

        Example :

         // assertion will pass
         assertThat(Period.ofMonths(-5)).isNegative();
        
         // assertion will fail
         assertThat(Period.ofMonths(2)).isNegative();
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Period is null
        AssertionError - if the actual Period is not greater than Period.ZERO
        Since:
        3.17.0