Package play.test

Class Fixtures


  • public class Fixtures
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Map<java.lang.String,​java.lang.Object> idCache  
      static java.lang.String PROFILE_NAME
      Name of the profile use when loading fixture Allow to define the behavior when loading fixtures
    • Constructor Summary

      Constructors 
      Constructor Description
      Fixtures()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void delete​(java.lang.Class<? extends Model>... types)
      Delete all Model instances for the given types using the underlying persistence mechanisms
      static void delete​(java.util.List<java.lang.Class<? extends Model>> classes)
      Delete all Model instances for the given types using the underlying persistence mechanisms
      static void deleteAll()
      Deprecated.
      use deleteDatabase() instead
      static void deleteAllModels()
      Delete all Model instances for the all available types using the underlying persistence mechanisms
      static void deleteDatabase()
      Flush the entire JDBC database
      static void deleteDirectory​(java.lang.String path)
      Delete a directory recursively
      static void executeSQL​(java.io.File sqlScript)  
      static void executeSQL​(java.lang.String sqlScript)  
      static void load​(java.lang.String name)
      Deprecated.
      static void load​(java.lang.String... names)
      Deprecated.
      static void load​(java.util.List<java.lang.String> names)
      Deprecated.
      static void loadModels​(boolean loadAsTemplate, java.lang.String name)
      Load Model instances from a YAML file and persist them using the underlying persistence mechanism.
      static void loadModels​(boolean loadAsTemplate, java.lang.String... names)
      Load Model instances from multiple YAML files (compile first as a template) and persist them using the underlying persistence mechanism.
      static void loadModels​(boolean loadAsTemplate, java.util.List<java.lang.String> names)
      Load Model instances from multiple YAML files (compile first as a template) and persist them using the underlying persistence mechanism.
      static void loadModels​(java.lang.String name)
      Load Model instances from a YAML file and persist them using the underlying persistence mechanism.
      static void loadModels​(java.lang.String... names)
      Load Model instances from multiple YAML files and persist them using the underlying persistence mechanism.
      static void loadModels​(java.util.List<java.lang.String> names)
      Load Model instances from multiple YAML files (compile first as a template) and persist them using the underlying persistence mechanism.
      static java.lang.Object loadYaml​(java.lang.String name)
      Load and parse a plain YAML file and returns the corresponding Java objects.
      static <T> T loadYaml​(java.lang.String name, java.lang.Class<T> clazz)
      Load and parse a plain YAML file and returns the corresponding Java Map.
      static <T> T loadYaml​(java.lang.String name, org.yaml.snakeyaml.Yaml yaml)  
      static java.util.List<?> loadYamlAsList​(java.lang.String name)
      Load and parse a plain YAML file and returns the corresponding Java List.
      static java.util.Map<?,​?> loadYamlAsMap​(java.lang.String name)
      Load and parse a plain YAML file and returns the corresponding Java Map.
      • Methods inherited from class java.lang.Object

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

      • PROFILE_NAME

        public static final java.lang.String PROFILE_NAME
        Name of the profile use when loading fixture Allow to define the behavior when loading fixtures
        See Also:
        Constant Field Values
      • idCache

        public static java.util.Map<java.lang.String,​java.lang.Object> idCache
    • Constructor Detail

      • Fixtures

        public Fixtures()
    • Method Detail

      • executeSQL

        public static void executeSQL​(java.lang.String sqlScript)
      • executeSQL

        public static void executeSQL​(java.io.File sqlScript)
      • delete

        public static void delete​(java.lang.Class<? extends Model>... types)
        Delete all Model instances for the given types using the underlying persistence mechanisms
        Parameters:
        types - Types to delete
      • delete

        public static void delete​(java.util.List<java.lang.Class<? extends Model>> classes)
        Delete all Model instances for the given types using the underlying persistence mechanisms
        Parameters:
        classes - Types to delete
      • deleteAllModels

        public static void deleteAllModels()
        Delete all Model instances for the all available types using the underlying persistence mechanisms
      • deleteAll

        @Deprecated
        public static void deleteAll()
        Deprecated.
        use deleteDatabase() instead
        Use deleteDatabase() instead
      • deleteDatabase

        public static void deleteDatabase()
        Flush the entire JDBC database
      • load

        @Deprecated
        public static void load​(java.lang.String name)
        Deprecated.
        Load Model instances from a YAML file and persist them using the underlying persistence mechanism. The format of the YAML file is constrained, see the Fixtures manual page
        Parameters:
        name - Name of a YAML file somewhere in the classpath (or conf/)
      • loadModels

        public static void loadModels​(java.lang.String name)
        Load Model instances from a YAML file and persist them using the underlying persistence mechanism. The format of the YAML file is constrained, see the Fixtures manual page
        Parameters:
        name - Name of a YAML file somewhere in the classpath (or conf/)
      • loadModels

        public static void loadModels​(boolean loadAsTemplate,
                                      java.lang.String name)
        Load Model instances from a YAML file and persist them using the underlying persistence mechanism. The format of the YAML file is constrained, see the Fixtures manual page
        Parameters:
        name - Name of a YAML file somewhere in the classpath (or conf/)
        loadAsTemplate - indicate if the file must interpreted as a Template
      • load

        @Deprecated
        public static void load​(java.lang.String... names)
        Deprecated.
        Load Model instances from multiple YAML files and persist them using the underlying persistence mechanism. The format of the YAML file is constrained, see the Fixtures manual page
        Parameters:
        names - Name of a YAML files somewhere in the classpath (or conf/)
      • loadModels

        public static void loadModels​(java.lang.String... names)
        Load Model instances from multiple YAML files and persist them using the underlying persistence mechanism. The format of the YAML file is constrained, see the Fixtures manual page
        Parameters:
        names - Name of a YAML files somewhere in the classpath (or conf/)
        See Also:
        loadModels(String name)
      • loadModels

        public static void loadModels​(boolean loadAsTemplate,
                                      java.lang.String... names)
        Load Model instances from multiple YAML files (compile first as a template) and persist them using the underlying persistence mechanism. The format of the YAML file is constrained, see the Fixtures manual page
        Parameters:
        loadAsTemplate - Indicate if the YAML file should be compile first as a template
        names - Name of a YAML files somewhere in the classpath (or conf/)
        See Also:
        loadModels(boolean loadAsTemplate, String name)
      • load

        @Deprecated
        public static void load​(java.util.List<java.lang.String> names)
        Deprecated.
        /** Load Model instances from multiple YAML files (compile first as a template) and persist them using the underlying persistence mechanism. The format of the YAML file is constrained, see the Fixtures manual page
        Parameters:
        names - Name of a YAML files somewhere in the classpath (or conf/)
      • loadModels

        public static void loadModels​(java.util.List<java.lang.String> names)
        Load Model instances from multiple YAML files (compile first as a template) and persist them using the underlying persistence mechanism. The format of the YAML file is constrained, see the Fixtures manual page
        Parameters:
        names - Name of a YAML files somewhere in the classpath (or conf/)
        See Also:
        loadModels(String name)
      • loadModels

        public static void loadModels​(boolean loadAsTemplate,
                                      java.util.List<java.lang.String> names)
        Load Model instances from multiple YAML files (compile first as a template) and persist them using the underlying persistence mechanism. The format of the YAML file is constrained, see the Fixtures manual page
        Parameters:
        loadAsTemplate - Indicate if the YAML file should be compile first as a template
        names - Name of a YAML files somewhere in the classpath (or conf/)
        See Also:
        loadModels(boolean, String...)
      • loadYaml

        public static java.lang.Object loadYaml​(java.lang.String name)
        Load and parse a plain YAML file and returns the corresponding Java objects. The YAML parser used is SnakeYAML (http://code.google.com/p/snakeyaml/)
        Parameters:
        name - Name of a YAML file somewhere in the classpath (or conf/)me
        Returns:
        Java objects
      • loadYamlAsList

        public static java.util.List<?> loadYamlAsList​(java.lang.String name)
        Load and parse a plain YAML file and returns the corresponding Java List. The YAML parser used is SnakeYAML (http://code.google.com/p/snakeyaml/)
        Parameters:
        name - Name of a YAML file somewhere in the classpath (or conf/)me
        Returns:
        Java List representing the YAML data
      • loadYamlAsMap

        public static java.util.Map<?,​?> loadYamlAsMap​(java.lang.String name)
        Load and parse a plain YAML file and returns the corresponding Java Map. The YAML parser used is SnakeYAML (http://code.google.com/p/snakeyaml/)
        Parameters:
        name - Name of a YAML file somewhere in the classpath (or conf/)me
        Returns:
        Java Map representing the YAML data
      • loadYaml

        public static <T> T loadYaml​(java.lang.String name,
                                     java.lang.Class<T> clazz)
        Load and parse a plain YAML file and returns the corresponding Java Map. The YAML parser used is SnakeYAML (http://code.google.com/p/snakeyaml/)
        Type Parameters:
        T - The entity load
        Parameters:
        name - Name of a YAML file somewhere in the classpath (or conf/)me
        clazz - the expected class
        Returns:
        Object representing the YAML data
      • loadYaml

        public static <T> T loadYaml​(java.lang.String name,
                                     org.yaml.snakeyaml.Yaml yaml)
      • deleteDirectory

        public static void deleteDirectory​(java.lang.String path)
        Delete a directory recursively
        Parameters:
        path - relative path of the directory to delete