Top Fields Constructors Methods
org.assertj.core.api

public Class AtomicIntegerAssert

extends AbstractAssert<AtomicIntegerAssert, AtomicInteger>
Class Inheritance
Static Imports
org.assertj.core.error.ShouldHaveValue.shouldHaveValue, .ShouldNotContainValue.shouldNotContainValue

Field Summary

Modifier and TypeField and Description
pack-priv Comparables
pack-priv Integers
Inherited from org.assertj.core.api.AbstractAssert:
actualassertionErrorCreatorconditionscustomRepresentationinfomyselfobjectsprintAssertionsDescriptionthrowUnsupportedExceptionOnEquals

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public AtomicIntegerAssert

Returns:

this assertion object.
doesNotHaveValue
(int
the value not expected .
expectedValue
)

Verifies that the actual atomic does not have the given value.

public AtomicIntegerAssert

Returns:

this assertion object.
hasNegativeValue
()

Verifies that the actual atomic has a negative value.

public AtomicIntegerAssert

Returns:

this assertion object.
hasNonNegativeValue
()

Verifies that the actual atomic has a non negative value (positive or equal zero).

public AtomicIntegerAssert

Returns:

this assertion object.
hasNonPositiveValue
()

Verifies that the actual atomic has a non positive value (negative or equal zero).

public AtomicIntegerAssert

Returns:

this assertion object.
hasPositiveValue
()

Verifies that the actual atomic has a positive value.

public AtomicIntegerAssert

Returns:

this assertion object.
hasValue
(int
the expected value.
expectedValue
)

Verifies that the actual atomic has the given value.

public AtomicIntegerAssert

Returns:

this assertion object.
hasValueBetween
(int
the start value (inclusive).
startInclusive
,
int
the end value (inclusive).
endInclusive
)

Verifies that the actual atomic has a value in [start, end] range (start included, end included).

public AtomicIntegerAssert

Returns:

this assertion object.
hasValueCloseTo
(int
the given number to compare the actual value to.
expected
,
Percentage
the given positive percentage.
percentage
)

Verifies that the actual atomic has a value close to the given one within the given percentage.

public AtomicIntegerAssert

Returns:

this assertion object.
hasValueCloseTo
(int
the given number to compare the actual value to.
expected
,
Offset<Integer>
the given allowed Offset.
offset
)

Verifies that the actual atomic has a value close to the given one within the given offset.

public AtomicIntegerAssert

Returns:

this assertion object.
hasValueGreaterThan
(int
the given value to compare the actual value to.
other
)

Verifies that the actual atomic has a value strictly greater than the given one.

public AtomicIntegerAssert

Returns:

this assertion object.
hasValueGreaterThanOrEqualTo
(int
the given value to compare the actual value to.
other
)

Verifies that the actual atomic has a value strictly greater than the given one.

public AtomicIntegerAssert

Returns:

this assertion object.
hasValueLessThan
(int
the given value to compare the actual value to.
other
)

Verifies that the actual atomic has a value strictly less than the given one.

public AtomicIntegerAssert

Returns:

this assertion object.
hasValueLessThanOrEqualTo
(int
the given value to compare the actual value to.
other
)

Verifies that the actual atomic has a value strictly less than the given one.

public AtomicIntegerAssert
usingComparator(Comparator<? super AtomicInteger>
the comparator to use for the incoming assertion checks.
customComparator
)

Overrides org.assertj.core.api.AbstractAssert.usingComparator.

Implements org.assertj.core.api.Assert.usingComparator.

Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.
public AtomicIntegerAssert
usingComparator(Comparator<? super AtomicInteger>
the comparator to use for the incoming assertion checks.
customComparator
,
String
comparator description to be used in assertion error messages
customComparatorDescription
)

Overrides org.assertj.core.api.AbstractAssert.usingComparator.

Implements org.assertj.core.api.Assert.usingComparator.

Use the given custom comparator instead of relying on actual type A equals method for incoming assertion checks.
public AtomicIntegerAssert
usingDefaultComparator()

Overrides org.assertj.core.api.AbstractAssert.usingDefaultComparator.

Implements org.assertj.core.api.Assert.usingDefaultComparator.

Revert to standard comparison for the incoming assertion checks.
Inherited from org.assertj.core.api.AbstractAssert:
areEqualasInstanceOfasListassertionErrorasStringdescribedAsdescriptionTextdoesNotHavedoesNotHaveSameClassAsdoesNotHaveSameHashCodeAsdoesNotHaveToStringdoesNotHaveToStringequalsextractingextractingfailurefailureWithActualExpectedfailWithActualExpectedAndMessagefailWithMessagegetWritableAssertionInfohashashCodehasSameClassAshasSameHashCodeAshasToStringhasToStringinBinaryinHexadecimalisisElementOfCustomAssertisEqualToisExactlyInstanceOfisInisInisInstanceOfisInstanceOfAnyisInstanceOfSatisfyingisNotisNotEqualToisNotExactlyInstanceOfisNotInisNotInisNotInstanceOfisNotInstanceOfAnyisNotNullisNotOfAnyClassInisNotSameAsisNullisOfAnyClassInisSameAsmatchesmatchesnewListAssertInstanceoverridingErrorMessageoverridingErrorMessagesatisfiessatisfiessatisfiessatisfiesAnyOfsatisfiesAnyOfsatisfiesAnyOfForProxysatisfiesForProxysetCustomRepresentationsetDescriptionConsumersetPrintAssertionsDescriptionthrowAssertionErrorusingRecursiveAssertionusingRecursiveAssertionusingRecursiveComparisonusingRecursiveComparisonwithAssertionStatewithFailMessagewithFailMessagewithRepresentationwithThreadDumpOnError

Field Detail

comparablesback to summary
pack-priv Comparables comparables
Annotations
@VisibleForTesting
integersback to summary
pack-priv Integers integers
Annotations
@VisibleForTesting

Constructor Detail

AtomicIntegerAssertback to summary
public AtomicIntegerAssert(AtomicInteger actual)

Method Detail

doesNotHaveValueback to summary
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);
Parameters
expectedValue:int

the value not expected .

Returns:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual atomic is null.
  • if the actual atomic has the given value.
Since
2.7.0 / 3.7.0
hasNegativeValueback to summary
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:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual atomic is null.
  • if the actual atomic value is not negative.
Since
2.7.0 / 3.7.0
hasNonNegativeValueback to summary
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:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual atomic is null.
  • if the actual atomic value is not non negative.
Since
2.7.0 / 3.7.0
hasNonPositiveValueback to summary
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:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual atomic is null.
  • if the actual atomic value is not non positive.
Since
2.7.0 / 3.7.0
hasPositiveValueback to summary
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:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual atomic is null.
  • if the actual atomic value is not positive.
Since
2.7.0 / 3.7.0
hasValueback to summary
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);
Parameters
expectedValue:int

the expected value.

Returns:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual atomic is null.
  • if the actual atomic does not have the given value.
Since
2.7.0 / 3.7.0
hasValueBetweenback to summary
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:int

the start value (inclusive).

endInclusive:int

the end value (inclusive).

Returns:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual atomic is null.
  • if the actual atomic value is not in [start, end] range.
Since
2.7.0 / 3.7.0
hasValueCloseToback to summary
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:int

the given number to compare the actual value to.

percentage:Percentage

the given positive percentage.

Returns:AtomicIntegerAssert

this assertion object.

Exceptions
NullPointerException:
if the given Percentage is null.
AssertionError:
if the actual atomic value is not close enough to the given one.
Since
2.7.0 / 3.7.0
hasValueCloseToback to summary
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.

When abs(actual - expected) == offset value, the assertion:

Breaking change since 2.9.0/3.9.0: using Assertions#byLessThan(Integer) implies a strict comparison, use Assertions#within(Integer) to get the old behavior.

Example with Integer:

 // assertions will pass:
assertThat(new AtomicInteger(5)).hasValueCloseTo(7, within(3))
                                .hasValueCloseTo(7, byLessThan(3));

// if the difference is exactly equals to the offset, it's ok ...
assertThat(new AtomicInteger(5)).hasValueCloseTo(7, within(2));
// ... but not with byLessThan which implies a strict comparison
assertThat(new AtomicInteger(5)).hasValueCloseTo(7, byLessThan(2)); // FAIL

// assertion will fail
assertThat(new AtomicInteger(5)).hasValueCloseTo(7, within(1));
assertThat(new AtomicInteger(5)).hasValueCloseTo(7, byLessThan(1));
Parameters
expected:int

the given number to compare the actual value to.

offset:Offset<Integer>

the given allowed Offset.

Returns:AtomicIntegerAssert

this assertion object.

Exceptions
NullPointerException:
if the given Offset is null.
AssertionError:
if the actual atomic value is not close enough to the given one.
Since
2.7.0 / 3.7.0
hasValueGreaterThanback to summary
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:int

the given value to compare the actual value to.

Returns:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if actual is null.
  • if the actual atomic value is equal to or less than the given one.
Since
2.7.0 / 3.7.0
hasValueGreaterThanOrEqualToback to summary
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:int

the given value to compare the actual value to.

Returns:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual atomic is null.
  • if the actual atomic value is less than the given one.
Since
2.7.0 / 3.7.0
hasValueLessThanback to summary
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:int

the given value to compare the actual value to.

Returns:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual atomic is null.
  • if the actual value is equal to or greater than the given one.
Since
2.7.0 / 3.7.0
hasValueLessThanOrEqualToback to summary
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:int

the given value to compare the actual value to.

Returns:AtomicIntegerAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual atomic is null.
  • if the actual atomic value is greater than the given one.
Since
2.7.0 / 3.7.0
usingComparatorback to summary
public AtomicIntegerAssert usingComparator(Comparator<? super AtomicInteger> customComparator)

Overrides org.assertj.core.api.AbstractAssert.usingComparator.

Implements org.assertj.core.api.Assert.usingComparator.

Doc from org.assertj.core.api.AbstractAssert.usingComparator.

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);
Parameters
customComparator:Comparator<? super AtomicInteger>

Doc from org.assertj.core.api.Assert.usingComparator.

the comparator to use for the incoming assertion checks.

Returns:AtomicIntegerAssert

Doc from org.assertj.core.api.Assert.usingComparator.

this assertion object.

Annotations
@Override
@CheckReturnValue
usingComparatorback to summary
public AtomicIntegerAssert usingComparator(Comparator<? super AtomicInteger> customComparator, String customComparatorDescription)

Overrides org.assertj.core.api.AbstractAssert.usingComparator.

Implements org.assertj.core.api.Assert.usingComparator.

Doc from org.assertj.core.api.AbstractAssert.usingComparator.

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);
Parameters
customComparator:Comparator<? super AtomicInteger>

Doc from org.assertj.core.api.Assert.usingComparator.

the comparator to use for the incoming assertion checks.

customComparatorDescription:String

Doc from org.assertj.core.api.Assert.usingComparator.

comparator description to be used in assertion error messages

Returns:AtomicIntegerAssert

Doc from org.assertj.core.api.Assert.usingComparator.

this assertion object.

Annotations
@Override
@CheckReturnValue
usingDefaultComparatorback to summary
public AtomicIntegerAssert usingDefaultComparator()

Overrides org.assertj.core.api.AbstractAssert.usingDefaultComparator.

Implements org.assertj.core.api.Assert.usingDefaultComparator.

Doc from org.assertj.core.api.AbstractAssert.usingDefaultComparator.

Revert to standard comparison for the incoming assertion checks.

This method should be used to disable a custom comparison strategy set by calling usingComparator.

Returns:AtomicIntegerAssert

Doc from org.assertj.core.api.Assert.usingDefaultComparator.

this assertion object.

Annotations
@Override
@CheckReturnValue