Enum RecursiveAssertionConfiguration.CollectionAssertionPolicy
java.lang.Object
java.lang.Enum<RecursiveAssertionConfiguration.CollectionAssertionPolicy>
org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration.CollectionAssertionPolicy
- All Implemented Interfaces:
Serializable
,Comparable<RecursiveAssertionConfiguration.CollectionAssertionPolicy>
- Enclosing class:
RecursiveAssertionConfiguration
public static enum RecursiveAssertionConfiguration.CollectionAssertionPolicy
extends Enum<RecursiveAssertionConfiguration.CollectionAssertionPolicy>
Possible policies to use regarding collections (including arrays) when recursively asserting over the fields of an object tree.
-
Enum Constant Summary
Enum Constants -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the enum constant of this type with the specified name.values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
ELEMENTS_ONLY
Apply thePredicate
(recursively) to the elements of the collection/array but not the collection/array itself.Consider the following example:
With this policy,class Parent { List<String> greetings = new ArrayList<>(); } Parent parent = new Parent(); parent.greetings.add("Hello"); parent.greetings.add("Salut"); assertThat(parent).usingRecursiveAssertion() .allFieldsSatisfy(field -> myPredicate(field));
myPredicate(field)
is applied to the two strings"Hello"
and"Salut"
but not to thegreetings
field. -
COLLECTION_OBJECT_ONLY
public static final RecursiveAssertionConfiguration.CollectionAssertionPolicy COLLECTION_OBJECT_ONLYApply thePredicate
to the collection/array only but not to its elements.Consider the following example:
With this policy,class Parent { List<String> greetings = new ArrayList<>(); } Parent parent = new Parent(); parent.greetings.add("Hello"); parent.greetings.add("Salut"); assertThat(parent).usingRecursiveAssertion() .allFieldsSatisfy(field -> myPredicate(field));
myPredicate(field)
is applied to thegreetings
ArrayList field but not to the two strings"Hello"
and"Salut"
. -
COLLECTION_OBJECT_AND_ELEMENTS
public static final RecursiveAssertionConfiguration.CollectionAssertionPolicy COLLECTION_OBJECT_AND_ELEMENTSApply thePredicate
to the collection/array as well as to (recursively) its elements.Consider the following example:
With this policy,class Parent { List<String> greetings = new ArrayList<>(); } Parent parent = new Parent(); parent.greetings.add("Hello"); parent.greetings.add("Salut"); assertThat(parent).usingRecursiveAssertion() .allFieldsSatisfy(field -> myPredicate(field));
myPredicate(field)
is applied to thegreetings
ArrayList field and to the two strings"Hello"
and"Salut"
.
-
-
Constructor Details
-
CollectionAssertionPolicy
private CollectionAssertionPolicy()
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-