Top Fields Constructors Methods
org.assertj.core.api

public Class RecursiveComparisonAssert<SELF extends RecursiveComparisonAssert<SELF>>

extends AbstractAssert<SELF extends RecursiveComparisonAssert<SELF>, Object>
Class Inheritance
Static Imports
org.assertj.core.error.ShouldBeEqualByComparingFieldByFieldRecursively.shouldBeEqualByComparingFieldByFieldRecursively, .ShouldNotBeEqualComparingFieldByFieldRecursively.shouldNotBeEqualComparingFieldByFieldRecursively

Field Summary

Modifier and TypeField and Description
private final RecursiveComparisonConfiguration
private final RecursiveComparisonDifferenceCalculator
Inherited from org.assertj.core.api.AbstractAssert:
actualassertionErrorCreatorconditionscustomRepresentationinfomyselfobjectsprintAssertionsDescriptionthrowUnsupportedExceptionOnEquals

Constructor Summary

AccessConstructor and Description
public
RecursiveComparisonAssert(Object actual, RecursiveComparisonConfiguration recursiveComparisonConfiguration)

Method Summary

Modifier and TypeMethod and Description
public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
comparingOnlyFields
(String...
the fields of the object under test to compare in the comparison.
fieldNamesToCompare
)

Makes the recursive comparison to only compare given actual fields and their subfields (no other fields will be compared).

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
comparingOnlyFieldsOfTypes
(Class<?>...
the types to compare in the recursive comparison.
typesToCompare
)

Makes the recursive comparison to only compare given actual fields of the specified types and their subfields (no other fields will be compared).

private List<ComparisonDifference>
public RecursiveComparisonConfiguration
public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringActualEmptyOptionalFields
()

Makes the recursive comparison to ignore all actual empty optional fields (including Optional, OptionalInt, OptionalLong and OptionalDouble), note that the expected object empty optional fields are not ignored, this only applies to actual's fields.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringActualNullFields
()

Makes the recursive comparison to ignore all actual null fields (but note that the expected object null fields are used in the comparison).

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringAllOverriddenEquals
()

This method instructs the recursive comparison to compare recursively all fields including the one whose type have overridden equals, except fields with java types (at some point we need to compare something!).

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringCollectionOrder
()

Makes the recursive comparison to ignore collection order in all fields in the object under test.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringCollectionOrderInFields
(String...
the fields of the object under test to ignore collection order in the comparison.
fieldsToIgnoreCollectionOrder
)

Makes the recursive comparison to ignore collection order in the object under test specified fields.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringCollectionOrderInFieldsMatchingRegexes
(String...
regexes used to find the object under test fields to ignore collection order in the comparison.
regexes
)

Makes the recursive comparison to ignore collection order in the object under test fields matching the specified regexes.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringExpectedNullFields
()

Makes the recursive comparison to ignore all expected null fields.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringFields
(String...
the field names of the object under test to ignore in the comparison.
fieldNamesToIgnore
)

Makes the recursive comparison to ignore the given object under test fields.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringFieldsMatchingRegexes
(String...
regexes used to ignore fields in the comparison.
regexes
)

Makes the recursive comparison to ignore the object under test fields whose name matches the given regexes.

public RecursiveComparisonAssert<?>

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringFieldsOfTypes
(Class<?>...
the types we want to ignore in the object under test fields.
typesToIgnore
)

Makes the recursive comparison to ignore the object under test fields of the given types.

public RecursiveComparisonAssert<?>

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringFieldsOfTypesMatchingRegexes
(String...
regexes specifying the types to ignore.
regexes
)

Makes the recursive comparison to ignore the fields of the object under test having types matching one of the given regexes.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringOverriddenEqualsForFields
(String...
the fields we want to force a recursive comparison on.
fields
)

In case you have instructed the recursive to use overridden equals with usingOverriddenEquals(), this method allows ignoring overridden equals for the given fields (it adds them to the already registered ones).

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringOverriddenEqualsForFieldsMatchingRegexes
(String...
regexes used to specify the fields we want to force a recursive comparison on.
regexes
)

In case you have instructed the recursive comparison to use overridden equals with usingOverriddenEquals(), this method allows forcing a recursive comparison for the fields matching the given regexes (it adds them to the already registered ones).

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
ignoringOverriddenEqualsForTypes
(Class<?>...
the types we want to force a recursive comparison on.
types
)

By default, the recursive comparison uses overridden equals methods to compare fields, this method allows forcing a recursive comparison for all fields of the given types (it adds them to the already registered ones).

public SELF

Returns:

this assertion object.
isEqualTo
(Object
the object to compare actual to.
expected
)

Overrides org.assertj.core.api.AbstractAssert.isEqualTo.

Implements org.assertj.core.api.Assert.isEqualTo.

Asserts that the object under test (actual) is equal to the given object when compared field by field recursively (including inherited fields are included in the comparison).
public SELF

Returns:

this assertion object.
isIn
(Object...
the given array to search the actual value in.
values
)

Overrides org.assertj.core.api.AbstractAssert.isIn.

Implements org.assertj.core.api.Assert.isIn.

Verifies that the actual value is present in the given array of values, comparing values with the recursive comparison.
public SELF

Returns:

this assertion object.
isIn
(Iterable<?>
the given iterable to search the actual value in.
values
)

Overrides org.assertj.core.api.AbstractAssert.isIn.

Implements org.assertj.core.api.Assert.isIn.

Verifies that the actual value is present in the given iterable, comparing values with the recursive comparison.
public SELF

Returns:

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

Overrides org.assertj.core.api.AbstractAssert.isNotEqualTo.

Implements org.assertj.core.api.Assert.isNotEqualTo.

Asserts that actual object is not equal to the given object based on a recursive property/field by property/field comparison (including inherited ones).
public SELF

Returns:

this assertion object.
isNotIn
(Object...
the given array to search the actual value in.
values
)

Overrides org.assertj.core.api.AbstractAssert.isNotIn.

Implements org.assertj.core.api.Assert.isNotIn.

Verifies that the actual value is not present in the given array of values, comparing values with the recursive comparison.
public SELF

Returns:

this assertion object.
isNotIn
(Iterable<?>
the given iterable to search the actual value in.
values
)

Overrides org.assertj.core.api.AbstractAssert.isNotIn.

Implements org.assertj.core.api.Assert.isNotIn.

Verifies that the actual value is not present in the given iterable, comparing values with the recursive comparison.
private void
public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
usingOverriddenEquals
()

By default, the recursive comparison compare recursively all fields including the ones whose type have overridden equals except fields with java types (at some point we need to compare something!).

private void
usingRecursiveComparator()

use a comparator performing a recursive comparison with the current recursiveComparisonConfiguration.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
withComparatorForFields
(Comparator<?>
the Comparator to use to compare the given fields
comparator
,
String...
the location from the root object of the fields the comparator should be used for
fieldLocations
)

Allows registering a comparator to compare fields with the given locations.

public <
the class type to register a comparator for
T
>
SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
withComparatorForType
(Comparator<? super T>
the Comparator to use to compare the given fields
comparator
,
Class<T>
the type to be compared with the given comparator.
type
)

Allows registering a comparator to compare the fields with the given type.

public SELF
withEnumStringComparison()

Allows the recursive comparison to compare an enum field against a String field and vice versa.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
withEqualsForFields
(BiPredicate<?, ?>
the BiPredicate to use to compare the given fields
equals
,
String...
the location from the root object of the fields the BiPredicate should be used for
fieldLocations
)

Allows registering a BiPredicate to compare fields with the given locations.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
withEqualsForFieldsMatchingRegexes
(BiPredicate<?, ?>
the BiPredicate to use to compare the fields matching the given regexes
equals
,
String...
the regexes from the root object of the field locations the BiPredicate should be used for
regexes
)

Allows registering a BiPredicate to compare fields whose location matches the given regexes.

public <
the class type to register a BiPredicate for
T
>
SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
withEqualsForType
(BiPredicate<? super T, ? super T>
the BiPredicate to use to compare the given fields
equals
,
Class<T>
the type to be compared with the given comparator.
type
)

Allows registering a BiPredicate to compare the fields with the given type.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
withErrorMessageForFields
(String
the error message that will be thrown when comparison error occurred.
message
,
String...
the fields the error message should be used for.
fieldLocations
)

Overrides an error message which would be shown when differences in the given fields while comparison occurred with the giving error message.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
withErrorMessageForType
(String
the error message that will be thrown when comparison error occurred.
message
,
Class<?>
the type the error message should be used for.
type
)

Overrides an error message which would be shown when differences for the giving type while comparison occurred with the giving error message.

public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
withIntrospectionStrategy
(RecursiveComparisonIntrospectionStrategy introspectionStrategy)

Defines how objects are introspected in the recursive comparison, that is:

  • how to traverse the graph of nodes to compare
  • how to get a node value
public SELF

Returns:

this RecursiveComparisonAssert to chain other methods.
withStrictTypeChecking
()

Makes the recursive comparison to check that actual's type is compatible with expected's type (and do the same for each field).

pack-priv SELF
Inherited from org.assertj.core.api.AbstractAssert:
areEqualasInstanceOfasListassertionErrorasStringdescribedAsdescriptionTextdoesNotHavedoesNotHaveSameClassAsdoesNotHaveSameHashCodeAsdoesNotHaveToStringdoesNotHaveToStringequalsextractingextractingfailurefailureWithActualExpectedfailWithActualExpectedAndMessagefailWithMessagegetWritableAssertionInfohashashCodehasSameClassAshasSameHashCodeAshasToStringhasToStringinBinaryinHexadecimalisisElementOfCustomAssertisExactlyInstanceOfisInstanceOfisInstanceOfAnyisInstanceOfSatisfyingisNotisNotExactlyInstanceOfisNotInstanceOfisNotInstanceOfAnyisNotNullisNotOfAnyClassInisNotSameAsisNullisOfAnyClassInisSameAsmatchesmatchesnewListAssertInstanceoverridingErrorMessageoverridingErrorMessagesatisfiessatisfiessatisfiessatisfiesAnyOfsatisfiesAnyOfsatisfiesAnyOfForProxysatisfiesForProxysetCustomRepresentationsetDescriptionConsumersetPrintAssertionsDescriptionthrowAssertionErrorusingComparatorusingComparatorusingDefaultComparatorusingRecursiveAssertionusingRecursiveAssertionusingRecursiveComparisonusingRecursiveComparisonwithAssertionStatewithFailMessagewithFailMessagewithRepresentationwithThreadDumpOnError