Package org.assertj.core.api
Class AtomicIntegerAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<AtomicIntegerAssert,AtomicInteger>
-
- org.assertj.core.api.AtomicIntegerAssert
-
- All Implemented Interfaces:
Assert<AtomicIntegerAssert,AtomicInteger>
,Descriptable<AtomicIntegerAssert>
,ExtensionPoints<AtomicIntegerAssert,AtomicInteger>
public class AtomicIntegerAssert extends AbstractAssert<AtomicIntegerAssert,AtomicInteger>
-
-
Field Summary
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself
-
-
Constructor Summary
Constructors Constructor Description AtomicIntegerAssert(AtomicInteger actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AtomicIntegerAssert
doesNotHaveValue(int expectedValue)
Verifies that the actual atomic does not have the given value.AtomicIntegerAssert
hasNegativeValue()
Verifies that the actual atomic has a negative value.AtomicIntegerAssert
hasNonNegativeValue()
Verifies that the actual atomic has a non negative value (positive or equal zero).AtomicIntegerAssert
hasNonPositiveValue()
Verifies that the actual atomic has a non positive value (negative or equal zero).AtomicIntegerAssert
hasPositiveValue()
Verifies that the actual atomic has a positive value.AtomicIntegerAssert
hasValue(int expectedValue)
Verifies that the actual atomic has the given value.AtomicIntegerAssert
hasValueBetween(int startInclusive, int endInclusive)
Verifies that the actual atomic has a value in [start, end] range (start included, end included).AtomicIntegerAssert
hasValueCloseTo(int expected, Offset<Integer> 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.AtomicIntegerAssert
hasValueCloseTo(int 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.AtomicIntegerAssert
hasValueGreaterThan(int other)
Verifies that the actual atomic has a value strictly greater than the given one.AtomicIntegerAssert
hasValueGreaterThanOrEqualTo(int other)
Verifies that the actual atomic has a value strictly greater than the given one.AtomicIntegerAssert
hasValueLessThan(int other)
Verifies that the actual atomic has a value strictly less than the given one.AtomicIntegerAssert
hasValueLessThanOrEqualTo(int other)
Verifies that the actual atomic has a value strictly less than the given one.AtomicIntegerAssert
usingComparator(Comparator<? super AtomicInteger> customComparator)
Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks.AtomicIntegerAssert
usingDefaultComparator()
Revert to standard comparison for incoming assertion checks.-
Methods inherited from class org.assertj.core.api.AbstractAssert
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, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, overridingErrorMessage, satisfies, setCustomRepresentation, throwAssertionError, withFailMessage, withRepresentation, withThreadDumpOnError
-
-
-
-
Constructor Detail
-
AtomicIntegerAssert
public AtomicIntegerAssert(AtomicInteger actual)
-
-
Method Detail
-
hasValueBetween
public AtomicIntegerAssert hasValueBetween(int startInclusive, int endInclusive)
Verifies that the actual atomic has a value in [start, end] range (start included, end included). Example:AtomicInteger actual = new AtomicInteger(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 AtomicIntegerAssert hasValueLessThan(int other)
Verifies that the actual atomic has a value strictly less than the given one.Example:
// assertions will pass: assertThat(new AtomicInteger(1)).hasValueLessThan(2); assertThat(new AtomicInteger(-2)).hasValueLessThan(-1); // assertions will fail: assertThat(new AtomicInteger(1)).hasValueLessThan(0); assertThat(new AtomicInteger(1)).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 AtomicIntegerAssert hasValueLessThanOrEqualTo(int other)
Verifies that the actual atomic has a value strictly less than the given one.Example:
// assertions will pass: assertThat(new AtomicInteger(1)).hasValueLessThanOrEqualTo(1) .hasValueLessThanOrEqualTo(2); assertThat(new AtomicInteger(-2)).hasValueLessThanOrEqualTo(-1); // assertion will fail: assertThat(new AtomicInteger(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 AtomicIntegerAssert hasValueGreaterThan(int other)
Verifies that the actual atomic has a value strictly greater than the given one.Example:
// assertions will pass: assertThat(new AtomicInteger(1)).hasValueGreaterThan(0); assertThat(new AtomicInteger(-1)).hasValueGreaterThan(-2); // assertions will fail: assertThat(new AtomicInteger(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 AtomicIntegerAssert hasValueGreaterThanOrEqualTo(int other)
Verifies that the actual atomic has a value strictly greater than the given one.Example:
// assertions will pass: assertThat(new AtomicInteger(1)).hasValueGreaterThanOrEqualTo(0); assertThat(new AtomicInteger(1)).hasValueGreaterThanOrEqualTo(1); assertThat(new AtomicInteger(-1)).hasValueGreaterThanOrEqualTo(-2); // assertion will fail: assertThat(new AtomicInteger(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 AtomicIntegerAssert hasPositiveValue()
Verifies that the actual atomic has a positive value.Example:
// assertion will pass assertThat(new AtomicInteger(42)).hasPositiveValue(); // assertions will fail assertThat(new AtomicInteger(0)).hasPositiveValue(); assertThat(new AtomicInteger(-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 AtomicIntegerAssert hasNonPositiveValue()
Verifies that the actual atomic has a non positive value (negative or equal zero).Example:
// assertions will pass assertThat(new AtomicInteger(-42)).hasNonPositiveValue(); assertThat(new AtomicInteger(0)).hasNonPositiveValue(); // assertion will fail assertThat(new AtomicInteger(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 AtomicIntegerAssert hasNegativeValue()
Verifies that the actual atomic has a negative value.Example:
// assertion will pass assertThat(new AtomicInteger(-42)).hasNegativeValue(); // assertions will fail assertThat(new AtomicInteger(0)).hasNegativeValue(); assertThat(new AtomicInteger(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 AtomicIntegerAssert hasNonNegativeValue()
Verifies that the actual atomic has a non negative value (positive or equal zero).Example:
// assertions will pass assertThat(new AtomicInteger(42)).hasNonNegativeValue(); assertThat(new AtomicInteger(0)).hasNonNegativeValue(); // assertion will fail assertThat(new AtomicInteger(-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 AtomicIntegerAssert hasValueCloseTo(int 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 integer:
// assertions will pass: assertThat(new AtomicInteger(11)).hasValueCloseTo(10, withinPercentage(20)); // if difference is exactly equals to the computed offset (1), it's ok assertThat(new AtomicInteger(11)).hasValueCloseTo(10, withinPercentage(10)); // assertion will fail assertThat(new AtomicInteger(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 AtomicIntegerAssert hasValueCloseTo(int expected, Offset<Integer> 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.Example with integer:
// assertions will pass: assertThat(new AtomicInteger(5)).hasValueCloseTo(7, offset(3)); // if the difference is exactly equals to the offset, it's ok assertThat(new AtomicInteger(5)).hasValueCloseTo(7, offset(2)); // assertion will fail assertThat(new AtomicInteger(5)).hasValueCloseTo(7, offset(1));
- 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
-
hasValue
public AtomicIntegerAssert hasValue(int expectedValue)
Verifies that the actual atomic has the given value.Example:
// assertion will pass assertThat(new AtomicInteger(42)).hasValue(42); // assertion will fail assertThat(new AtomicInteger(42)).hasValue(0);
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic does not have the given value.- Since:
- 2.7.0 / 3.7.0
-
doesNotHaveValue
public AtomicIntegerAssert doesNotHaveValue(int expectedValue)
Verifies that the actual atomic does not have the given value.Example:
// assertion will pass assertThat(new AtomicInteger(42)).doesNotHaveValue(0); // assertion will fail assertThat(new AtomicInteger(42)).doesNotHaveValue(42);
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual atomic isnull
.AssertionError
- if the actual atomic has the given value.- Since:
- 2.7.0 / 3.7.0
-
usingComparator
public AtomicIntegerAssert usingComparator(Comparator<? super AtomicInteger> customComparator)
Description copied from class:AbstractAssert
Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks.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);
- Specified by:
usingComparator
in interfaceAssert<AtomicIntegerAssert,AtomicInteger>
- Overrides:
usingComparator
in classAbstractAssert<AtomicIntegerAssert,AtomicInteger>
- Parameters:
customComparator
- the comparator to use for incoming assertion checks.- Returns:
this
assertion object.
-
usingDefaultComparator
public AtomicIntegerAssert usingDefaultComparator()
Description copied from class:AbstractAssert
Revert to standard comparison for incoming assertion checks.This method should be used to disable a custom comparison strategy set by calling
Assert.usingComparator(Comparator)
.- Specified by:
usingDefaultComparator
in interfaceAssert<AtomicIntegerAssert,AtomicInteger>
- Overrides:
usingDefaultComparator
in classAbstractAssert<AtomicIntegerAssert,AtomicInteger>
- Returns:
this
assertion object.
-
-