Class AbstractDurationAssert<SELF extends AbstractDurationAssert<SELF>>

    • Constructor Detail

      • AbstractDurationAssert

        public AbstractDurationAssert​(Duration duration,
                                      Class<?> selfType)
        Parameters:
        duration - the actual value to verify
        selfType - the "self type"
    • Method Detail

      • isZero

        public SELF isZero()
        Verifies that the actual Duration is equal to Duration.ZERO.

        Example :

         // assertion will pass
         assertThat(Duration.ZERO).isZero();
        
         // assertion will fail
         assertThat(Duration.ofMinutes(3)).isZero();
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Duration is null
        AssertionError - if the actual Duration is not Duration.ZERO
        Since:
        3.15.0
      • isNegative

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

        Example :

         // assertion will pass
         assertThat(Duration.ofMinutes(-15)).isNegative();
        
         // assertion will fail
         assertThat(Duration.ofMinutes(10)).isNegative();
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Duration is null
        AssertionError - if the actual Duration is not less than Duration.ZERO
        Since:
        3.15.0
      • isPositive

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

        Example :

         // assertion will pass
         assertThat(Duration.ofHours(5)).isPositive();
        
         // assertion will fail
         assertThat(Duration.ofHours(-2)).isPositive();
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Duration is null
        AssertionError - if the actual Duration is not greater than Duration.ZERO
        Since:
        3.15.0
      • hasNanos

        public SELF hasNanos​(long otherNanos)
        Verifies that the actual Duration has the given nanos.

        Example :

         // assertion will pass
         assertThat(Duration.ofNanos(145)).hasNanos(145);
        
         // assertion will fail
         assertThat(Duration.ofNanos(145)).hasNanos(50);
        Parameters:
        otherNanos - the expected nanoseconds value
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Duration is null
        AssertionError - if the actual Duration does not have the given nanos
        Since:
        3.15.0
      • hasMillis

        public SELF hasMillis​(long otherMillis)
        Verifies that the actual Duration has the given millis.

        Example :

         // assertion will pass
         assertThat(Duration.ofMillis(250)).hasMillis(250);
        
         // assertion will fail
         assertThat(Duration.ofMillis(250)).hasMillis(700);
        Parameters:
        otherMillis - the expected milliseconds value
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Duration is null
        AssertionError - if the actual Duration does not have the given millis
        Since:
        3.15.0
      • hasSeconds

        public SELF hasSeconds​(long otherSeconds)
        Verifies that the actual Duration has the given seconds.

        Example :

         // assertion will pass
         assertThat(Duration.ofSeconds(250)).hasSeconds(250);
        
         // assertion will fail
         assertThat(Duration.ofSeconds(250)).hasSeconds(700);
        Parameters:
        otherSeconds - the expected seconds value
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Duration is null
        AssertionError - if the actual Duration does not have the given seconds
        Since:
        3.15.0
      • hasMinutes

        public SELF hasMinutes​(long otherMinutes)
        Verifies that the actual Duration has the given minutes.

        Example :

         // assertion will pass
         assertThat(Duration.ofMinutes(65)).hasMinutes(65);
        
         // assertion will fail
         assertThat(Duration.ofMinutes(65)).hasMinutes(25);
        Parameters:
        otherMinutes - the expected minutes value
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Duration is null
        AssertionError - if the actual Duration does not have the given minutes
        Since:
        3.15.0
      • hasHours

        public SELF hasHours​(long otherHours)
        Verifies that the actual Duration has the given hours.

        Example :

         // assertion will pass
         assertThat(Duration.ofHours(15)).hasHours(15);
        
         // assertion will fail
         assertThat(Duration.ofHours(15)).hasHours(5);
        Parameters:
        otherHours - the expected hours value
        Returns:
        this assertion object
        Throws:
        AssertionError - if the actual Duration is null
        AssertionError - if the actual Duration does not have the given hours
        Since:
        3.15.0
      • hasDays

        public SELF hasDays​(long otherDays)
        Verifies that the actual Duration has the given days.

        Example :

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