Class Extractors


  • public class Extractors
    extends java.lang.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");
    • Constructor Summary

      Constructors 
      Constructor Description
      Extractors()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.function.Function<java.lang.Object,​java.lang.Object> byName​(java.lang.String fieldOrProperty)
      Provides extractor for extracting single field or property from any object using reflection
      static java.util.function.Function<java.lang.Object,​Tuple> byName​(java.lang.String... fieldsOrProperties)
      Provides extractor for extracting multiple fields or properties from any object using reflection
      static java.lang.String extractedDescriptionOf​(java.lang.Object... items)  
      static java.lang.String extractedDescriptionOf​(java.lang.String... itemsDescription)  
      static java.lang.String extractedDescriptionOfMethod​(java.lang.String method)  
      static java.util.function.Function<java.lang.Object,​java.lang.Object> resultOf​(java.lang.String methodName)
      Provides extractor for extracting values by method name from any object using reflection
      static java.util.function.Function<java.lang.Object,​java.lang.String> toStringMethod()
      Provides extractor for extracting Object.toString() from any object
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Extractors

        public Extractors()
    • Method Detail

      • toStringMethod

        public static java.util.function.Function<java.lang.Object,​java.lang.String> toStringMethod()
        Provides extractor for extracting Object.toString() from any object
        Returns:
        the built Function
      • byName

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

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

        public static java.util.function.Function<java.lang.Object,​java.lang.Object> resultOf​(java.lang.String methodName)
        Provides extractor for extracting values by method name from any object using reflection
        Parameters:
        methodName - the name of the method to execute
        Returns:
        the built Function
      • extractedDescriptionOf

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

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

        public static java.lang.String extractedDescriptionOfMethod​(java.lang.String method)