@Test public void testEnabledAndInvalidStatisticsPath() throws IOException, ConfigurationException { File expectedNonExistingStatisticsDirectory = myTemporaryFolder.newFolder(); expectedNonExistingStatisticsDirectory.delete(); Properties properties = new Properties(); properties.put("statistics.enabled", "true"); properties.put("statistics.directory", expectedNonExistingStatisticsDirectory.toURI().toString()); assertThatExceptionOfType(ConfigurationException.class) .isThrownBy(() -> StatisticsProperties.from(properties)); }
public static StatisticsProperties from(Properties properties) throws ConfigurationException { boolean enabled = Boolean.parseBoolean(properties.getProperty(CONFIG_STATISTICS_ENABLED, DEFAULT_STATISTICS_ENABLED)); File statisticsDirectory = new File(properties.getProperty(CONFIG_STATISTICS_DIRECTORY, DEFAULT_STATISTICS_DIRECTORY)); if (enabled && !statisticsDirectory.exists()) { throw new ConfigurationException("Statistics directory '" + statisticsDirectory + "' does not exist"); } return new StatisticsProperties(enabled, statisticsDirectory); }
StatisticsProperties { public static StatisticsProperties from(Properties properties) throws ConfigurationException { boolean enabled = Boolean.parseBoolean(properties.getProperty(CONFIG_STATISTICS_ENABLED, DEFAULT_STATISTICS_ENABLED)); File statisticsDirectory = new File(properties.getProperty(CONFIG_STATISTICS_DIRECTORY, DEFAULT_STATISTICS_DIRECTORY)); if (enabled && !statisticsDirectory.exists()) { throw new ConfigurationException("Statistics directory '" + statisticsDirectory + "' does not exist"); } return new StatisticsProperties(enabled, statisticsDirectory); } }
StatisticsProperties { public static StatisticsProperties from(Properties properties) throws ConfigurationException { boolean enabled = Boolean.parseBoolean(properties.getProperty(CONFIG_STATISTICS_ENABLED, DEFAULT_STATISTICS_ENABLED)); File statisticsDirectory = new File(properties.getProperty(CONFIG_STATISTICS_DIRECTORY, DEFAULT_STATISTICS_DIRECTORY)); if (enabled && !statisticsDirectory.exists()) { throw new ConfigurationException("Statistics directory '" + statisticsDirectory + "' does not exist"); } return new StatisticsProperties(enabled, statisticsDirectory); } private  StatisticsProperties(boolean enabled, File statisticsDirectory); }
StatisticsProperties { public static StatisticsProperties from(Properties properties) throws ConfigurationException { boolean enabled = Boolean.parseBoolean(properties.getProperty(CONFIG_STATISTICS_ENABLED, DEFAULT_STATISTICS_ENABLED)); File statisticsDirectory = new File(properties.getProperty(CONFIG_STATISTICS_DIRECTORY, DEFAULT_STATISTICS_DIRECTORY)); if (enabled && !statisticsDirectory.exists()) { throw new ConfigurationException("Statistics directory '" + statisticsDirectory + "' does not exist"); } return new StatisticsProperties(enabled, statisticsDirectory); } private  StatisticsProperties(boolean enabled, File statisticsDirectory); boolean isEnabled(); File getStatisticsDirectory(); static StatisticsProperties from(Properties properties); }
StatisticsProperties { public static StatisticsProperties from(Properties properties) throws ConfigurationException { boolean enabled = Boolean.parseBoolean(properties.getProperty(CONFIG_STATISTICS_ENABLED, DEFAULT_STATISTICS_ENABLED)); File statisticsDirectory = new File(properties.getProperty(CONFIG_STATISTICS_DIRECTORY, DEFAULT_STATISTICS_DIRECTORY)); if (enabled && !statisticsDirectory.exists()) { throw new ConfigurationException("Statistics directory '" + statisticsDirectory + "' does not exist"); } return new StatisticsProperties(enabled, statisticsDirectory); } private  StatisticsProperties(boolean enabled, File statisticsDirectory); boolean isEnabled(); File getStatisticsDirectory(); static StatisticsProperties from(Properties properties);  }