Class ReflectionUtils

java.lang.Object
org.antublue.test.engine.internal.ReflectionUtils

public final class ReflectionUtils extends Object
Class to implement methods to get test class fields / methods, caching the results
  • Method Details

    • findAllClasses

      public static List<Class<?>> findAllClasses(URI uri)
      Method to find all classes for a URI
      Parameters:
      uri - uri
      Returns:
      the return value
    • findAllClasses

      public static List<Class<?>> findAllClasses(String packageName)
      Method to find all classes with a package name
      Parameters:
      packageName - packageName
      Returns:
      the return value
    • acceptsArgument

      public static boolean acceptsArgument(Method method, Argument argument)
      Method to return if a Method accepts an Argument
      Parameters:
      method - method
      argument - argument
      Returns:
      the return value
    • getArgumentSupplierMethod

      public static Method getArgumentSupplierMethod(Class<?> clazz)
      Method to get a @TestEngine.ArgumentSupplier Method
      Parameters:
      clazz - class to inspect
      Returns:
      Method the return value
    • getArgumentsList

      public static List<Argument> getArgumentsList(Class<?> clazz)
      Method to get a List of Arguments for a Class
      Parameters:
      clazz - class to inspect
      Returns:
      list of Arguments
    • getPrepareMethods

      public static List<Method> getPrepareMethods(Class<?> clazz)
      Method to get a List of @TestEngine.Prepare Methods
      Parameters:
      clazz - class to inspect
      Returns:
      list of Methods
    • getArgumentField

      public static Optional<Field> getArgumentField(Class<?> clazz)
      Method to get @TestEngine.Argument Field
      Parameters:
      clazz - class to inspect
      Returns:
      Optional that contains an @TestEngine.Argument annotated Field if it exists or is empty
    • getAutoCloseFields

      public static List<Field> getAutoCloseFields(Class<?> clazz)
      Method to get a List of @TestEngine.AutoClose Fields
      Parameters:
      clazz - class to inspect
      Returns:
      List of Fields
    • getBeforeAllMethods

      public static List<Method> getBeforeAllMethods(Class<?> clazz)
      Method to get a List of @TestEngine.BeforeAll Methods
      Parameters:
      clazz - class to inspect
      Returns:
      list of Methods
    • getBeforeEachMethods

      public static List<Method> getBeforeEachMethods(Class<?> clazz)
      Method to get a List of @TestEngine.BeforeEach Methods
      Parameters:
      clazz - class to inspect
      Returns:
      list of Methods
    • getTestMethods

      public static List<Method> getTestMethods(Class<?> clazz)
      Method to get a List of @TestEngine.Test Methods
      Parameters:
      clazz - class to inspect
      Returns:
      list of Methods
    • getAfterEachMethods

      public static List<Method> getAfterEachMethods(Class<?> clazz)
      Method to get a List of @TestEngine.AfterEach Methods
      Parameters:
      clazz - class to inspect
      Returns:
      list of Methods
    • getAfterAllMethods

      public static List<Method> getAfterAllMethods(Class<?> clazz)
      Method to get a List of @TestEngine.AfterAll Methods
      Parameters:
      clazz - class to inspect
      Returns:
      list of Methods
    • getConcludeMethods

      public static List<Method> getConcludeMethods(Class<?> clazz)
      Method to get a @TestEngine.Conclude Methods
      Parameters:
      clazz - class to inspect
      Returns:
      Method the return value
    • getDisplayName

      public static String getDisplayName(Method method)
      Method to get a test method display name
      Parameters:
      method - method to get the display name for
      Returns:
      the display name
    • getDisplayName

      public static String getDisplayName(Class<?> clazz)
      Method to get a test method display name
      Parameters:
      clazz - class to get the display name for
      Returns:
      the display name
    • instantiate

      public static void instantiate(Class<?> clazz, Consumer<Object> objectConsumer, Consumer<Throwable> throwableConsumer)
      Method to instantiate an Object
      Parameters:
      clazz - clazz
      objectConsumer - objectConsumer
      throwableConsumer - throwableConsumer
    • setField

      public static void setField(Object object, Field field, Object value, Consumer<Throwable> throwableConsumer)
      Method to set a Field
      Parameters:
      object - object
      field - field
      value - value
      throwableConsumer - throwableConsumer
    • invoke

      public static void invoke(Object object, Method method, Consumer<Throwable> throwableConsumer)
      Method to invoke a method
      Parameters:
      object - object
      method - method
      throwableConsumer - throwableConsumer
    • invoke

      public static void invoke(Object object, Method method, Object[] arguments, Consumer<Throwable> throwableConsumer)
      Method to invoke a method
      Parameters:
      object - object
      method - method
      arguments - arguments
      throwableConsumer - throwableConsumer
    • sortClasses

      public static void sortClasses(List<Class<?>> classes)
      Method to sort a List of classes first by @TestEngine.Order annotation, then by display name / class name
      Parameters:
      classes - list of Classes to sort
    • sortMethods

      public static void sortMethods(List<Method> methods)
      Method to sort a List of methods first by @TestEngine.Order annotation, then alphabetically
      Parameters:
      methods - list of Methods to sort