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 forLongAdder
s.- Since:
- 3.16.0
- Author:
- Grzegorz Piwowarek
-
-
Field Summary
Fields Modifier and Type Field Description (package private) org.assertj.core.internal.Longs
longs
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractLongAdderAssert(LongAdder longAdder, Class<?> selfType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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
.Comparable.compareTo(Object)
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
.Comparable.compareTo(Object)
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.-
Methods inherited from class org.assertj.core.api.AbstractAssert
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, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, 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
-
-
-
-
Method Detail
-
hasValue
public SELF hasValue(long expected)
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
public SELF doesNotHaveValue(long unexpected)
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
public SELF usingComparator(Comparator<? super LongAdder> customComparator)
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
public SELF 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
public SELF 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
public SELF 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
public SELF 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
public SELF 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
public SELF 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
public SELF 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
public SELF 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
public SELF isEqualByComparingTo(Long other)
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
public SELF isNotEqualByComparingTo(Long other)
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
public SELF isLessThan(Long other)
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
public SELF isLessThanOrEqualTo(Long other)
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
public SELF isGreaterThan(Long other)
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
public SELF isGreaterThanOrEqualTo(Long other)
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
public SELF isBetween(Long start, Long end)
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
public SELF isStrictlyBetween(Long start, Long end)
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
public SELF isCloseTo(Long expected, Offset<Long> offset)
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
public SELF isNotCloseTo(Long expected, Offset<Long> offset)
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
public SELF isCloseTo(Long expected, Percentage percentage)
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
public SELF isNotCloseTo(Long expected, Percentage percentage)
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.
-
-