Package io.skodjob.testframe.environment
Class TestEnvironmentVariables
java.lang.Object
io.skodjob.testframe.environment.TestEnvironmentVariables
Class representing environment variables used in the test suite
-
Constructor Summary
ConstructorsConstructorDescriptionTestEnvironmentVariablesobject initialization, where the config file is loaded toyamlDataif possible.TestEnvironmentVariables(Map<String, String> envMap) TestEnvironmentVariablesobject initialization, where the config file is loaded toyamlDataif possible. -
Method Summary
Modifier and TypeMethodDescriptiongetOrDefault(String envVarName, String defaultValue) Method which returns the value from env variable or its default in String.<T> TgetOrDefault(String envVarName, Function<String, T> converter, T defaultValue) Method which returns the value from env variable or its default in the specified type.voidMethod which logs environment variables parsed byTestEnvironmentVariablesvoidsaveConfigurationFile(String testLogDir) Saves all set environment variables into yaml file
-
Constructor Details
-
TestEnvironmentVariables
public TestEnvironmentVariables()TestEnvironmentVariablesobject initialization, where the config file is loaded toyamlDataif possible. -
TestEnvironmentVariables
TestEnvironmentVariablesobject initialization, where the config file is loaded toyamlDataif possible.- Parameters:
envMap- Map containing the environment variables. Used mainly for testing purposes.
-
-
Method Details
-
getOrDefault
Method which returns the value from env variable or its default in String.- Parameters:
envVarName- environment variable namedefaultValue- 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
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 nameconverter- converter to the desired typedefaultValue- 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
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 byTestEnvironmentVariables
-