@Test public void testLoadEmptyConfigFromUrlGivesDefaultConfig() { Path path = Paths.get("src/test/resources/empty.yaml"); EcLogYamlConfig config = EcLogYamlConfigLoader.loadConfigFromUrl(path); assertDefaultConfig(config); }
static EcLogYamlConfig loadConfigFromUrl(Path filePath) { Constructor constructor = new Constructor(EcLogYamlConfig.class); Yaml yaml = new Yaml(constructor); try { String fileAsString = new String(Files.readAllBytes(filePath)); EcLogYamlConfig auditYamlConfig = (EcLogYamlConfig) yaml.load(fileAsString); return auditYamlConfig == null ? new EcLogYamlConfig() : auditYamlConfig; } catch (YAMLException | IOException e) { throw new IllegalArgumentException("Invalid configuration file: " + filePath, e); } }
EcLogYamlConfigLoader { static EcLogYamlConfig loadConfigFromUrl(Path filePath) { Constructor constructor = new Constructor(EcLogYamlConfig.class); Yaml yaml = new Yaml(constructor); try { String fileAsString = new String(Files.readAllBytes(filePath)); EcLogYamlConfig auditYamlConfig = (EcLogYamlConfig) yaml.load(fileAsString); return auditYamlConfig == null ? new EcLogYamlConfig() : auditYamlConfig; } catch (YAMLException | IOException e) { throw new IllegalArgumentException("Invalid configuration file: " + filePath, e); } } }
EcLogYamlConfigLoader { static EcLogYamlConfig loadConfigFromUrl(Path filePath) { Constructor constructor = new Constructor(EcLogYamlConfig.class); Yaml yaml = new Yaml(constructor); try { String fileAsString = new String(Files.readAllBytes(filePath)); EcLogYamlConfig auditYamlConfig = (EcLogYamlConfig) yaml.load(fileAsString); return auditYamlConfig == null ? new EcLogYamlConfig() : auditYamlConfig; } catch (YAMLException | IOException e) { throw new IllegalArgumentException("Invalid configuration file: " + filePath, e); } } private  EcLogYamlConfigLoader(); }
EcLogYamlConfigLoader { static EcLogYamlConfig loadConfigFromUrl(Path filePath) { Constructor constructor = new Constructor(EcLogYamlConfig.class); Yaml yaml = new Yaml(constructor); try { String fileAsString = new String(Files.readAllBytes(filePath)); EcLogYamlConfig auditYamlConfig = (EcLogYamlConfig) yaml.load(fileAsString); return auditYamlConfig == null ? new EcLogYamlConfig() : auditYamlConfig; } catch (YAMLException | IOException e) { throw new IllegalArgumentException("Invalid configuration file: " + filePath, e); } } private  EcLogYamlConfigLoader(); static EcLogYamlConfig load(ToolOptions options); }
EcLogYamlConfigLoader { static EcLogYamlConfig loadConfigFromUrl(Path filePath) { Constructor constructor = new Constructor(EcLogYamlConfig.class); Yaml yaml = new Yaml(constructor); try { String fileAsString = new String(Files.readAllBytes(filePath)); EcLogYamlConfig auditYamlConfig = (EcLogYamlConfig) yaml.load(fileAsString); return auditYamlConfig == null ? new EcLogYamlConfig() : auditYamlConfig; } catch (YAMLException | IOException e) { throw new IllegalArgumentException("Invalid configuration file: " + filePath, e); } } private  EcLogYamlConfigLoader(); static EcLogYamlConfig load(ToolOptions options);  }