Skip to content
Snippets Groups Projects
Commit df7c4d11 authored by Martin Vogel's avatar Martin Vogel
Browse files

refactor(config): add config loading via string path

parent 70559a04
No related branches found
No related tags found
No related merge requests found
......@@ -30,13 +30,25 @@ public final class ApplicationConfigLoader {
}
/**
* Load ApplicationConfig from string.
* Load ApplicationConfig from path string.
*
* @param configPath string of path to config file
*
* @return ApplicationConfig
* @throws InitializationException if the config file could not be loaded
*/
public static ApplicationConfig loadConfig(final String configPath) {
return loadConfig(Path.of(configPath));
}
/**
* Load ApplicationConfig from yaml string.
*
* @param configYaml string content of the yaml config file
*
* @return ApplicationConfig
*/
public static ApplicationConfig loadConfig(final String configYaml) {
public static ApplicationConfig loadConfigFromYaml(final String configYaml) {
final Constructor constructor = new Constructor(ApplicationConfig.class);
final Yaml yaml = new Yaml(constructor);
return yaml.load(configYaml);
......
......@@ -25,7 +25,7 @@ class ApplicationConfigLoaderTest {
@Test
void testLoadMissingConfigFile() {
Assertions.assertThrows(InitializationException.class, () -> ApplicationConfigLoader.loadConfig(Path.of("/no/path")));
Assertions.assertThrows(InitializationException.class, () -> ApplicationConfigLoader.loadConfig("/no/path"));
}
@Test
......@@ -57,7 +57,7 @@ class ApplicationConfigLoaderTest {
final SenderConfig senderConfig = new SenderConfig("1", "123");
// When
final ApplicationConfig testConfig = ApplicationConfigLoader.loadConfig(testConfigYaml);
final ApplicationConfig testConfig = ApplicationConfigLoader.loadConfigFromYaml(testConfigYaml);
// Then
assertNotNull(testConfig);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment