public class AtomicLongAssert extends AbstractAssert<AtomicLongAssert,AtomicLong>
actual, info, myself
Constructor and Description |
---|
AtomicLongAssert(AtomicLong actual) |
Modifier and Type | Method and 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.
If difference is equal to the offset value, assertion is considered valid. |
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 given custom comparator instead of relying on actual type A equals method for incoming assertion checks.
|
AtomicLongAssert |
usingDefaultComparator()
Revert to standard comparison for incoming assertion checks.
|
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, overridingErrorMessage, setCustomRepresentation, throwAssertionError, withFailMessage, withRepresentation, withThreadDumpOnError
public AtomicLongAssert(AtomicLong actual)
public AtomicLongAssert hasValueBetween(long startInclusive, long endInclusive)
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);
startInclusive
- the start value (inclusive).endInclusive
- the end value (inclusive).AssertionError
- if the actual atomic is null
.AssertionError
- if the actual atomic value is not in [start, end] range.public AtomicLongAssert hasValueLessThan(long other)
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);
other
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual atomic is null
.AssertionError
- if the actual value is equal to or greater than the given one.public AtomicLongAssert hasValueLessThanOrEqualTo(long other)
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);
other
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual atomic is null
.AssertionError
- if the actual atomic value is greater than the given one.public AtomicLongAssert hasValueGreaterThan(long other)
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);
other
- the given value to compare the actual value to.this
assertion object.AssertionError
- if actual is null
.AssertionError
- if the actual atomic value is equal to or less than the given one.public AtomicLongAssert hasValueGreaterThanOrEqualTo(long other)
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);
other
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual atomic is null
.AssertionError
- if the actual atomic value is less than the given one.public AtomicLongAssert hasPositiveValue()
Example:
// assertion will pass
assertThat(new AtomicLong(42)).hasPositiveValue();
// assertions will fail
assertThat(new AtomicLong(0)).hasPositiveValue();
assertThat(new AtomicLong(-1)).hasPositiveValue();
AssertionError
- if the actual atomic is null
.AssertionError
- if the actual atomic value is not positive.public AtomicLongAssert hasNonPositiveValue()
Example:
// assertions will pass
assertThat(new AtomicLong(-42)).hasNonPositiveValue();
assertThat(new AtomicLong(0)).hasNonPositiveValue();
// assertion will fail
assertThat(new AtomicLong(42)).hasNonPositiveValue();
this
assertion object.AssertionError
- if the actual atomic is null
.AssertionError
- if the actual atomic value is not non positive.public AtomicLongAssert hasNegativeValue()
Example:
// assertion will pass
assertThat(new AtomicLong(-42)).hasNegativeValue();
// assertions will fail
assertThat(new AtomicLong(0)).hasNegativeValue();
assertThat(new AtomicLong(42)).hasNegativeValue();
AssertionError
- if the actual atomic is null
.AssertionError
- if the actual atomic value is not negative.public AtomicLongAssert hasNonNegativeValue()
Example:
// assertions will pass
assertThat(new AtomicLong(42)).hasNonNegativeValue();
assertThat(new AtomicLong(0)).hasNonNegativeValue();
// assertion will fail
assertThat(new AtomicLong(-42)).hasNonNegativeValue();
this
assertion object.AssertionError
- if the actual atomic is null
.AssertionError
- if the actual atomic value is not non negative.public AtomicLongAssert hasValueCloseTo(long expected, Percentage percentage)
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));
expected
- the given number to compare the actual value to.percentage
- the given positive percentage.this
assertion object.NullPointerException
- if the given Percentage
is null
.AssertionError
- if the actual atomic value is not close enough to the given one.public AtomicLongAssert hasValueCloseTo(long expected, Offset<Long> offset)
Example with Long:
// assertions will pass:
assertThat(new AtomicLong(5)).hasValueCloseTo(7, offset(3));
// if the difference is exactly equals to the offset, it's ok
assertThat(new AtomicLong(5)).hasValueCloseTo(7, offset(2));
// assertion will fail
assertThat(new AtomicLong(5)).hasValueCloseTo(7, offset(1));
expected
- the given number to compare the actual value to.offset
- the given allowed Offset
.this
assertion object.NullPointerException
- if the given Offset
is null
.AssertionError
- if the actual atomic value is not close enough to the given one.public AtomicLongAssert hasValue(long expectedValue)
Example:
// assertion will pass
assertThat(new AtomicLong(42)).hasValue(42);
// assertion will fail
assertThat(new AtomicLong(42)).hasValue(0);
this
assertion object.AssertionError
- if the actual atomic is null
.AssertionError
- if the actual atomic value is not non negative.public AtomicLongAssert doesNotHaveValue(long expectedValue)
Example:
// assertion will pass
assertThat(new AtomicLong(42)).doesNotHaveValue(0);
// assertion will fail
assertThat(new AtomicLong(42)).doesNotHaveValue(42);
this
assertion object.AssertionError
- if the actual atomic is null
.AssertionError
- if the actual atomic value is not non negative.public AtomicLongAssert usingComparator(Comparator<? super AtomicLong> customComparator)
AbstractAssert
Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy. 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<AtomicLongAssert,AtomicLong>
usingComparator
in class AbstractAssert<AtomicLongAssert,AtomicLong>
customComparator
- the comparator to use for incoming assertion checks.this
assertion object.public AtomicLongAssert usingDefaultComparator()
AbstractAssert
This method should be used to disable a custom comparison strategy set by calling
Assert.usingComparator(Comparator)
.
usingDefaultComparator
in interface Assert<AtomicLongAssert,AtomicLong>
usingDefaultComparator
in class AbstractAssert<AtomicLongAssert,AtomicLong>
this
assertion object.Copyright © 2013–2017 AssertJ. All rights reserved.