SELF - the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation"
for more details.public class AbstractLongAdderAssert<SELF extends AbstractLongAdderAssert<SELF>> extends AbstractAssert<SELF,LongAdder> implements NumberAssert<SELF,Long>, ComparableAssert<SELF,Long>
LongAdders.actual, info, myself, objects, throwUnsupportedExceptionOnEquals| Modifier | Constructor and Description |
|---|---|
protected |
AbstractLongAdderAssert(LongAdder longAdder,
Class<?> selfType) |
| Modifier and Type | Method and Description |
|---|---|
SELF |
doesNotHaveValue(long unexpected)
Verifies that the actual sum has not the given value.
|
SELF |
hasValue(long expected)
Verifies that the actual sum has the given value.
|
SELF |
isBetween(Long start,
Long end)
Verifies that the actual value is in [start, end] range (start included, end included).
|
SELF |
isCloseTo(Long expected,
Offset<Long> offset)
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. |
SELF |
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. |
SELF |
isEqualByComparingTo(Long other)
Verifies that the actual value is equal to the given one by invoking
. |
SELF |
isGreaterThan(Long other)
Verifies that the actual value is greater than the given one.
|
SELF |
isGreaterThanOrEqualTo(Long other)
Verifies that the actual value is greater than or equal to the given one.
|
SELF |
isLessThan(Long other)
Verifies that the actual value is less than the given one.
|
SELF |
isLessThanOrEqualTo(Long other)
Verifies that the actual value is less than or equal to the given one.
|
SELF |
isNegative()
Verifies that the actual value is negative.
|
SELF |
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. |
SELF |
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. |
SELF |
isNotEqualByComparingTo(Long other)
Verifies that the actual value is not equal to the given one by invoking
. |
SELF |
isNotNegative()
Verifies that the actual value is non negative (positive or equal zero).
|
SELF |
isNotPositive()
Verifies that the actual value is non positive (negative or equal zero).
|
SELF |
isNotZero()
Verifies that the actual value is not equal to zero.
|
SELF |
isOne()
Verifies that the actual value is equal to one.
|
SELF |
isPositive()
Verifies that the actual value is positive.
|
SELF |
isStrictlyBetween(Long start,
Long end)
Verifies that the actual value is in ]start, end[ range (start excluded, end excluded).
|
SELF |
isZero()
Verifies that the actual value is equal to zero.
|
SELF |
usingComparator(Comparator<? super LongAdder> customComparator)
Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.
|
SELF |
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.
|
SELF |
usingDefaultComparator()
Revert to standard comparison for the incoming assertion checks.
|
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, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitas, as, as, describedAspublic SELF hasValue(long expected)
Example:
// assertion will pass
LongAdder actual = new LongAdder();
actual.add(42);
assertThat(actual).hasValue(42);
// assertion will fail
assertThat(actual).hasValue(0);expected - the expected value.this assertion object.AssertionError - if the actual adder is null.public SELF doesNotHaveValue(long unexpected)
Example:
// assertion will pass
LongAdder actual = new LongAdder();
actual.add(42);
assertThat(actual).doesNotHaveValue(0);
// assertion will fail
assertThat(actual).doesNotHaveValue(42);unexpected - the unexpected value.this assertion object.AssertionError - if the actual adder is null.AssertionError - if the actual sum is not the given value.public SELF usingComparator(Comparator<? super LongAdder> customComparator)
AbstractAssertThe 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);usingComparator in interface Assert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>usingComparator in class AbstractAssert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>customComparator - the comparator to use for the incoming assertion checks.this assertion object.public SELF usingComparator(Comparator<? super LongAdder> customComparator, String customComparatorDescription)
AbstractAssertThe 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);usingComparator in interface Assert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>usingComparator in class AbstractAssert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>customComparator - the comparator to use for the incoming assertion checks.customComparatorDescription - comparator description to be used in assertion error messagesthis assertion object.public SELF usingDefaultComparator()
AbstractAssert
This method should be used to disable a custom comparison strategy set by calling usingComparator.
usingDefaultComparator in interface Assert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>usingDefaultComparator in class AbstractAssert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>this assertion object.public SELF isZero()
NumberAssertExample:
// assertions will pass
assertThat(0).isZero();
assertThat(0.0).isZero();
// assertions will fail
assertThat(42).isZero();
assertThat(3.142).isZero();isZero in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>public SELF isNotZero()
NumberAssertExample:
// assertions will pass
assertThat(42).isNotZero();
assertThat(3.142).isNotZero();
// assertions will fail
assertThat(0).isNotZero();
assertThat(0.0).isNotZero();isNotZero in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>public SELF isOne()
NumberAssertExample:
// assertions will pass
assertThat(1).isOne();
assertThat(1.0).isOne();
// assertions will fail
assertThat(42).isOne();
assertThat(3.142).isOne();isOne in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>public SELF isPositive()
NumberAssertExample:
// assertions will pass
assertThat(42).isPositive();
assertThat(3.142).isPositive();
// assertions will fail
assertThat(0).isPositive();
assertThat(-42).isPositive();isPositive in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>public SELF isNegative()
NumberAssertExample:
// assertions will pass
assertThat(-42).isNegative();
assertThat(-3.124).isNegative();
// assertions will fail
assertThat(0).isNegative();
assertThat(42).isNegative();isNegative in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>public SELF isNotNegative()
NumberAssertExample:
// assertions will pass
assertThat(42).isNotNegative();
assertThat(0).isNotNegative();
// assertions will fail
assertThat(-42).isNotNegative();
assertThat(-3.124).isNotNegative();isNotNegative in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>this assertion object.public SELF isNotPositive()
NumberAssertExample:
// assertions will pass
assertThat(-42).isNotPositive();
assertThat(0).isNotPositive();
// assertions will fail
assertThat(42).isNotPositive();
assertThat(3.124).isNotPositive();isNotPositive in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>this assertion object.public SELF isEqualByComparingTo(Long other)
ComparableAssertComparable.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));isEqualByComparingTo in interface ComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>other - the given value to compare the actual value to.this assertion object.public SELF isNotEqualByComparingTo(Long other)
ComparableAssertComparable.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"));isNotEqualByComparingTo in interface ComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>other - the given value to compare the actual value to.this assertion object.public SELF isLessThan(Long other)
ComparableAssertExample:
// 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);isLessThan in interface ComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>other - the given value to compare the actual value to.this assertion object.public SELF isLessThanOrEqualTo(Long other)
ComparableAssertExample:
// 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);isLessThanOrEqualTo in interface ComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>other - the given value to compare the actual value to.this assertion object.public SELF isGreaterThan(Long other)
ComparableAssertExample:
// 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);isGreaterThan in interface ComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>other - the given value to compare the actual value to.this assertion object.public SELF isGreaterThanOrEqualTo(Long other)
ComparableAssertExample:
// 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);isGreaterThanOrEqualTo in interface ComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>other - the given value to compare the actual value to.this assertion object.public SELF isBetween(Long start, Long end)
NumberAssertExample:
// 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);isBetween in interface ComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>isBetween in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>start - the start value (inclusive), expected not to be null.end - the end value (inclusive), expected not to be null.public SELF isStrictlyBetween(Long start, Long end)
NumberAssertExample:
// 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);isStrictlyBetween in interface ComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>isStrictlyBetween in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>start - the start value (exclusive), expected not to be null.end - the end value (exclusive), expected not to be null.public SELF isCloseTo(Long expected, Offset<Long> offset)
NumberAssertExample 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));isCloseTo in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>expected - the given number to compare the actual value to.offset - the given positive offset.this assertion object.public SELF isNotCloseTo(Long expected, Offset<Long> offset)
NumberAssertExample 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));isNotCloseTo in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>expected - the given number to compare the actual value to.offset - the given positive offset.this assertion object.public SELF isCloseTo(Long expected, Percentage percentage)
NumberAssertExample 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));isCloseTo in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>expected - the given number to compare the actual value to.percentage - the given positive percentage.this assertion object.public SELF isNotCloseTo(Long expected, Percentage percentage)
NumberAssertExample 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));isNotCloseTo in interface NumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>expected - the given number to compare the actual value to.percentage - the given positive percentage.this assertion object.Copyright © 2025. All rights reserved.