Class TestConfig


  • public class TestConfig
    extends Object
    This class is responsible for extracting the attributes from the test config file (test-config.json), and provides simple extractors for the attributes within.
    • Constructor Detail

      • TestConfig

        public TestConfig()
        The constructor loads the test configuration attributes from a file into a config Map.
    • Method Detail

      • getItem

        public Optional<Object> getItem​(String attribute)
        Gets a single item from the config file.
        Parameters:
        attribute - The name of the item being extracted from the config file.
        Returns:
        Optional Object, or empty Optional if the retrieval of the attribute results in a null value.
      • getStringItem

        public Optional<String> getStringItem​(String attribute)
                                       throws RuntimeException
        Gets a String item from the config file.
        Parameters:
        attribute - The name of the item being extracted from the config file.
        Returns:
        An Optional String, or empty Optional if the attribute is either an empty String or not a String.
        Throws:
        RuntimeException - The attribute does not exist in the config file.
      • getMap

        public Optional<Map<String,​Object>> getMap​(String attribute)
                                                  throws RuntimeException
        Gets a map item from the config file.
        Parameters:
        attribute - The name of the item being extracted from the config file.
        Returns:
        Optional Map(String, Object) that can be further parsed, or an empty Optional if the map is empty or not a Map.
        Throws:
        RuntimeException - The attribute does not exist in the config file.
      • getStringMap

        public Optional<Map<String,​String>> getStringMap​(String attribute)
                                                        throws RuntimeException
        Gets a string map item from the config file.
        Parameters:
        attribute - The name of the item being extracted from the config file.
        Returns:
        Optional Map(String, String), or an empty Optional if the map is empty or not a Map.
        Throws:
        RuntimeException - The attribute does not exist in the config file.