Package org.assertj.core.api
Class AbstractLongAdderAssert<SELF extends AbstractLongAdderAssert<SELF>>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,LongAdder>
org.assertj.core.api.AbstractLongAdderAssert<SELF>
- Type Parameters:
SELF
- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation" for more details.
- All Implemented Interfaces:
Assert<SELF,
,LongAdder> ComparableAssert<SELF,
,Long> Descriptable<SELF>
,ExtensionPoints<SELF,
,LongAdder> NumberAssert<SELF,
Long>
- Direct Known Subclasses:
LongAdderAssert
public class AbstractLongAdderAssert<SELF extends AbstractLongAdderAssert<SELF>>
extends AbstractAssert<SELF,LongAdder>
implements NumberAssert<SELF,Long>, ComparableAssert<SELF,Long>
Base class for all implementations of assertions for
LongAdder
s.- Since:
- 3.16.0
- Author:
- Grzegorz Piwowarek
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractLongAdderAssert
(LongAdder longAdder, Class<?> selfType) -
Method Summary
Modifier and TypeMethodDescriptiondoesNotHaveValue
(long unexpected) Verifies that the actual sum has not the given value.hasValue
(long expected) Verifies that the actual sum has the given value.Verifies that the actual value is in [start, end] range (start included, end included).Verifies that the actual number is close to the given one within the given offset.
If difference is equal to offset value, assertion is considered valid.isCloseTo
(Long expected, Percentage percentage) Verifies that the actual number is close to the given one within the given percentage.
If difference is equal to the percentage value, assertion is considered valid.isEqualByComparingTo
(Long other) Verifies that the actual value is equal to the given one by invoking
.Comparable.compareTo(Object)
isGreaterThan
(Long other) Verifies that the actual value is greater than the given one.isGreaterThanOrEqualTo
(Long other) Verifies that the actual value is greater than or equal to the given one.isLessThan
(Long other) Verifies that the actual value is less than the given one.isLessThanOrEqualTo
(Long other) Verifies that the actual value is less than or equal to the given one.Verifies that the actual value is negative.isNotCloseTo
(Long expected, Offset<Long> offset) Verifies that the actual number is not close to the given one within the given offset.
If the difference is equal to the offset value, the assertion fails.isNotCloseTo
(Long expected, Percentage percentage) Verifies that the actual number is not close to the given one within the given percentage.
If difference is equal to the percentage value, the assertion fails.isNotEqualByComparingTo
(Long other) Verifies that the actual value is not equal to the given one by invoking
.Comparable.compareTo(Object)
Verifies that the actual value is non negative (positive or equal zero).Verifies that the actual value is non positive (negative or equal zero).Verifies that the actual value is not equal to zero.isOne()
Verifies that the actual value is equal to one.Verifies that the actual value is positive.isStrictlyBetween
(Long start, Long end) Verifies that the actual value is in ]start, end[ range (start excluded, end excluded).isZero()
Verifies that the actual value is equal to zero.usingComparator
(Comparator<? super LongAdder> customComparator) Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.usingComparator
(Comparator<? super LongAdder> customComparator, String customComparatorDescription) Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.Revert to standard comparison for the incoming assertion checks.Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, 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, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, 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
-
Constructor Details
-
AbstractLongAdderAssert
-
-
Method Details
-
hasValue
Verifies that the actual sum has the given value.Example:
// assertion will pass LongAdder actual = new LongAdder(); actual.add(42); assertThat(actual).hasValue(42); // assertion will fail assertThat(actual).hasValue(0);
- Parameters:
expected
- the expected value.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual adder isnull
.
-
doesNotHaveValue
Verifies that the actual sum has not the given value.Example:
// assertion will pass LongAdder actual = new LongAdder(); actual.add(42); assertThat(actual).doesNotHaveValue(0); // assertion will fail assertThat(actual).doesNotHaveValue(42);
- Parameters:
unexpected
- the unexpected value.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual adder isnull
.AssertionError
- if the actual sum is not the given value.
-
usingComparator
Description copied from class:AbstractAssert
Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.The custom comparator is bound to assertion instance, meaning that if a new assertion instance is created, the default comparison strategy will be used.
Examples :
// frodo and sam are instances of Character with Hobbit race (obviously :). // raceComparator implements Comparator<Character> assertThat(frodo).usingComparator(raceComparator).isEqualTo(sam);
- Specified by:
usingComparator
in interfaceAssert<SELF extends AbstractLongAdderAssert<SELF>,
LongAdder> - Overrides:
usingComparator
in classAbstractAssert<SELF extends AbstractLongAdderAssert<SELF>,
LongAdder> - Parameters:
customComparator
- the comparator to use for the incoming assertion checks.- Returns:
this
assertion object.
-
usingComparator
public SELF usingComparator(Comparator<? super LongAdder> customComparator, String customComparatorDescription) Description copied from class:AbstractAssert
Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.The custom comparator is bound to assertion instance, meaning that if a new assertion instance is created, the default comparison strategy will be used.
Examples :
// frodo and sam are instances of Character with Hobbit race (obviously :). // raceComparator implements Comparator<Character> assertThat(frodo).usingComparator(raceComparator, "Hobbit Race Comparator").isEqualTo(sam);
- Specified by:
usingComparator
in interfaceAssert<SELF extends AbstractLongAdderAssert<SELF>,
LongAdder> - Overrides:
usingComparator
in classAbstractAssert<SELF extends AbstractLongAdderAssert<SELF>,
LongAdder> - Parameters:
customComparator
- the comparator to use for the incoming assertion checks.customComparatorDescription
- comparator description to be used in assertion error messages- Returns:
this
assertion object.
-
usingDefaultComparator
Description copied from class:AbstractAssert
Revert to standard comparison for the incoming assertion checks.This method should be used to disable a custom comparison strategy set by calling
usingComparator
.- Specified by:
usingDefaultComparator
in interfaceAssert<SELF extends AbstractLongAdderAssert<SELF>,
LongAdder> - Overrides:
usingDefaultComparator
in classAbstractAssert<SELF extends AbstractLongAdderAssert<SELF>,
LongAdder> - Returns:
this
assertion object.
-
isZero
Description copied from interface:NumberAssert
Verifies that the actual value is equal to zero.Example:
// assertions will pass assertThat(0).isZero(); assertThat(0.0).isZero(); // assertions will fail assertThat(42).isZero(); assertThat(3.142).isZero();
- Specified by:
isZero
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Returns:
- this assertion object.
-
isNotZero
Description copied from interface:NumberAssert
Verifies that the actual value is not equal to zero.Example:
// assertions will pass assertThat(42).isNotZero(); assertThat(3.142).isNotZero(); // assertions will fail assertThat(0).isNotZero(); assertThat(0.0).isNotZero();
- Specified by:
isNotZero
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Returns:
- this assertion object.
-
isOne
Description copied from interface:NumberAssert
Verifies that the actual value is equal to one.Example:
// assertions will pass assertThat(1).isOne(); assertThat(1.0).isOne(); // assertions will fail assertThat(42).isOne(); assertThat(3.142).isOne();
- Specified by:
isOne
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Returns:
- this assertion object.
-
isPositive
Description copied from interface:NumberAssert
Verifies that the actual value is positive.Example:
// assertions will pass assertThat(42).isPositive(); assertThat(3.142).isPositive(); // assertions will fail assertThat(0).isPositive(); assertThat(-42).isPositive();
- Specified by:
isPositive
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Returns:
- this assertion object.
-
isNegative
Description copied from interface:NumberAssert
Verifies that the actual value is negative.Example:
// assertions will pass assertThat(-42).isNegative(); assertThat(-3.124).isNegative(); // assertions will fail assertThat(0).isNegative(); assertThat(42).isNegative();
- Specified by:
isNegative
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Returns:
- this assertion object.
-
isNotNegative
Description copied from interface:NumberAssert
Verifies that the actual value is non negative (positive or equal zero).Example:
// assertions will pass assertThat(42).isNotNegative(); assertThat(0).isNotNegative(); // assertions will fail assertThat(-42).isNotNegative(); assertThat(-3.124).isNotNegative();
- Specified by:
isNotNegative
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Returns:
this
assertion object.
-
isNotPositive
Description copied from interface:NumberAssert
Verifies that the actual value is non positive (negative or equal zero).Example:
// assertions will pass assertThat(-42).isNotPositive(); assertThat(0).isNotPositive(); // assertions will fail assertThat(42).isNotPositive(); assertThat(3.124).isNotPositive();
- Specified by:
isNotPositive
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Returns:
this
assertion object.
-
isEqualByComparingTo
Description copied from interface:ComparableAssert
Verifies that the actual value is equal to the given one by invoking
.Comparable.compareTo(Object)
Example:
// assertion will pass assertThat(1.0).isEqualByComparingTo(1.0); // assertion will pass because 8.0 is equal to 8.00 using
BigDecimal.compareTo(BigDecimal)
assertThat(new BigDecimal("8.0")).isEqualByComparingTo(new BigDecimal("8.00")); // assertion will fail assertThat(new BigDecimal(1.0)).isEqualByComparingTo(new BigDecimal(2.0));- Specified by:
isEqualByComparingTo
in interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
other
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
isNotEqualByComparingTo
Description copied from interface:ComparableAssert
Verifies that the actual value is not equal to the given one by invoking
.Comparable.compareTo(Object)
Example:
// assertion will pass assertThat(new BigDecimal(1.0)).isNotEqualByComparingTo(new BigDecimal(2.0)); // assertion will fail assertThat(1.0).isNotEqualByComparingTo(1.0); // assertion will fail because 8.0 is equal to 8.00 using
BigDecimal.compareTo(BigDecimal)
assertThat(new BigDecimal("8.0")).isNotEqualByComparingTo(new BigDecimal("8.00"));- Specified by:
isNotEqualByComparingTo
in interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
other
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
isLessThan
Description copied from interface:ComparableAssert
Verifies that the actual value is less than the given one.Example:
// assertions will pass assertThat('a').isLessThan('b'); assertThat(BigInteger.ZERO).isLessThan(BigInteger.ONE); // assertions will fail assertThat('a').isLessThan('a'); assertThat(BigInteger.ONE).isLessThan(BigInteger.ZERO);
- Specified by:
isLessThan
in interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
other
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
isLessThanOrEqualTo
Description copied from interface:ComparableAssert
Verifies that the actual value is less than or equal to the given one.Example:
// assertions will pass assertThat('a').isLessThanOrEqualTo('b'); assertThat('a').isLessThanOrEqualTo('a'); assertThat(BigInteger.ZERO).isLessThanOrEqualTo(BigInteger.ZERO); // assertions will fail assertThat('b').isLessThanOrEqualTo('a'); assertThat(BigInteger.ONE).isLessThanOrEqualTo(BigInteger.ZERO);
- Specified by:
isLessThanOrEqualTo
in interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
other
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
isGreaterThan
Description copied from interface:ComparableAssert
Verifies that the actual value is greater than the given one.Example:
// assertions will pass assertThat('b').isGreaterThan('a'); assertThat(BigInteger.ONE).isGreaterThan(BigInteger.ZERO); // assertions will fail assertThat('b').isGreaterThan('a'); assertThat(BigInteger.ZERO).isGreaterThan(BigInteger.ZERO);
- Specified by:
isGreaterThan
in interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
other
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
isGreaterThanOrEqualTo
Description copied from interface:ComparableAssert
Verifies that the actual value is greater than or equal to the given one.Example:
// assertions will pass assertThat('b').isGreaterThanOrEqualTo('a'); assertThat(BigInteger.ONE).isGreaterThanOrEqualTo(BigInteger.ONE); // assertions will fail assertThat('a').isGreaterThanOrEqualTo('b'); assertThat(BigInteger.ZERO).isGreaterThanOrEqualTo(BigInteger.ONE);
- Specified by:
isGreaterThanOrEqualTo
in interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
other
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
isBetween
Description copied from interface:NumberAssert
Verifies that the actual value is in [start, end] range (start included, end included).Example:
// these assertions succeed ... assertThat(12).isBetween(10, 14); assertThat(12).isBetween(12, 14); assertThat(12).isBetween(10, 12); // ... but this one fails assertThat(12).isBetween(14, 16);
- Specified by:
isBetween
in interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Specified by:
isBetween
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
start
- the start value (inclusive), expected not to be null.end
- the end value (inclusive), expected not to be null.- Returns:
- this assertion object.
-
isStrictlyBetween
Description copied from interface:NumberAssert
Verifies that the actual value is in ]start, end[ range (start excluded, end excluded).Example:
// this assertion succeeds ... assertThat(12).isStrictlyBetween(10, 14); // ... but these ones fail assertThat(12).isStrictlyBetween(12, 14); assertThat(12).isStrictlyBetween(10, 12); assertThat(12).isStrictlyBetween(16, 18);
- Specified by:
isStrictlyBetween
in interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Specified by:
isStrictlyBetween
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
start
- the start value (exclusive), expected not to be null.end
- the end value (exclusive), expected not to be null.- Returns:
- this assertion object.
-
isCloseTo
Description copied from interface:NumberAssert
Verifies that the actual number is close to the given one within the given offset.
If difference is equal to offset value, assertion is considered valid.Example with double:
// assertions will pass: assertThat(8.1).isCloseTo(8.0, within(0.2)); // you can use offset if you prefer assertThat(8.1).isCloseTo(8.0, offset(0.2)); // if difference is exactly equals to the offset (0.1), it's ok assertThat(8.1).isCloseTo(8.0, within(0.1)); // assertion will fail assertThat(8.1).isCloseTo(8.0, within(0.01));
- Specified by:
isCloseTo
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
expected
- the given number to compare the actual value to.offset
- the given positive offset.- Returns:
this
assertion object.
-
isNotCloseTo
Description copied from interface:NumberAssert
Verifies that the actual number is not close to the given one within the given offset.
If the difference is equal to the offset value, the assertion fails.Example with double:
// assertions will pass: assertThat(8.1).isNotCloseTo(8.0, byLessThan(0.01)); // you can use offset if you prefer assertThat(8.1).isNotCloseTo(8.0, offset(0.01)); // assertions will fail assertThat(8.1).isNotCloseTo(8.0, byLessThan(0.1)); assertThat(8.1).isNotCloseTo(8.0, byLessThan(0.2));
- Specified by:
isNotCloseTo
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
expected
- the given number to compare the actual value to.offset
- the given positive offset.- Returns:
this
assertion object.
-
isCloseTo
Description copied from interface:NumberAssert
Verifies that the actual number is close to the given one within the given percentage.
If difference is equal to the percentage value, assertion is considered valid.Example with double:
// assertions will pass: assertThat(11.0).isCloseTo(10.0, withinPercentage(20)); // if difference is exactly equals to the computed offset (1.0), it's ok assertThat(11.0).isCloseTo(10.0, withinPercentage(10)); // assertion will fail assertThat(11.0).isCloseTo(10.0, withinPercentage(5));
- Specified by:
isCloseTo
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
expected
- the given number to compare the actual value to.percentage
- the given positive percentage.- Returns:
this
assertion object.
-
isNotCloseTo
Description copied from interface:NumberAssert
Verifies that the actual number is not close to the given one within the given percentage.
If difference is equal to the percentage value, the assertion fails.Example with double:
// assertions will pass: assertThat(11.0).isNotCloseTo(10.0, withinPercentage(5)); // assertions will fail assertThat(11.0).isNotCloseTo(10.0, withinPercentage(10)); assertThat(11.0).isNotCloseTo(10.0, withinPercentage(20));
- Specified by:
isNotCloseTo
in interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,
Long> - Parameters:
expected
- the given number to compare the actual value to.percentage
- the given positive percentage.- Returns:
this
assertion object.
-