Package io.skodjob.testframe.utils
Class TestFrameUtils
java.lang.Object
io.skodjob.testframe.utils.TestFrameUtils
Utility methods for TestFrame.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault timeout for asynchronous tests.static final TimeUnitDefault timeout unit for asynchronous tests. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TconfigFromYaml(File yamlFile, Class<T> c) Parses YAML configuration into an object.static <T> TconfigFromYaml(String yamlFile, Class<T> c) Parses YAML configuration into an object.static InputStreamgetFileFromResourceAsStream(String fileName) Retrieves a file from the classpath as an input stream.static <T> TrunUntilPass(int retry, Callable<T> fn) Runs a callable function until it passes or the maximum number of retries is reached.
-
Field Details
-
DEFAULT_TIMEOUT_DURATION
public static final int DEFAULT_TIMEOUT_DURATIONDefault timeout for asynchronous tests.- See Also:
-
DEFAULT_TIMEOUT_UNIT
Default timeout unit for asynchronous tests.
-
-
Method Details
-
getFileFromResourceAsStream
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
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
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
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.
-