Class AtomicLongAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<AtomicLongAssert,AtomicLong>
-
- org.assertj.core.api.AtomicLongAssert
-
- All Implemented Interfaces:
Assert<AtomicLongAssert,AtomicLong>
,Descriptable<AtomicLongAssert>
,ExtensionPoints<AtomicLongAssert,AtomicLong>
public class AtomicLongAssert extends AbstractAssert<AtomicLongAssert,AtomicLong>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Comparables
comparables
(package private) Longs
longs
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, info, myself, objects, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description AtomicLongAssert(AtomicLong actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AtomicLongAssert
doesNotHaveValue(long expectedValue)
Verifies that the actual atomic has not the given value.AtomicLongAssert
hasNegativeValue()
Verifies that the actual atomic has a negative value.AtomicLongAssert
hasNonNegativeValue()
Verifies that the actual atomic has a non negative value (positive or equal zero).AtomicLongAssert
hasNonPositiveValue()
Verifies that the actual atomic has a non positive value (negative or equal zero).AtomicLongAssert
hasPositiveValue()
Verifies that the actual atomic has a positive value.AtomicLongAssert
hasValue(long expectedValue)
Verifies that the actual atomic has the given value.AtomicLongAssert
hasValueBetween(long startInclusive, long endInclusive)
Verifies that the actual atomic has a value in [start, end] range (start included, end included).AtomicLongAssert
hasValueCloseTo(long expected, Offset<Long> offset)
Verifies that the actual atomic has a value close to the given one within the given offset.AtomicLongAssert
hasValueCloseTo(long expected, Percentage percentage)
Verifies that the actual atomic has a value close to the given one within the given percentage.
If difference is equal to the percentage value, assertion is considered valid.AtomicLongAssert
hasValueGreaterThan(long other)
Verifies that the actual atomic has a value strictly greater than the given one.AtomicLongAssert
hasValueGreaterThanOrEqualTo(long other)
Verifies that the actual atomic has a value strictly greater than the given one.AtomicLongAssert
hasValueLessThan(long other)
Verifies that the actual atomic has a value strictly less than the given one.AtomicLongAssert
hasValueLessThanOrEqualTo(long other)
Verifies that the actual atomic has a value strictly less than the given one.AtomicLongAssert
usingComparator(Comparator<? super AtomicLong> customComparator)
Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.AtomicLongAssert
usingComparator(Comparator<? super AtomicLong> customComparator, String customComparatorDescription)
Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.AtomicLongAssert
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, equals, extracting, extracting, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, 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, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOf, 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, describedAs
-
-
-
-
Field Detail
-
comparables
Comparables comparables
-
longs
Longs longs
-
-
Constructor Detail
-
AtomicLongAssert
public AtomicLongAssert(AtomicLong actual)
-
-
Method Detail
-
hasValueBetween
public AtomicLongAssert hasValueBetween(long startInclusive, long endInclusive)
Verifies that the actual atomic has a value in [start, end] range (start included, end included).Example:
AtomicLong actual = new AtomicLong(5); // assertions succeed assertThat(actual).hasValueBetween(4, 6) .hasValueBetween(4, 5) .hasValueBetween(5, 6); // assertions fail assertThat(actual).hasValueBetween(6, 8) .hasValueBetween(0, 4);
- Parameters:
startInclusive
- the start value (inclusive).endInclusive
- the end value (inclusive).- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic value is not in [start, end] range.- Since:
- 2.7.0 / 3.7.0
-
hasValueLessThan
public AtomicLongAssert hasValueLessThan(long other)
Verifies that the actual atomic has a value strictly less than the given one.Example:
// assertions will pass: assertThat(new AtomicLong(1)).hasValueLessThan(2); assertThat(new AtomicLong(-2)).hasValueLessThan(-1); // assertions will fail: assertThat(new AtomicLong(1)).hasValueLessThan(0) .hasValueLessThan(1);
- Parameters:
other
- the given value to compare the actual value to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual value is equal to or greater than the given one.- Since:
- 2.7.0 / 3.7.0
-
hasValueLessThanOrEqualTo
public AtomicLongAssert hasValueLessThanOrEqualTo(long other)
Verifies that the actual atomic has a value strictly less than the given one.Example:
// assertions will pass: assertThat(new AtomicLong(1)).hasValueLessThanOrEqualTo(1) .hasValueLessThanOrEqualTo(2); assertThat(new AtomicLong(-2)).hasValueLessThanOrEqualTo(-1); // assertion will fail: assertThat(new AtomicLong(1)).hasValueLessThanOrEqualTo(0);
- Parameters:
other
- the given value to compare the actual value to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic value is greater than the given one.- Since:
- 2.7.0 / 3.7.0
-
hasValueGreaterThan
public AtomicLongAssert hasValueGreaterThan(long other)
Verifies that the actual atomic has a value strictly greater than the given one.Example:
// assertions will pass: assertThat(new AtomicLong(1)).hasValueGreaterThan(0); assertThat(new AtomicLong(-1)).hasValueGreaterThan(-2); // assertions will fail: assertThat(new AtomicLong(1)).hasValueGreaterThan(2) .hasValueGreaterThan(1);
- Parameters:
other
- the given value to compare the actual value to.- Returns:
this
assertion object.- Throws:
AssertionError
- if actual isnull
.AssertionError
- if the actual atomic value is equal to or less than the given one.- Since:
- 2.7.0 / 3.7.0
-
hasValueGreaterThanOrEqualTo
public AtomicLongAssert hasValueGreaterThanOrEqualTo(long other)
Verifies that the actual atomic has a value strictly greater than the given one.Example:
// assertions will pass: assertThat(new AtomicLong(1)).hasValueGreaterThanOrEqualTo(0) .hasValueGreaterThanOrEqualTo(1); assertThat(new AtomicLong(-1)).hasValueGreaterThanOrEqualTo(-2); // assertion will fail: assertThat(new AtomicLong(1)).hasValueGreaterThanOrEqualTo(2);
- Parameters:
other
- the given value to compare the actual value to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic value is less than the given one.- Since:
- 2.7.0 / 3.7.0
-
hasPositiveValue
public AtomicLongAssert hasPositiveValue()
Verifies that the actual atomic has a positive value.Example:
// assertion will pass assertThat(new AtomicLong(42)).hasPositiveValue(); // assertions will fail assertThat(new AtomicLong(0)).hasPositiveValue(); assertThat(new AtomicLong(-1)).hasPositiveValue();
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic value is not positive.- Since:
- 2.7.0 / 3.7.0
-
hasNonPositiveValue
public AtomicLongAssert hasNonPositiveValue()
Verifies that the actual atomic has a non positive value (negative or equal zero).Example:
// assertions will pass assertThat(new AtomicLong(-42)).hasNonPositiveValue(); assertThat(new AtomicLong(0)).hasNonPositiveValue(); // assertion will fail assertThat(new AtomicLong(42)).hasNonPositiveValue();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic value is not non positive.- Since:
- 2.7.0 / 3.7.0
-
hasNegativeValue
public AtomicLongAssert hasNegativeValue()
Verifies that the actual atomic has a negative value.Example:
// assertion will pass assertThat(new AtomicLong(-42)).hasNegativeValue(); // assertions will fail assertThat(new AtomicLong(0)).hasNegativeValue(); assertThat(new AtomicLong(42)).hasNegativeValue();
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic value is not negative.- Since:
- 2.7.0 / 3.7.0
-
hasNonNegativeValue
public AtomicLongAssert hasNonNegativeValue()
Verifies that the actual atomic has a non negative value (positive or equal zero).Example:
// assertions will pass assertThat(new AtomicLong(42)).hasNonNegativeValue(); assertThat(new AtomicLong(0)).hasNonNegativeValue(); // assertion will fail assertThat(new AtomicLong(-42)).hasNonNegativeValue();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic value is not non negative.- Since:
- 2.7.0 / 3.7.0
-
hasValueCloseTo
public AtomicLongAssert hasValueCloseTo(long expected, Percentage percentage)
Verifies that the actual atomic has a value close to the given one within the given percentage.
If difference is equal to the percentage value, assertion is considered valid.Example with Long:
// assertions will pass: assertThat(new AtomicLong(11)).hasValueCloseTo(10, withinPercentage(20)); // if difference is exactly equals to the computed offset (1), it's ok assertThat(new AtomicLong(11)).hasValueCloseTo(10, withinPercentage(10)); // assertion will fail assertThat(new AtomicLong(11)).hasValueCloseTo(10, withinPercentage(5));
- Parameters:
expected
- the given number to compare the actual value to.percentage
- the given positive percentage.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the givenPercentage
isnull
.AssertionError
- if the actual atomic value is not close enough to the given one.- Since:
- 2.7.0 / 3.7.0
-
hasValueCloseTo
public AtomicLongAssert hasValueCloseTo(long expected, Offset<Long> offset)
Verifies that the actual atomic has a value close to the given one within the given offset.When abs(actual - expected) == offset value, the assertion:
- succeeds when using
Assertions.within(Long)
orOffset.offset(Number)
- fails when using
Assertions.byLessThan(Long)
orOffset.strictOffset(Number)
Breaking change since 2.9.0/3.9.0: using
Assertions.byLessThan(Long)
implies a strict comparison, useAssertions.within(Long)
to get the old behavior.Example with Long:
// assertions will pass: assertThat(new AtomicLong(5)).hasValueCloseTo(7L, within(3L)) .hasValueCloseTo(7L, byLessThan(3L)); // if the difference is exactly equals to the offset, it's ok ... assertThat(new AtomicLong(5)).hasValueCloseTo(7L, within(2L)); // ... but not with byLessThan which implies a strict comparison assertThat(new AtomicLong(5)).hasValueCloseTo(7L, byLessThan(2L)); // FAIL // assertion will fail assertThat(new AtomicLong(5)).hasValueCloseTo(7L, within(1L)); assertThat(new AtomicLong(5)).hasValueCloseTo(7L, byLessThan(1L));
- Parameters:
expected
- the given number to compare the actual value to.offset
- the given allowedOffset
.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the givenOffset
isnull
.AssertionError
- if the actual atomic value is not close enough to the given one.- Since:
- 2.7.0 / 3.7.0
- succeeds when using
-
hasValue
public AtomicLongAssert hasValue(long expectedValue)
Verifies that the actual atomic has the given value.Example:
// assertion will pass assertThat(new AtomicLong(42)).hasValue(42); // assertion will fail assertThat(new AtomicLong(42)).hasValue(0);
- Parameters:
expectedValue
- the value not expected .- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic value is not non negative.- Since:
- 2.7.0 / 3.7.0
-
doesNotHaveValue
public AtomicLongAssert doesNotHaveValue(long expectedValue)
Verifies that the actual atomic has not the given value.Example:
// assertion will pass assertThat(new AtomicLong(42)).doesNotHaveValue(0); // assertion will fail assertThat(new AtomicLong(42)).doesNotHaveValue(42);
- Parameters:
expectedValue
- the value not expected .- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic value is not non negative.- Since:
- 2.7.0 / 3.7.0
-
usingComparator
public AtomicLongAssert usingComparator(Comparator<? super AtomicLong> 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<AtomicLongAssert,AtomicLong>
- Overrides:
usingComparator
in classAbstractAssert<AtomicLongAssert,AtomicLong>
- Parameters:
customComparator
- the comparator to use for the incoming assertion checks.- Returns:
this
assertion object.
-
usingComparator
public AtomicLongAssert usingComparator(Comparator<? super AtomicLong> 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<AtomicLongAssert,AtomicLong>
- Overrides:
usingComparator
in classAbstractAssert<AtomicLongAssert,AtomicLong>
- 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 AtomicLongAssert 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<AtomicLongAssert,AtomicLong>
- Overrides:
usingDefaultComparator
in classAbstractAssert<AtomicLongAssert,AtomicLong>
- Returns:
this
assertion object.
-
-