Enum RecursiveAssertionConfiguration.MapAssertionPolicy
java.lang.Object
java.lang.Enum<RecursiveAssertionConfiguration.MapAssertionPolicy>
org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration.MapAssertionPolicy
- All Implemented Interfaces:
Serializable
,Comparable<RecursiveAssertionConfiguration.MapAssertionPolicy>
- Enclosing class:
RecursiveAssertionConfiguration
public static enum RecursiveAssertionConfiguration.MapAssertionPolicy
extends Enum<RecursiveAssertionConfiguration.MapAssertionPolicy>
Possible policies to use regarding maps 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
-
MAP_OBJECT_ONLY
Apply thePredicate
to the map but not to its entries.Consider the following example:
With this policy,class Parent { Map<String, String> greetings = new HashMap<>(); } Parent parent = new Parent(); parent.greetings.put("english", "Hi"); parent.greetings.put("french", "Salut"); assertThat(parent).usingRecursiveAssertion() .allFieldsSatisfy(field -> myPredicate(field));
myPredicate(field)
is applied to thegreetings
field but not to the objects contained in thegreetings
map entries. -
MAP_VALUES_ONLY
Apply thePredicate
(recursively) to the map values but not to the map itself or its keys.
With this policy,class Parent { Map<String, String> greetings = new HashMap<>(); } Parent parent = new Parent(); parent.greetings.put("english", "Hi"); parent.greetings.put("french", "Salut"); assertThat(parent).usingRecursiveAssertion() .allFieldsSatisfy(field -> myPredicate(field));
myPredicate(field)
is applied to thegreetings
map values"Hi"
and"Salut"
but not to thegreetings
field itself or its keys. -
MAP_OBJECT_AND_ENTRIES
Apply thePredicate
to the map as well as (recursively) to its keys and values.Consider the following example:
With this policy,class Parent { Map<String, String> greetings = new HashMap<>(); } Parent parent = new Parent(); parent.greetings.put("english", "Hi"); parent.greetings.put("french", "Salut"); assertThat(parent).usingRecursiveAssertion() .allFieldsSatisfy(field -> myPredicate(field));
myPredicate(field)
is applied to thegreetings
field and also to the keys and values of thegreetings
map:"english", "Hi", "french"
and"Salut"
.
-
-
Constructor Details
-
MapAssertionPolicy
private MapAssertionPolicy()
-
-
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
-