Class TestEnvironmentVariables

java.lang.Object
io.skodjob.testframe.environment.TestEnvironmentVariables

public class TestEnvironmentVariables extends Object
Class representing environment variables used in the test suite
  • Constructor Details

    • TestEnvironmentVariables

      public TestEnvironmentVariables()
      TestEnvironmentVariables object initialization, where the config file is loaded to yamlData if possible.
    • TestEnvironmentVariables

      public TestEnvironmentVariables(Map<String,String> envMap)
      TestEnvironmentVariables object initialization, where the config file is loaded to yamlData if possible.
      Parameters:
      envMap - Map containing the environment variables. Used mainly for testing purposes.
  • Method Details

    • getOrDefault

      public String getOrDefault(String envVarName, String defaultValue)
      Method which returns the value from env variable or its default in String.
      Parameters:
      envVarName - environment variable name
      defaultValue - default value, which should be used if the env var is empty and the config file doesn't contain it
      Returns:
      value from env var/config file or default
    • getOrDefault

      public <T> T getOrDefault(String envVarName, Function<String,T> converter, T defaultValue)
      Method which returns the value from env variable or its default in the specified type. It also checks if the env var is specified in the configuration file before applying the default.
      Type Parameters:
      T - desired type
      Parameters:
      envVarName - environment variable name
      converter - converter to the desired type
      defaultValue - default value, which should be used if the env var is empty and the config file doesn't contain it
      Returns:
      value from env var/config file or default
    • saveConfigurationFile

      public void saveConfigurationFile(String testLogDir) throws IOException
      Saves all set environment variables into yaml file
      Parameters:
      testLogDir - dir where to store file with set env vars
      Throws:
      IOException - ioException
    • logEnvironmentVariables

      public void logEnvironmentVariables()
      Method which logs environment variables parsed by TestEnvironmentVariables