Class ModelUtils

java.lang.Object
spoon.testing.utils.ModelUtils

public final class ModelUtils extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static Factory
    build​(File... filesToBuild)
    Builds the Spoon mode of the `filesToBuild` given as parameter
    static Factory
    build​(Class<?>... classesToBuild)
    Utility method for testing: creates the model of the given `classesToBuild` from src/test/java and returns the factory
    static <T extends CtType<?>>
    T
    build​(String packageName, String className)
    Utility method for testing: creates the model of `packageName` from src/test/java and returns the CtType corresponding to `className`
    static <T extends CtType<?>>
    T
    build​(String packageName, String className, Factory f)
    Utility method for testing: creates the model of `packageName` and the factory from src/test/java and returns the CtType corresponding to `className`
    static Factory
    build​(Consumer<Launcher> config, Class<?>... classesToBuild)
    Utility method for testing: creates the model of the given `classesToBuild` from src/test/java and returns the factory and allows to configure the Launcher first using `config`
    static <T> CtType<T>
    buildClass​(Class<T> classToBuild)
     
    static <T> CtType<T>
    buildClass​(Class<T> classToBuild, boolean ensureFullclasspath)
    Builds and returns the Spoon model of `` classToBuild
    static <T> CtType<T>
    buildClass​(Consumer<Launcher> config, Class<T> classToBuild)
     
    static Factory
    buildNoClasspath​(Class<?>... classesToBuild)
    Utility method for testing: creates the noclasspath model of the given `classesToBuild` from src/test/java and returns the factory
    static void
    canBeBuilt​(File outputDirectoryFile, int complianceLevel)
    checks that the file `outputDirectoryFile` can be parsed with Spoon , given a compliance level.
    static void
    canBeBuilt​(File outputDirectoryFile, int complianceLevel, boolean noClasspath)
    checks that the file `outputDirectoryFile` can be parsed with Spoon , given a compliance level and the noclasspath option.
    static void
    canBeBuilt​(String outputDirectory, int complianceLevel)
    checks that the file at path `outputDirectory` can be parsed with Spoon , given a compliance level.
    static void
    canBeBuilt​(String outputDirectory, int complianceLevel, boolean noClasspath)
    checks that the file at path `outputDirectory` can be parsed with Spoon , given a compliance level and noclasspath option.
    static Factory
     
    static String
    Converts `obj` to String and all EOLs and TABs are removed and sequences of white spaces are replaced by single space

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • createFactory

      public static Factory createFactory()
    • build

      public static <T extends CtType<?>> T build(String packageName, String className) throws Exception
      Utility method for testing: creates the model of `packageName` from src/test/java and returns the CtType corresponding to `className`
      Throws:
      Exception
    • build

      public static <T extends CtType<?>> T build(String packageName, String className, Factory f) throws Exception
      Utility method for testing: creates the model of `packageName` and the factory from src/test/java and returns the CtType corresponding to `className`
      Throws:
      Exception
    • build

      public static Factory build(Class<?>... classesToBuild) throws Exception
      Utility method for testing: creates the model of the given `classesToBuild` from src/test/java and returns the factory
      Throws:
      Exception
    • buildNoClasspath

      public static Factory buildNoClasspath(Class<?>... classesToBuild) throws Exception
      Utility method for testing: creates the noclasspath model of the given `classesToBuild` from src/test/java and returns the factory
      Throws:
      Exception
    • build

      public static Factory build(Consumer<Launcher> config, Class<?>... classesToBuild) throws Exception
      Utility method for testing: creates the model of the given `classesToBuild` from src/test/java and returns the factory and allows to configure the Launcher first using `config`
      Throws:
      Exception
    • build

      public static Factory build(File... filesToBuild)
      Builds the Spoon mode of the `filesToBuild` given as parameter
    • buildClass

      public static <T> CtType<T> buildClass(Class<T> classToBuild) throws Exception
      Throws:
      Exception
    • buildClass

      public static <T> CtType<T> buildClass(Class<T> classToBuild, boolean ensureFullclasspath) throws Exception
      Builds and returns the Spoon model of `` classToBuild
      Throws:
      Exception
    • buildClass

      public static <T> CtType<T> buildClass(Consumer<Launcher> config, Class<T> classToBuild) throws Exception
      Throws:
      Exception
    • canBeBuilt

      public static void canBeBuilt(File outputDirectoryFile, int complianceLevel)
      checks that the file `outputDirectoryFile` can be parsed with Spoon , given a compliance level.
    • canBeBuilt

      public static void canBeBuilt(String outputDirectory, int complianceLevel)
      checks that the file at path `outputDirectory` can be parsed with Spoon , given a compliance level.
    • canBeBuilt

      public static void canBeBuilt(File outputDirectoryFile, int complianceLevel, boolean noClasspath)
      checks that the file `outputDirectoryFile` can be parsed with Spoon , given a compliance level and the noclasspath option.
    • canBeBuilt

      public static void canBeBuilt(String outputDirectory, int complianceLevel, boolean noClasspath)
      checks that the file at path `outputDirectory` can be parsed with Spoon , given a compliance level and noclasspath option.
    • getOptimizedString

      public static String getOptimizedString(Object obj)
      Converts `obj` to String and all EOLs and TABs are removed and sequences of white spaces are replaced by single space
      Parameters:
      obj - to be converted object
      Returns:
      single line string optimized for comparation