Top Description Fields Constructors Methods
org.assertj.core.api

public abstract Class AbstractObjectAssert<SELF extends AbstractObjectAssert<SELF, ACTUAL>, ACTUAL>

extends AbstractAssert<SELF extends AbstractObjectAssert<SELF, ACTUAL>, ACTUAL>
Class Inheritance
Known Direct Subclasses
org.assertj.core.api.ThrowableAssertAlternative, org.assertj.core.api.AbstractThrowableAssert, org.assertj.core.api.AbstractUniversalComparableAssert, org.assertj.core.api.AbstractAtomicFieldUpdaterAssert, org.assertj.core.api.AbstractAtomicReferenceAssert, org.assertj.core.api.AbstractComparableAssert, org.assertj.core.api.ObjectAssert, org.assertj.core.api.AbstractMapAssert
Annotations
@SuppressWarnings:deprecation
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.
<ACTUAL>
the type of the "actual" value.
Static Imports
java.util.Objects.requireNonNull, java.util.stream.Collectors.toList, org.assertj.core.description.Description.mostRelevantDescription, org.assertj.core.error.ShouldNotBeNull.shouldNotBeNull, org.assertj.core.extractor.Extractors.byName, .Extractors.extractedDescriptionOf, org.assertj.core.internal.TypeComparators.defaultTypeComparators

Base class for all implementations of assertions for Objects.
Authors
Yvonne Wang, Alex Ruiz, Nicolas François, Mikhail Mazursky, Joel Costigliola, Libor Ondrusek

Field Summary

Modifier and TypeField and Description
private Map<String, Comparator<?>>
private TypeComparators
Inherited from org.assertj.core.api.AbstractAssert:
actualassertionErrorCreatorconditionscustomRepresentationinfomyselfobjectsprintAssertionsDescriptionthrowUnsupportedExceptionOnEquals

Constructor Summary

AccessConstructor and Description
public
AbstractObjectAssert(ACTUAL actual, Class<?> selfType)

Method Summary

Modifier and TypeMethod and Description
public SELF
as(Description
the new description to set.
description
)

Overrides default org.assertj.core.api.Descriptable.as.

Sets the description of the assertion that is going to be called after.
public SELF
as(String
the new description to set.
description
,
Object...
optional parameter if description is a format String.
args
)

Overrides default org.assertj.core.api.Descriptable.as.

Sets the description of the assertion that is going to be called after.
public <
the expected value type the given method returns.
T
>
SELF

Returns:

this assertion object.
doesNotReturn
(T
the value the object under test method's call should not return.
expected
,
Function<ACTUAL, T>
Function used to acquire the value to test from the object under test. Must not be null
from
)

Verifies that the object under test does not return the given expected value from the given Function, a typical usage is to pass a method reference to assert object's property.

public AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>>

Returns:

a new assertion object whose object under test is the list containing the extracted properties/fields values
extracting
(String...
the properties/fields to extract from the initial object under test
propertiesOrFields
)

Extracts the values of given fields/properties from the object under test into a list, this new list becoming the object under test.

public AbstractObjectAssert<?, ?>

Returns:

a new ObjectAssert instance whose object under test is the extracted property/field value
extracting
(String
the property/field to extract from the initial object under test
propertyOrField
)

Extracts the value of given field/property from the object under test, the extracted value becoming the new object under test.

public <
the type of the resulting Assert
ASSERT extends AbstractAssert<?, ?>
>
ASSERT

Returns:

a new narrowed Assert instance whose object under test is the extracted property/field value
extracting
(String
the property/field to extract from the initial object under test
propertyOrField
,
InstanceOfAssertFactory<?, ASSERT>
the factory which verifies the type and creates the new Assert
assertFactory
)

Extracts the value of given field/property from the object under test, the extracted value becoming the new object under test.

public final AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>>

Returns:

a new assertion object whose object under test is the list containing the extracted values
extracting
(Function<? super ACTUAL, ?>...
the extractor functions to extract values from the Object under test.
extractors
)

Uses the given Functions to extract the values from the object under test into a list, this new list becoming the object under test.

public <
the expected extracted value type.
T
>
AbstractObjectAssert<?, T>

Returns:

a new ObjectAssert instance whose object under test is the extracted value
extracting
(Function<? super ACTUAL, T>
the extractor function used to extract the value from the object under test.
extractor
)

Uses the given Function to extract a value from the object under test, the extracted value becoming the new object under test.

public <
the expected extracted value type
T
,
the type of the resulting Assert
ASSERT extends AbstractAssert<?, ?>
>
ASSERT

Returns:

a new narrowed Assert instance whose object under test is the extracted value
extracting
(Function<? super ACTUAL, T>
the extractor function used to extract the value from the object under test
extractor
,
InstanceOfAssertFactory<?, ASSERT>
the factory which verifies the type and creates the new Assert
assertFactory
)

Uses the given Function to extract a value from the object under test, the extracted value becoming the new object under test.

protected AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>>
extractingForProxy(Function<? super ACTUAL, ?>[] extractors)

private Objects
protected TypeComparators
public SELF

Returns:

this assertion object.
hasAllNullFieldsOrProperties
()

Asserts that the actual object has only null fields or properties.

public SELF

Returns:

this assertion object.
hasAllNullFieldsOrPropertiesExcept
(String...
properties/fields that won't be checked for not being null.
propertiesOrFieldsToIgnore
)

Asserts that the actual object has only null fields or properties except for the given ones (inherited ones are taken into account).

public SELF

Returns:

this assertion object.
hasFieldOrProperty
(String
the field/property name to check
name
)

Asserts that the actual object has the specified field or property.

public SELF

Returns:

this assertion object.
hasFieldOrPropertyWithValue
(String
the field/property name to check
name
,
Object
the field/property expected value
value
)

Asserts that the actual object has the specified field or property with the given value.

public SELF

Returns:

this assertion object.
hasNoNullFieldsOrProperties
()

Asserts that the actual object has no null fields or properties (inherited ones are taken into account).

public SELF

Returns:

this assertion object.
hasNoNullFieldsOrPropertiesExcept
(String...
properties/fields that won't be checked for null.
propertiesOrFieldsToIgnore
)

Asserts that the actual object has no null fields or properties except for the given ones (inherited ones are taken into account).

public SELF

Returns:

this assertion object.
hasOnlyFields
(String...
the expected field names actual should have
expectedFieldNames
)

Asserts that the actual object has only the specified fields and nothing else.

public SELF

Returns:

this assertions object
isEqualToComparingFieldByField
(Object
the object to compare actual to.
other
)

Deprecated Use the recursive comparison by calling usingRecursiveComparison().
public SELF

Returns:

this assertion object.
isEqualToComparingFieldByFieldRecursively
(Object
the object to compare actual to.
other
)

Deprecated Prefer calling usingRecursiveComparison() for comparing objects field by field as it offers more flexibility, better reporting and an easier to use API.
public SELF

Returns:

this assertion object.
isEqualToComparingOnlyGivenFields
(Object
the object to compare actual to.
other
,
String...
properties/fields used in comparison.
propertiesOrFieldsUsedInComparison
)

Deprecated Use the recursive comparison by calling usingRecursiveComparison() and specify the fields to ignore.
public SELF

Returns:

this assertion object.
isEqualToIgnoringGivenFields
(Object
the object to compare actual to.
other
,
String...
ignored properties/fields to ignore in comparison.
propertiesOrFieldsToIgnore
)

Deprecated Use the recursive comparison by calling usingRecursiveComparison() and chain with ignoringFields(String...).
public SELF

Returns:

this assertion object.
isEqualToIgnoringNullFields
(Object
the object to compare actual to.
other
)

Deprecated Use the recursive comparison by calling usingRecursiveComparison() and chain with ignoringExpectedNullFields().
protected <T> AbstractObjectAssert<?, T>
newObjectAssert(T objectUnderTest)

public <
the expected value type the given method returns.
T
>
SELF

Returns:

this assertion object.
returns
(T
the value the object under test method's call should return.
expected
,
Function<ACTUAL, T>
Function used to acquire the value to test from the object under test. Must not be null
from
)

Verifies that the object under test returns the given expected value from the given Function, a typical usage is to pass a method reference to assert object's property.

public <
the type of values to compare.
T
>
SELF

Returns:

this assertions object
usingComparatorForFields
(Comparator<T>
the Comparator to use
comparator
,
String...
the names of the properties and/or fields the comparator should be used for
propertiesOrFields
)

Allows to set a specific comparator to compare properties or fields with the given names.

public <
the type of objects that the comparator should be used for
T
>
SELF

Returns:

this assertions object
usingComparatorForType
(Comparator<? super T>
the Comparator to use
comparator
,
Class<T>
the Class of the type the comparator should be used for
type
)

Allows to set a specific comparator to compare properties or fields with the given type.

public RecursiveAssertionAssert

Returns:

A new instance of RecursiveAssertionAssert built with a default RecursiveAssertionConfiguration.
usingRecursiveAssertion
()

Overrides org.assertj.core.api.AbstractAssert.usingRecursiveAssertion.

Asserts that the given predicate is met for all fields of the object under test recursively (but not the object itself).

public RecursiveAssertionAssert

Returns:

A new instance of RecursiveAssertionAssert built with a default RecursiveAssertionConfiguration.
usingRecursiveAssertion
(RecursiveAssertionConfiguration
The recursion configuration described above.
recursiveAssertionConfiguration
)

Overrides org.assertj.core.api.AbstractAssert.usingRecursiveAssertion.

The same as usingRecursiveAssertion(), but this method allows the developer to pass in an explicit recursion configuration.

public RecursiveComparisonAssert<?>

Returns:

a new RecursiveComparisonAssert instance
usingRecursiveComparison
()

Overrides org.assertj.core.api.AbstractAssert.usingRecursiveComparison.

Enable using a recursive field by field comparison strategy when calling the chained isEqualTo assertion.
public RecursiveComparisonAssert<?>
pack-priv SELF
pack-priv SELF
pack-priv SELF
Inherited from org.assertj.core.api.AbstractAssert:
areEqualasInstanceOfasListassertionErrorasStringdescribedAsdescriptionTextdoesNotHavedoesNotHaveSameClassAsdoesNotHaveSameHashCodeAsdoesNotHaveToStringdoesNotHaveToStringequalsextractingextractingfailurefailureWithActualExpectedfailWithActualExpectedAndMessagefailWithMessagegetWritableAssertionInfohashashCodehasSameClassAshasSameHashCodeAshasToStringhasToStringinBinaryinHexadecimalisisElementOfCustomAssertisEqualToisExactlyInstanceOfisInisInisInstanceOfisInstanceOfAnyisInstanceOfSatisfyingisNotisNotEqualToisNotExactlyInstanceOfisNotInisNotInisNotInstanceOfisNotInstanceOfAnyisNotNullisNotOfAnyClassInisNotSameAsisNullisOfAnyClassInisSameAsmatchesmatchesnewListAssertInstanceoverridingErrorMessageoverridingErrorMessagesatisfiessatisfiessatisfiessatisfiesAnyOfsatisfiesAnyOfsatisfiesAnyOfForProxysatisfiesForProxysetCustomRepresentationsetDescriptionConsumersetPrintAssertionsDescriptionthrowAssertionErrorusingComparatorusingComparatorusingDefaultComparatorwithFailMessagewithFailMessagewithRepresentationwithThreadDumpOnError