Configuration { static void initConfiguration(String configFilePath) throws IOException { final File configFile = new File(configFilePath); if (!configFile.exists()) { throw new IllegalArgumentException("configuration file: " + configFilePath + " is not exists"); } try { final Configuration configuration = new ObjectMapper(new YAMLFactory()).readValue(configFile, Configuration.class); if (configuration != null) { instance = configuration; } } catch (JsonParseException | JsonMappingException ex) { throw new IllegalArgumentException("configuration file: " + configFilePath + " is not a legal YAML file or has invalid configurations", ex); } } Configuration(); void setMetricsPrefix(String metricsPrefix); @JsonSetter("purgeFilterIntervalMillis") void setPurgeFilterInterval(int purgeFilterIntervalMillis); void setMaxHttpConnections(int maxHttpConnections); void setMaxHttpRequestLength(int maxHttpRequestLength); void setMaxWorkerThreadPoolSize(int maxWorkerThreadPoolSize); @JsonSetter("requestTimeoutSeconds") void setRequestTimeout(int requestTimeoutSeconds); void setIdleTimeoutMillis(int idleTimeoutMillis); void setDefaultExpectedInsertions(int defaultExpectedInsertions); void setDefaultFalsePositiveProbability(double defaultFalsePositiveProbability); @JsonSetter("defaultValidSecondsAfterCreate") void setDefaultValidPeriodAfterCreate(long defaultValidSecondsAfterCreate); void setChannelBufferSizeForFilterPersistence(int channelBufferSizeForFilterPersistence); void setPersistentStorageDirectory(@Nullable String persistentStorageDirectory); void setAllowRecoverFromCorruptedPersistentFile(boolean allowRecoverFromCorruptedPersistentFile); void setChannelOptions(SupportedChannelOptions channelOptions); @JsonProperty("triggerPersistenceCriteria") void setPersistenceCriteria(@Nullable List<TriggerPersistenceCriteria> criteriaList); void setGracefulShutdownQuietPeriodMillis(long gracefulShutdownQuietPeriodMillis); void setGracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis);  }
@Test public void testConfigurationFileNotExists() { assertThatThrownBy(() -> Configuration.initConfiguration("not-exists.yaml")) .isInstanceOf(IllegalArgumentException.class) .hasMessageMatching("configuration file: .* is not exists"); }
@Test public void testConfigurationFileIllegal() { assertThatThrownBy(() -> Configuration.initConfiguration("src/test/resources/illegal-configuration.yaml")) .isInstanceOf(IllegalArgumentException.class) .hasMessageMatching("configuration file: .* is not a legal YAML file or has invalid configurations"); }