Class TestFrameUtils

java.lang.Object
io.skodjob.testframe.utils.TestFrameUtils

public final class TestFrameUtils extends Object
Utility methods for TestFrame.
  • Field Details

    • DEFAULT_TIMEOUT_DURATION

      public static final int DEFAULT_TIMEOUT_DURATION
      Default timeout for asynchronous tests.
      See Also:
    • DEFAULT_TIMEOUT_UNIT

      public static final TimeUnit DEFAULT_TIMEOUT_UNIT
      Default timeout unit for asynchronous tests.
  • Method Details

    • getFileFromResourceAsStream

      public static InputStream getFileFromResourceAsStream(String fileName)
      Retrieves a file from the classpath as an input stream.
      Parameters:
      fileName - The name of the file.
      Returns:
      An input stream for the file.
      Throws:
      IllegalArgumentException - if the file is not found.
    • configFromYaml

      public static <T> T configFromYaml(String yamlFile, Class<T> c)
      Parses YAML configuration into an object.
      Type Parameters:
      T - The type of the object.
      Parameters:
      yamlFile - The YAML file content.
      c - The class of the object to parse into.
      Returns:
      The parsed object.
      Throws:
      IllegalArgumentException - if the YAML is invalid.
      RuntimeException - if an I/O error occurs.
    • configFromYaml

      public static <T> T configFromYaml(File yamlFile, Class<T> c)
      Parses YAML configuration into an object.
      Type Parameters:
      T - The type of the object.
      Parameters:
      yamlFile - The YAML file.
      c - The class of the object to parse into.
      Returns:
      The parsed object.
      Throws:
      IllegalArgumentException - if the YAML is invalid.
      RuntimeException - if an I/O error occurs.
    • runUntilPass

      public static <T> T runUntilPass(int retry, Callable<T> fn)
      Runs a callable function until it passes or the maximum number of retries is reached.
      Type Parameters:
      T - The return type of the callable.
      Parameters:
      retry - The maximum number of retries.
      fn - The callable function.
      Returns:
      The value from the first successful call to the callable.
      Throws:
      IllegalStateException - if the callable does not pass after all retries.