Enum RecursiveAssertionConfiguration.CollectionAssertionPolicy

    • Enum Constant Detail

      • ELEMENTS_ONLY

        public static final RecursiveAssertionConfiguration.CollectionAssertionPolicy ELEMENTS_ONLY
        Apply the Predicate (recursively) to the elements of the collection/array but not the collection/array itself.

        Consider the following example:

         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));
        With this policy, myPredicate(field) is applied to the two strings "Hello" and "Salut" but not to the greetings field.
      • COLLECTION_OBJECT_ONLY

        public static final RecursiveAssertionConfiguration.CollectionAssertionPolicy COLLECTION_OBJECT_ONLY
        Apply the Predicate to the collection/array only but not to its elements.

        Consider the following example:

         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));
        With this policy, myPredicate(field) is applied to the greetings ArrayList field but not to the two strings "Hello" and "Salut".
      • COLLECTION_OBJECT_AND_ELEMENTS

        public static final RecursiveAssertionConfiguration.CollectionAssertionPolicy COLLECTION_OBJECT_AND_ELEMENTS
        Apply the Predicate to the collection/array as well as to (recursively) its elements.

        Consider the following example:

         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));
        With this policy, myPredicate(field) is applied to the greetings ArrayList field and to the two strings "Hello" and "Salut".
    • Constructor Detail

      • CollectionAssertionPolicy

        private CollectionAssertionPolicy()
    • Method Detail

      • values

        public static RecursiveAssertionConfiguration.CollectionAssertionPolicy[] 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.CollectionAssertionPolicy c : RecursiveAssertionConfiguration.CollectionAssertionPolicy.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.CollectionAssertionPolicy 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 name
        java.lang.NullPointerException - if the argument is null