Package org.assertj.core.api
Class AbstractOptionalDoubleAssert<SELF extends AbstractOptionalDoubleAssert<SELF>>
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,java.util.OptionalDouble>
-
- org.assertj.core.api.AbstractOptionalDoubleAssert<SELF>
-
- All Implemented Interfaces:
Assert<SELF,java.util.OptionalDouble>,Descriptable<SELF>,ExtensionPoints<SELF,java.util.OptionalDouble>
- Direct Known Subclasses:
OptionalDoubleAssert
public abstract class AbstractOptionalDoubleAssert<SELF extends AbstractOptionalDoubleAssert<SELF>> extends AbstractAssert<SELF,java.util.OptionalDouble>
Assertions forOptionalDouble.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Doublesdoubles-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractOptionalDoubleAssert(java.util.OptionalDouble actual, java.lang.Class<?> selfType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SELFhasValue(double expectedValue)Verifies that the actualOptionalDoublehas the value in argument.SELFhasValueCloseTo(java.lang.Double expectedValue, Offset<java.lang.Double> offset)Verifies that the actualOptionalDoublehas the value close to the argument.SELFhasValueCloseTo(java.lang.Double expectedValue, Percentage percentage)Verifies that the actualOptionalDoublehas a value close to the expected value, within the given percentage of the expected value.
If the difference is equal to the percentage value, the assertion is considered valid.SELFisEmpty()Verifies that the actualOptionalDoubleis empty.SELFisNotEmpty()Verifies that there is a value present in the actualOptionalDouble, it's an alias ofisPresent().SELFisNotPresent()Verifies that the actualOptionalis empty (alias ofisEmpty()).SELFisPresent()Verifies that there is a value present in the actualOptionalDouble.-
Methods inherited from class org.assertj.core.api.AbstractAssert
actual, areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingEquals, usingEquals, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withAssertionState, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs, describedAs
-
-
-
-
Field Detail
-
doubles
Doubles doubles
-
-
Method Detail
-
isPresent
public SELF isPresent()
Verifies that there is a value present in the actualOptionalDouble.Assertion will pass :
assertThat(OptionalDouble.of(10.0)).isPresent();Assertion will fail :
assertThat(OptionalDouble.empty()).isPresent();- Returns:
- this assertion object.
- Throws:
java.lang.AssertionError- if actual value is empty.java.lang.AssertionError- if actual is null.
-
isNotPresent
public SELF isNotPresent()
Verifies that the actualOptionalis empty (alias ofisEmpty()).Assertion will pass :
Assertion will fail :assertThat(OptionalDouble.empty()).isNotPresent();assertThat(OptionalDouble.of(10.0)).isNotPresent();- Returns:
- this assertion object.
-
isEmpty
public SELF isEmpty()
Verifies that the actualOptionalDoubleis empty.Assertion will pass :
assertThat(OptionalDouble.empty()).isEmpty();Assertion will fail :
assertThat(OptionalDouble.of(10.0)).isEmpty();- Returns:
- this assertion object.
- Throws:
java.lang.AssertionError- if actual value is present.java.lang.AssertionError- if actual is null.
-
isNotEmpty
public SELF isNotEmpty()
Verifies that there is a value present in the actualOptionalDouble, it's an alias ofisPresent().Assertion will pass :
assertThat(OptionalDouble.of(10.0)).isNotEmpty();Assertion will fail :
assertThat(OptionalDouble.empty()).isNotEmpty();- Returns:
- this assertion object.
- Throws:
java.lang.AssertionError- if actual value is empty.java.lang.AssertionError- if actual is null.
-
hasValue
public SELF hasValue(double expectedValue)
Verifies that the actualOptionalDoublehas the value in argument. The check is consistent withOptionalDouble.equals(Object)since 3.26.0.// assertions succeed: 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); assertThat(OptionalDouble.of(Double.POSITIVE_INFINITY)).hasValue(Double.POSITIVE_INFINITY); assertThat(OptionalDouble.of(Double.NEGATIVE_INFINITY)).hasValue(Double.NEGATIVE_INFINITY); // assertions fail: assertThat(OptionalDouble.empty()).hasValue(8.0); assertThat(OptionalDouble.of(7)).hasValue(8.0);- Parameters:
expectedValue- the expected value inside theOptionalDouble.- Returns:
- this assertion object.
- Throws:
java.lang.AssertionError- if actual value is empty.java.lang.AssertionError- if actual is null.java.lang.AssertionError- if actual does not have the expected value.
-
hasValueCloseTo
public SELF hasValueCloseTo(java.lang.Double expectedValue, Offset<java.lang.Double> offset)
Verifies that the actualOptionalDoublehas 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 theOptionalDouble.offset- the given positive offset.- Returns:
- this assertion object.
- Throws:
java.lang.AssertionError- if actual value is empty.java.lang.AssertionError- if actual is null.java.lang.AssertionError- if actual has not the value as expected.java.lang.NullPointerException- if offset is nulljava.lang.IllegalArgumentException- if offset is not positive.
-
hasValueCloseTo
public SELF hasValueCloseTo(java.lang.Double expectedValue, Percentage percentage)
Verifies that the actualOptionalDoublehas a value close to the expected value, within the given percentage of the expected value.
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 theOptionalDoublepercentage- the given positive percentage- Returns:
- the assertion object
- Throws:
java.lang.AssertionError- if actual value is emptyjava.lang.AssertionError- if actual is nulljava.lang.AssertionError- if the actual value is not close to the given one
-
-