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 Details

    • MAP_OBJECT_ONLY

      public static final RecursiveAssertionConfiguration.MapAssertionPolicy MAP_OBJECT_ONLY
      Apply the Predicate to the map but not to its entries.

      Consider the following example:

       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)); 
      With this policy, myPredicate(field) is applied to the greetings field but not to the objects contained in the greetings map entries.
    • MAP_VALUES_ONLY

      public static final RecursiveAssertionConfiguration.MapAssertionPolicy MAP_VALUES_ONLY
      Apply the Predicate (recursively) to the map values but not to the map itself or its keys.

       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)); 
      With this policy, myPredicate(field) is applied to the greetings map values "Hi" and "Salut" but not to the greetings field itself or its keys.
    • MAP_OBJECT_AND_ENTRIES

      public static final RecursiveAssertionConfiguration.MapAssertionPolicy MAP_OBJECT_AND_ENTRIES
      Apply the Predicate to the map as well as (recursively) to its keys and values.

      Consider the following example:

       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)); 
      With this policy, myPredicate(field) is applied to the greetings field and also to the keys and values of the greetings 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 name
      NullPointerException - if the argument is null