Class Extractors


  • public class Extractors
    extends Object
    Extractors factory, providing convenient methods of creating common extractors.

    For example:

     assertThat(objectsList).extracting(toStringMethod()).contains("toString 1", "toString 2");
     assertThat(objectsList).extracting(byName("field")).contains("someResult1", "someResult2");
    Author:
    Mateusz Haligowski
    • Constructor Detail

      • Extractors

        public Extractors()
    • Method Detail

      • byName

        public static <F> Function<F,​Object> byName​(String fieldOrProperty)
        Provides extractor for extracting single field or property from any object using reflection
        Type Parameters:
        F - type to extract property from
        Parameters:
        fieldOrProperty - the name of the field/property to extract
        Returns:
        the built Function
      • byName

        public static <F> Function<F,​Tuple> byName​(String... fieldsOrProperties)
        Provides extractor for extracting multiple fields or properties from any object using reflection
        Type Parameters:
        F - type to extract property from
        Parameters:
        fieldsOrProperties - the name of the fields/properties to extract
        Returns:
        the built Function
      • resultOf

        public static <F> Function<F,​Object> resultOf​(String methodName)
        Provides extractor for extracting values by method name from any object using reflection
        Type Parameters:
        F - type to extract property from
        Parameters:
        methodName - the name of the method to execute
        Returns:
        the built Function
      • extractedDescriptionOf

        public static String extractedDescriptionOf​(String... itemsDescription)
      • extractedDescriptionOf

        public static String extractedDescriptionOf​(Object... items)
      • extractedDescriptionOfMethod

        public static String extractedDescriptionOfMethod​(String method)