Class TestEnvironment

java.lang.Object
com.nomagic.magicdraw.tests.common.TestEnvironment

@OpenApi public class TestEnvironment extends Object
The class which is used for initializing the MagicDraw test environment(starting the MagicDraw and specifying the necessary variables).
  • Method Details

    • getResourceDir

      @OpenApi public static File getResourceDir()
      Returns test framework resources directory specified by "tests.resources" system property. Resources directory is a central place for all resources required by test cases.
      Returns:
      File representing test framework resources directory.
    • getRelativeOutputFile

      @OpenApi public static File getRelativeOutputFile(Class clazz, File resourceFile)
      Creates output file relative to given resource file in specific test case output directory.
      Parameters:
      clazz - test case class to create related output file for.
      resourceFile - resource file to create related output file for.
      Returns:
      output file in given test case output directory with name related to given resource file.
    • getOutputDir

      @OpenApi public static File getOutputDir(Class clazz)
      Get default directory for specific test case output. Output directory is created if it does not exist. Output directory is located in parent directory if specified by "tests.output" system property or MagicDraw install root otherwise.
      Parameters:
      clazz - Test case class to get output directory for.
      Returns:
      File representing output directory for test case.
    • getProjects

      @OpenApi public static List<File> getProjects(File rootDirectory)
      Collects MagicDraw project files from specific directory and from its inner directories recursively.
      Parameters:
      rootDirectory - Root directory to collect project files recursively from.
      Returns:
      List of MagicDraw projects Files.
    • createFileNameWithPrefix

      @OpenApi public static File createFileNameWithPrefix(File file, String prefix)
      Insert specific prefix after file name before file extension. For instance my_projectPREFIX.mdzip.
      Parameters:
      file - file to insert prefix to.
      prefix - prefix to insert.
      Returns:
      File representing new file there name has prefix inserted.
    • getFileWithExtension

      @OpenApi public static File getFileWithExtension(File file, String extension)
      Replace MagicDraw project file extension by the given one.
      Parameters:
      file - File to replace extension.
      extension - new extension.
      Returns:
      new File with replaced given extension.
    • getFiles

      @OpenApi public static List<File> getFiles(File rootDirectory, FilenameFilter filter, @CheckForNull Collection<String> skipNames)
      Collects files from root directory and inner directories recursively except those specified to skip. Files needed to skip might be also listed in skip.txt file located in root or nested directories.
      Parameters:
      rootDirectory - Root directory to collect project files recursively from.
      filter - only files matching this filter will be returned
      skipNames - the Collection of project file names to skip. Project file is skipped if it name contains any name defined in skipNames collection or skip.txt file.
      Returns:
      The list of MagicDraw project files collected.
    • getProjects

      @OpenApi public static List<File> getProjects(File rootDirectory, @CheckForNull Collection<String> skipNames)
      Collects MagicDraw projects files from root directory and inner directories recursively except those specified to skip. Projects needed to skip might be also listed in skip.txt file located in root or nested directories.
      Parameters:
      rootDirectory - Root directory to collect project files recursively from.
      skipNames - the Collection of project file names to skip. Project file is skipped if it name contains any name defined in skipNames collection or skip.txt file.
      Returns:
      The list of MagicDraw project files collected.
    • getProjects

      @OpenApi public static List<File> getProjects(String directory)
      Collects MagicDraw projects recursively from the given directory of resource directory.
      Parameters:
      directory - directory name in the resource directory
      Returns:
      List of MagicDraw project files found in the given resource directory and its nested directories.
    • splitFileName

      @CheckForNull @OpenApi public static String[] splitFileName(String fileName)
      Splits MagicDraw project file name to file name and extension.
      Parameters:
      fileName - MagicDraw project file name to split.
      Returns:
      String[2] = {fileName, fileExtension}