ProxyConfigurationLoader { public static YamlProxyConfiguration load(final String path) throws IOException { Collection<String> schemaNames = new HashSet<>(); YamlProxyServerConfiguration serverConfig = loadServerConfiguration(getResourceFile(path + "/" + SERVER_CONFIG_FILE)); File configPath = getResourceFile(path); Collection<YamlProxyRuleConfiguration> ruleConfigurations = loadRuleConfigurations(schemaNames, configPath); Preconditions.checkState(!ruleConfigurations.isEmpty() || null != serverConfig.getGovernance(), "Can not find any rule configurations file in path `%s`.", configPath.getPath()); return new YamlProxyConfiguration(serverConfig, ruleConfigurations.stream().collect(Collectors.toMap(YamlProxyRuleConfiguration::getSchemaName, each -> each))); }  static YamlProxyConfiguration load(final String path);  }
@Test public void assertLoad() throws IOException { YamlProxyConfiguration actual = ProxyConfigurationLoader.load("/conf/"); assertThat(actual.getServerConfiguration().getGovernance().getRegistryCenter().getServerLists(), is("localhost:2181")); assertThat(actual.getRuleConfigurations().size(), is(3)); assertShardingRuleConfiguration(actual.getRuleConfigurations().get("sharding_db")); assertPrimaryReplicaReplicationRuleConfiguration(actual.getRuleConfigurations().get("primary_replica_db")); assertEncryptRuleConfiguration(actual.getRuleConfigurations().get("encrypt_db")); }