Enum RecursiveAssertionConfiguration.MapAssertionPolicy
- java.lang.Object
-
- java.lang.Enum<RecursiveAssertionConfiguration.MapAssertionPolicy>
-
- org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration.MapAssertionPolicy
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<RecursiveAssertionConfiguration.MapAssertionPolicy>
- Enclosing class:
- RecursiveAssertionConfiguration
public static enum RecursiveAssertionConfiguration.MapAssertionPolicy extends java.lang.Enum<RecursiveAssertionConfiguration.MapAssertionPolicy>
Possible policies to use regarding maps when recursively asserting over the fields of an object tree.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description MAP_OBJECT_AND_ENTRIES
Apply thePredicate
to the map as well as (recursively) to its keys and values.MAP_OBJECT_ONLY
Apply thePredicate
to the map but not to its entries.MAP_VALUES_ONLY
Apply thePredicate
(recursively) to the map values but not to the map itself or its keys.
-
Constructor Summary
Constructors Modifier Constructor Description private
MapAssertionPolicy()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RecursiveAssertionConfiguration.MapAssertionPolicy
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static RecursiveAssertionConfiguration.MapAssertionPolicy[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
MAP_OBJECT_ONLY
public static final RecursiveAssertionConfiguration.MapAssertionPolicy 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
public static final RecursiveAssertionConfiguration.MapAssertionPolicy 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
public static final RecursiveAssertionConfiguration.MapAssertionPolicy 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"
.
-
-
Method Detail
-
values
public static RecursiveAssertionConfiguration.MapAssertionPolicy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (RecursiveAssertionConfiguration.MapAssertionPolicy c : RecursiveAssertionConfiguration.MapAssertionPolicy.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static RecursiveAssertionConfiguration.MapAssertionPolicy valueOf(java.lang.String name)
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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
-