Class AbstractPeriodAssert<SELF extends AbstractPeriodAssert<SELF>>

java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,Period>
org.assertj.core.api.AbstractPeriodAssert<SELF>
All Implemented Interfaces:
Assert<SELF,Period>, Descriptable<SELF>, ExtensionPoints<SELF,Period>
Direct Known Subclasses:
PeriodAssert

public abstract class AbstractPeriodAssert<SELF extends AbstractPeriodAssert<SELF>> extends AbstractAssert<SELF,Period>
Assertions for Period type.
Since:
3.17.0
Author:
Hayden Meloche
  • Constructor Details

    • AbstractPeriodAssert

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

    • 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