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).
  • Field Details

  • Method Details

    • startMagicDrawUML

      public static void startMagicDrawUML()
      Starts MagicDraw in a test mode if it is not started yet.
    • startMagicDrawUML

      public static void startMagicDrawUML(List<String> arguments)
      Starts MagicDraw in a test mode if it is not started yet.
    • parseArguments

      public static void parseArguments(String[] args)
    • 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.
    • getResourceFile

      public static File getResourceFile(String relativePath)
      Resource file.
      Parameters:
      relativePath - path relative to the resource directory (getResourceDir())
    • 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.
    • getRelativeOutputFile

      public static File getRelativeOutputFile(Class clazz, File resourceFile, boolean createDir)
    • getRelativeOutputFile

      public static File getRelativeOutputFile(Class clazz, String resourceFilePath, boolean createDir)
    • 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.
    • extractFileName

      public static String extractFileName(String filePath)
    • getOutputDir

      public static File getOutputDir(String name)
      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:
      name - directory name.
      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.
    • isIgnoredFile

      public static boolean isIgnoredFile(File file)
      Check if given file should be skipped as some test case data.
      Parameters:
      file - file
      Returns:
      true if file should be skipped
    • 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.
    • ensureFrameVisible

      public static void ensureFrameVisible()
      Ensures that main frame is visible
    • 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}
    • getArtifactDir

      public static File getArtifactDir()
      Get artifacts directory.
      Returns:
      artifacts dir.
    • getArtifactsDirectory

      @CheckForNull public static File getArtifactsDirectory(String directory)
      Creates and returns artifacts directory
      Parameters:
      directory - directory
      Returns:
      created directory
    • concatPath

      public static String concatPath(String... path)
      Method returns whole path to given project. eg. getProjectPath("menu", "browser", "transform.mdzip") -> path_to_MD\core_resources\menu\browser\transform.mdzip
      Parameters:
      path - path
      Returns:
      Generated project path
    • createFileInArtifactsDir

      public static File createFileInArtifactsDir(String artifactsDirectory, String fileName)
    • arrayToString

      public static String arrayToString(String[] strings, String separator)
      Concat given string array to one string
      Parameters:
      strings - array e.g. {"s1","s2","s3"}
      separator - e.g. "/"
      Returns:
      "s1/s2/s3/"