@Test public void configurationLoadingFailsIfStyxHomeIsNotSpecified() { Exception e = assertThrows(IllegalArgumentException.class, () -> StartupConfig.load()); assertEquals("No system property STYX_HOME has been defined.", e.getMessage()); }
public static StartupConfig load() { String styxHome = System.getProperty(STYX_HOME_VAR_NAME); checkArgument(styxHome != null, "No system property %s has been defined.", STYX_HOME_VAR_NAME); checkArgument(isReadable(Paths.get(styxHome)), "%s=%s is not a readable configuration path.", STYX_HOME_VAR_NAME, styxHome); String configFileLocation = System.getProperty(CONFIG_FILE_LOCATION_VAR_NAME); if (configFileLocation == null) { configFileLocation = Paths.get(styxHome).resolve("conf/default.yml").toString(); } String logbackConfigLocation = System.getProperty(LOGBACK_CONFIG_LOCATION_VAR_NAME); if (logbackConfigLocation == null) { logbackConfigLocation = Paths.get(styxHome).resolve("conf/logback.xml").toString(); } return new Builder() .styxHome(styxHome) .configFileLocation(configFileLocation) .logbackConfigLocation(logbackConfigLocation) .build(); }
StartupConfig { public static StartupConfig load() { String styxHome = System.getProperty(STYX_HOME_VAR_NAME); checkArgument(styxHome != null, "No system property %s has been defined.", STYX_HOME_VAR_NAME); checkArgument(isReadable(Paths.get(styxHome)), "%s=%s is not a readable configuration path.", STYX_HOME_VAR_NAME, styxHome); String configFileLocation = System.getProperty(CONFIG_FILE_LOCATION_VAR_NAME); if (configFileLocation == null) { configFileLocation = Paths.get(styxHome).resolve("conf/default.yml").toString(); } String logbackConfigLocation = System.getProperty(LOGBACK_CONFIG_LOCATION_VAR_NAME); if (logbackConfigLocation == null) { logbackConfigLocation = Paths.get(styxHome).resolve("conf/logback.xml").toString(); } return new Builder() .styxHome(styxHome) .configFileLocation(configFileLocation) .logbackConfigLocation(logbackConfigLocation) .build(); } }
StartupConfig { public static StartupConfig load() { String styxHome = System.getProperty(STYX_HOME_VAR_NAME); checkArgument(styxHome != null, "No system property %s has been defined.", STYX_HOME_VAR_NAME); checkArgument(isReadable(Paths.get(styxHome)), "%s=%s is not a readable configuration path.", STYX_HOME_VAR_NAME, styxHome); String configFileLocation = System.getProperty(CONFIG_FILE_LOCATION_VAR_NAME); if (configFileLocation == null) { configFileLocation = Paths.get(styxHome).resolve("conf/default.yml").toString(); } String logbackConfigLocation = System.getProperty(LOGBACK_CONFIG_LOCATION_VAR_NAME); if (logbackConfigLocation == null) { logbackConfigLocation = Paths.get(styxHome).resolve("conf/logback.xml").toString(); } return new Builder() .styxHome(styxHome) .configFileLocation(configFileLocation) .logbackConfigLocation(logbackConfigLocation) .build(); } private  StartupConfig(Builder builder); }
StartupConfig { public static StartupConfig load() { String styxHome = System.getProperty(STYX_HOME_VAR_NAME); checkArgument(styxHome != null, "No system property %s has been defined.", STYX_HOME_VAR_NAME); checkArgument(isReadable(Paths.get(styxHome)), "%s=%s is not a readable configuration path.", STYX_HOME_VAR_NAME, styxHome); String configFileLocation = System.getProperty(CONFIG_FILE_LOCATION_VAR_NAME); if (configFileLocation == null) { configFileLocation = Paths.get(styxHome).resolve("conf/default.yml").toString(); } String logbackConfigLocation = System.getProperty(LOGBACK_CONFIG_LOCATION_VAR_NAME); if (logbackConfigLocation == null) { logbackConfigLocation = Paths.get(styxHome).resolve("conf/logback.xml").toString(); } return new Builder() .styxHome(styxHome) .configFileLocation(configFileLocation) .logbackConfigLocation(logbackConfigLocation) .build(); } private  StartupConfig(Builder builder); static StartupConfig load(); static Builder newStartupConfigBuilder(); Path styxHome(); Resource logConfigLocation(); Resource configFileLocation(); @Override String toString(); }
StartupConfig { public static StartupConfig load() { String styxHome = System.getProperty(STYX_HOME_VAR_NAME); checkArgument(styxHome != null, "No system property %s has been defined.", STYX_HOME_VAR_NAME); checkArgument(isReadable(Paths.get(styxHome)), "%s=%s is not a readable configuration path.", STYX_HOME_VAR_NAME, styxHome); String configFileLocation = System.getProperty(CONFIG_FILE_LOCATION_VAR_NAME); if (configFileLocation == null) { configFileLocation = Paths.get(styxHome).resolve("conf/default.yml").toString(); } String logbackConfigLocation = System.getProperty(LOGBACK_CONFIG_LOCATION_VAR_NAME); if (logbackConfigLocation == null) { logbackConfigLocation = Paths.get(styxHome).resolve("conf/logback.xml").toString(); } return new Builder() .styxHome(styxHome) .configFileLocation(configFileLocation) .logbackConfigLocation(logbackConfigLocation) .build(); } private  StartupConfig(Builder builder); static StartupConfig load(); static Builder newStartupConfigBuilder(); Path styxHome(); Resource logConfigLocation(); Resource configFileLocation(); @Override String toString();  }