Package org.assertj.core.api.recursive
Class AbstractRecursiveOperationConfiguration
java.lang.Object
org.assertj.core.api.recursive.AbstractRecursiveOperationConfiguration
- Direct Known Subclasses:
RecursiveAssertionConfiguration,RecursiveComparisonConfiguration
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAbstractRecursiveOperationConfiguration.AbstractBuilder<BUILDER_TYPE extends AbstractRecursiveOperationConfiguration.AbstractBuilder<BUILDER_TYPE>> -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractRecursiveOperationConfiguration(AbstractRecursiveOperationConfiguration.AbstractBuilder<?> builder) -
Method Summary
Modifier and TypeMethodDescriptionprotected static Class<?> asWrapperIfPrimitiveType(Class<?> type) private Stringprotected voiddescribeIgnoredFields(StringBuilder description) protected voiddescribeIgnoredFieldsRegexes(StringBuilder description) protected Stringprotected StringdescribeRegexes(List<Pattern> regexes) Returns the set of fields from the object under test to ignore in the recursive comparison.Returns the set of fields from the object under test types to ignore in the recursive comparison.voidignoreFields(String... fieldsToIgnore) Adds the given fields to the set of fields from the object under test to ignore in the recursive comparison.voidignoreFieldsMatchingRegexes(String... regexes) Allows to ignore in the recursive comparison the object under test fields matching the given regexes.voidignoreFieldsOfTypes(Class<?>... types) Makes the recursive assertion to ignore the object under test fields of the given types.protected static Stringjoin(Collection<String> typesDescription) booleanmatchesAnIgnoredField(FieldLocation fieldLocation) booleanmatchesAnIgnoredFieldRegex(FieldLocation fieldLocation)
-
Field Details
-
DEFAULT_DELIMITER
- See Also:
-
ignoredFields
-
ignoredFieldsRegexes
-
ignoredTypes
-
-
Constructor Details
-
AbstractRecursiveOperationConfiguration
protected AbstractRecursiveOperationConfiguration(AbstractRecursiveOperationConfiguration.AbstractBuilder<?> builder) -
AbstractRecursiveOperationConfiguration
protected AbstractRecursiveOperationConfiguration()
-
-
Method Details
-
ignoreFields
Adds the given fields to the set of fields from the object under test to ignore in the recursive comparison.The fields are ignored by name, not by value.
See
RecursiveComparisonAssert#ignoringFields(String...)for examples.- Parameters:
fieldsToIgnore- the fields of the object under test to ignore in the comparison.
-
getIgnoredFields
Returns the set of fields from the object under test to ignore in the recursive comparison.- Returns:
- the set of fields from the object under test to ignore in the recursive comparison.
-
ignoreFieldsMatchingRegexes
Allows to ignore in the recursive comparison the object under test fields matching the given regexes. The given regexes are added to the already registered ones.See
RecursiveComparisonAssert#ignoringFieldsMatchingRegexes(String...)for examples.- Parameters:
regexes- regexes used to ignore fields in the comparison.
-
getIgnoredFieldsRegexes
-
ignoreFieldsOfTypes
Makes the recursive assertion to ignore the object under test fields of the given types. The fields are ignored if their types exactly match one of the ignored types, for example if a field is a subtype of an ignored type it is not ignored.If some object under test fields are null it is not possible to evaluate their types and thus these fields are not ignored.
Example:
public class Person { String name; String occupation; Address address = new Address(); } public static class Address { int number; String street; } Person sherlock = new Person("Sherlock", "Detective"); sherlock.address.street = "Baker Street"; sherlock.address.number = 221; // assertion succeeds Person has only String fields except for address assertThat(sherlock).usingRecursiveAssertion() .ignoringFieldsOfTypes(Address.class) .allFieldsSatisfy(field -> field instanceof String); // assertion fails because of address and address.number assertThat(sherlock).usingRecursiveComparison() .allFieldsSatisfy(field -> field instanceof String);- Parameters:
types- the types of the object under test to ignore in the comparison.
-
asWrapperIfPrimitiveType
-
getIgnoredTypes
Returns the set of fields from the object under test types to ignore in the recursive comparison.- Returns:
- the set of fields from the object under test types to ignore in the recursive comparison.
-
describeIgnoredFields
-
describeIgnoredFieldsRegexes
-
describeIgnoredTypes
-
describeRegexes
-
join
-
matchesAnIgnoredFieldRegex
-
matchesAnIgnoredField
-
describeIgnoredFields
-