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 forLongAdders.- Since:
- 3.16.0
- Author:
- Grzegorz Piwowarek
-
-
Field Summary
Fields Modifier and Type Field Description (package private) org.assertj.core.internal.Longslongs-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractLongAdderAssert(LongAdder longAdder, Class<?> selfType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SELFdoesNotHaveValue(long unexpected)Verifies that the actual sum has not the given value.SELFhasValue(long expected)Verifies that the actual sum has the given value.SELFisBetween(Long start, Long end)Verifies that the actual value is in [start, end] range (start included, end included).SELFisCloseTo(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.SELFisCloseTo(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.SELFisEqualByComparingTo(Long other)Verifies that the actual value is equal to the given one by invoking.Comparable.compareTo(Object)SELFisGreaterThan(Long other)Verifies that the actual value is greater than the given one.SELFisGreaterThanOrEqualTo(Long other)Verifies that the actual value is greater than or equal to the given one.SELFisLessThan(Long other)Verifies that the actual value is less than the given one.SELFisLessThanOrEqualTo(Long other)Verifies that the actual value is less than or equal to the given one.SELFisNegative()Verifies that the actual value is negative.SELFisNotCloseTo(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.SELFisNotCloseTo(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.SELFisNotEqualByComparingTo(Long other)Verifies that the actual value is not equal to the given one by invoking.Comparable.compareTo(Object)SELFisNotNegative()Verifies that the actual value is non negative (positive or equal zero).SELFisNotPositive()Verifies that the actual value is non positive (negative or equal zero).SELFisNotZero()Verifies that the actual value is not equal to zero.SELFisOne()Verifies that the actual value is equal to one.SELFisPositive()Verifies that the actual value is positive.SELFisStrictlyBetween(Long start, Long end)Verifies that the actual value is in ]start, end[ range (start excluded, end excluded).SELFisZero()Verifies that the actual value is equal to zero.SELFusingComparator(Comparator<? super LongAdder> customComparator)Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.SELFusingComparator(Comparator<? super LongAdder> customComparator, String customComparatorDescription)Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.SELFusingDefaultComparator()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, satisfiesForProxy, 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:
thisassertion 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:
thisassertion 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:AbstractAssertUse 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:
usingComparatorin interfaceAssert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>- Overrides:
usingComparatorin classAbstractAssert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>- Parameters:
customComparator- the comparator to use for the incoming assertion checks.- Returns:
thisassertion object.
-
usingComparator
public SELF usingComparator(Comparator<? super LongAdder> customComparator, String customComparatorDescription)
Description copied from class:AbstractAssertUse 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:
usingComparatorin interfaceAssert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>- Overrides:
usingComparatorin 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:
thisassertion object.
-
usingDefaultComparator
public SELF usingDefaultComparator()
Description copied from class:AbstractAssertRevert 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:
usingDefaultComparatorin interfaceAssert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>- Overrides:
usingDefaultComparatorin classAbstractAssert<SELF extends AbstractLongAdderAssert<SELF>,LongAdder>- Returns:
thisassertion object.
-
isZero
public SELF isZero()
Description copied from interface:NumberAssertVerifies 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:
isZeroin interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Returns:
- this assertion object.
-
isNotZero
public SELF isNotZero()
Description copied from interface:NumberAssertVerifies 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:
isNotZeroin interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Returns:
- this assertion object.
-
isOne
public SELF isOne()
Description copied from interface:NumberAssertVerifies 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:
isOnein interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Returns:
- this assertion object.
-
isPositive
public SELF isPositive()
Description copied from interface:NumberAssertVerifies 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:
isPositivein interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Returns:
- this assertion object.
-
isNegative
public SELF isNegative()
Description copied from interface:NumberAssertVerifies 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:
isNegativein interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Returns:
- this assertion object.
-
isNotNegative
public SELF isNotNegative()
Description copied from interface:NumberAssertVerifies 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:
isNotNegativein interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Returns:
thisassertion object.
-
isNotPositive
public SELF isNotPositive()
Description copied from interface:NumberAssertVerifies 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:
isNotPositivein interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Returns:
thisassertion object.
-
isEqualByComparingTo
public SELF isEqualByComparingTo(Long other)
Description copied from interface:ComparableAssertVerifies 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 usingBigDecimal.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:
isEqualByComparingToin interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Parameters:
other- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isNotEqualByComparingTo
public SELF isNotEqualByComparingTo(Long other)
Description copied from interface:ComparableAssertVerifies 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 usingBigDecimal.compareTo(BigDecimal)assertThat(new BigDecimal("8.0")).isNotEqualByComparingTo(new BigDecimal("8.00"));- Specified by:
isNotEqualByComparingToin interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Parameters:
other- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isLessThan
public SELF isLessThan(Long other)
Description copied from interface:ComparableAssertVerifies 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:
isLessThanin interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Parameters:
other- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isLessThanOrEqualTo
public SELF isLessThanOrEqualTo(Long other)
Description copied from interface:ComparableAssertVerifies 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:
isLessThanOrEqualToin interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Parameters:
other- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isGreaterThan
public SELF isGreaterThan(Long other)
Description copied from interface:ComparableAssertVerifies 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:
isGreaterThanin interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Parameters:
other- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isGreaterThanOrEqualTo
public SELF isGreaterThanOrEqualTo(Long other)
Description copied from interface:ComparableAssertVerifies 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:
isGreaterThanOrEqualToin interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Parameters:
other- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isBetween
public SELF isBetween(Long start, Long end)
Description copied from interface:NumberAssertVerifies 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:
isBetweenin interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Specified by:
isBetweenin 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:NumberAssertVerifies 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:
isStrictlyBetweenin interfaceComparableAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Specified by:
isStrictlyBetweenin 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:NumberAssertVerifies 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:
isCloseToin interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Parameters:
expected- the given number to compare the actual value to.offset- the given positive offset.- Returns:
thisassertion object.
-
isNotCloseTo
public SELF isNotCloseTo(Long expected, Offset<Long> offset)
Description copied from interface:NumberAssertVerifies 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:
isNotCloseToin interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Parameters:
expected- the given number to compare the actual value to.offset- the given positive offset.- Returns:
thisassertion object.
-
isCloseTo
public SELF isCloseTo(Long expected, Percentage percentage)
Description copied from interface:NumberAssertVerifies 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:
isCloseToin interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Parameters:
expected- the given number to compare the actual value to.percentage- the given positive percentage.- Returns:
thisassertion object.
-
isNotCloseTo
public SELF isNotCloseTo(Long expected, Percentage percentage)
Description copied from interface:NumberAssertVerifies 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:
isNotCloseToin interfaceNumberAssert<SELF extends AbstractLongAdderAssert<SELF>,Long>- Parameters:
expected- the given number to compare the actual value to.percentage- the given positive percentage.- Returns:
thisassertion object.
-
-