Class AbstractRecursiveOperationConfiguration
- Direct Known Subclasses:
RecursiveAssertionConfiguration
,RecursiveComparisonConfiguration
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
AbstractRecursiveOperationConfiguration.AbstractBuilder<BUILDER_TYPE extends AbstractRecursiveOperationConfiguration.AbstractBuilder<BUILDER_TYPE>>
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
AbstractRecursiveOperationConfiguration
(AbstractRecursiveOperationConfiguration.AbstractBuilder<?> builder) -
Method Summary
Modifier and TypeMethodDescriptionprotected static Class
<?> asWrapperIfPrimitiveType
(Class<?> type) private String
protected void
describeIgnoredFields
(StringBuilder description) protected void
describeIgnoredFieldsRegexes
(StringBuilder description) protected String
protected String
describeRegexes
(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.Returns the regexes that will be used to ignore fields with types matching these regexes in the recursive comparison.void
ignoreFields
(String... fieldsToIgnore) Adds the given fields to the set of fields from the object under test to ignore in the recursive comparison.void
ignoreFieldsMatchingRegexes
(String... regexes) Allows to ignore in the recursive comparison the object under test fields matching the given regexes.void
ignoreFieldsOfTypes
(Class<?>... types) Makes the recursive assertion to ignore the object under test fields of the given types.void
ignoreFieldsOfTypesMatchingRegexes
(String... regexes) Makes the recursive comparison to ignore the fields of the object under test having types matching one of the given regexes.protected static String
join
(Collection<String> typesDescription) boolean
matchesAnIgnoredField
(FieldLocation fieldLocation) boolean
matchesAnIgnoredFieldRegex
(FieldLocation fieldLocation) toPatterns
(String[] regexes)
-
Field Details
-
DEFAULT_DELIMITER
- See Also:
-
ignoredFields
-
ignoredFieldsRegexes
-
ignoredTypes
-
ignoredTypesRegexes
-
-
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: see
RecursiveComparisonAssert.ignoringFieldsOfTypes(Class[])
.- Parameters:
types
- the types of the object under test to ignore in the comparison.
-
ignoreFieldsOfTypesMatchingRegexes
Makes the recursive comparison to ignore the fields of the object under test having types matching one of the given regexes. The fields are ignored if their types exactly match one of the regexes, if a field is a subtype of a matched type it is not ignored.One use case of this method is to ignore types that can't be introspected.
If
strictTypeChecking
mode is enabled and a field of the object under test is null, the recursive comparison evaluates the corresponding expected field's type (if not null), if it is disabled then the field is evaluated as usual (i.e. it is not ignored).Warning: primitive types are not directly supported because under the hood they are converted to their corresponding wrapping types, for example
int
tojava.lang.Integer
. The preferred way to ignore primitive types is to useignoreFieldsOfTypes(Class[])
. Another way is to ignore the wrapping type, for example ignoringjava.lang.Integer
ignores bothjava.lang.Integer
andint
fields.Example: see
RecursiveComparisonAssert.ignoringFieldsOfTypesMatchingRegexes(String...)
.- Parameters:
regexes
- regexes specifying the types to ignore.
-
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.
-
getIgnoredTypesRegexes
Returns the regexes that will be used to ignore fields with types matching these regexes in the recursive comparison.- Returns:
- the regexes that will be used to ignore fields with types matching these regexes in the recursive comparison.
-
describeIgnoredFields
-
describeIgnoredFieldsRegexes
-
describeIgnoredTypes
-
describeRegexes
-
join
-
matchesAnIgnoredFieldRegex
-
matchesAnIgnoredField
-
describeIgnoredFields
-
toPatterns
-