Class AbstractOptionalDoubleAssert<SELF extends AbstractOptionalDoubleAssert<SELF>>

    • Constructor Detail

      • AbstractOptionalDoubleAssert

        protected AbstractOptionalDoubleAssert​(OptionalDouble actual,
                                               Class<?> selfType)
    • Method Detail

      • isPresent

        public SELF isPresent()
        Verifies that there is a value present in the actual OptionalDouble.

        Assertion will pass :

         assertThat(OptionalDouble.of(10.0)).isPresent();

        Assertion will fail :

         assertThat(OptionalDouble.empty()).isPresent();
        Returns:
        this assertion object.
        Throws:
        AssertionError - if actual value is empty.
        AssertionError - if actual is null.
      • isNotPresent

        public SELF isNotPresent()
        Verifies that the actual Optional is empty (alias of isEmpty()).

        Assertion will pass :

         assertThat(OptionalDouble.empty()).isNotPresent();
        Assertion will fail :
         assertThat(OptionalDouble.of(10.0)).isNotPresent();
        Returns:
        this assertion object.
      • isEmpty

        public SELF isEmpty()
        Verifies that the actual OptionalDouble is empty.

        Assertion will pass :

         assertThat(OptionalDouble.empty()).isEmpty();

        Assertion will fail :

         assertThat(OptionalDouble.of(10.0)).isEmpty();
        Returns:
        this assertion object.
        Throws:
        AssertionError - if actual value is present.
        AssertionError - if actual is null.
      • isNotEmpty

        public SELF isNotEmpty()
        Verifies that there is a value present in the actual OptionalDouble, it's an alias of isPresent().

        Assertion will pass :

         assertThat(OptionalDouble.of(10.0)).isNotEmpty();

        Assertion will fail :

         assertThat(OptionalDouble.empty()).isNotEmpty();
        Returns:
        this assertion object.
        Throws:
        AssertionError - if actual value is empty.
        AssertionError - if actual is null.
      • hasValue

        public SELF hasValue​(double expectedValue)
        Verifies that the actual OptionalDouble has the value in argument.

        Assertion will pass :

         assertThat(OptionalDouble.of(8.0)).hasValue(8.0);
         assertThat(OptionalDouble.of(8.0)).hasValue(Double.valueOf(8.0));
         assertThat(OptionalDouble.of(Double.NaN)).hasValue(Double.NaN); 

        Assertion will fail :

         assertThat(OptionalDouble.empty()).hasValue(8.0);
         assertThat(OptionalDouble.of(7)).hasValue(8.0);
        Parameters:
        expectedValue - the expected value inside the OptionalDouble.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if actual value is empty.
        AssertionError - if actual is null.
        AssertionError - if actual has not the value as expected.
      • hasValueCloseTo

        public SELF hasValueCloseTo​(Double expectedValue,
                                    Offset<Double> offset)
        Verifies that the actual OptionalDouble has the value close to the argument.

        Assertion will pass :

         assertThat(OptionalDouble.of(8)).hasValueCloseTo(8.0, within(0d));
         assertThat(OptionalDouble.of(8)).hasValueCloseTo(8.0, within(1d));
         assertThat(OptionalDouble.of(7)).hasValueCloseTo(8.0, within(1d));

        Assertion will fail :

         assertThat(OptionalDouble.empty()).hasValueCloseTo(8.0, within(1d));
         assertThat(OptionalDouble.of(7)).hasValueCloseTo(1.0, within(1d));
         assertThat(OptionalDouble.of(7)).hasValueCloseTo(1.0, null);
         assertThat(OptionalDouble.of(7)).hasValueCloseTo(1.0, within(-1d));
        Parameters:
        expectedValue - the expected value inside the OptionalDouble.
        offset - the given positive offset.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if actual value is empty.
        AssertionError - if actual is null.
        AssertionError - if actual has not the value as expected.
        NullPointerException - if offset is null
        IllegalArgumentException - if offset is not positive.
      • hasValueCloseTo

        public SELF hasValueCloseTo​(Double expectedValue,
                                    Percentage percentage)
        Verifies that the actual OptionalDouble has a value close to the expected value, within the given percentage.
        If the difference is equal to the percentage value, the assertion is considered valid.
        // The assertion will pass:
         assertThat(OptionalDouble.of(11)).hasValueCloseTo(10.0, withinPercentage(20));
        
         // If the difference is exactly equals to the computed offset (1.0), the assertion will pass:
         assertThat(OptionalDouble.of(11)).hasValueCloseTo(10.0, withinPercentage(10));
        
         // The assertions will fail:
         assertThat(OptionalDouble.of(11)).hasValueCloseTo(10.0, withinPercentage(5));
         assertThat(OptionalDouble.empty()).hasValueCloseTo(10.0, withinPercentage(5));
        Parameters:
        expectedValue - the expected value inside the OptionalDouble
        percentage - the given positive percentage
        Returns:
        the assertion object
        Throws:
        AssertionError - if actual value is empty
        AssertionError - if actual is null
        AssertionError - if the actual value is not close to the given one