@Test public void testFormatExtractionFromPath() { String path = "config.json"; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("json"); path = "config.Json"; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("json"); path = "." + File.separator + "config.json"; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("json"); path = ".config.json"; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("json"); path = "." + File.separator + ".config" + File.separator + "config.json"; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("json"); path = "config.yaml"; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("yaml"); path = "config.yml"; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("yaml"); path = "config."; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("json"); path = ""; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("json"); path = " "; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("json"); path = " . "; assertThat(ConfigRetrieverImpl.extractFormatFromFileExtension(path)).isEqualTo("json"); }
static String extractFormatFromFileExtension(String path) { int index = path.lastIndexOf("."); if (index == -1) { return "json"; } else { String ext = path.substring(index + 1); if (ext.trim().isEmpty()) { return "json"; } if ("yml".equalsIgnoreCase(ext)) { ext = "yaml"; } return ext.toLowerCase(); } }
ConfigRetrieverImpl implements ConfigRetriever { static String extractFormatFromFileExtension(String path) { int index = path.lastIndexOf("."); if (index == -1) { return "json"; } else { String ext = path.substring(index + 1); if (ext.trim().isEmpty()) { return "json"; } if ("yml".equalsIgnoreCase(ext)) { ext = "yaml"; } return ext.toLowerCase(); } } }
ConfigRetrieverImpl implements ConfigRetriever { static String extractFormatFromFileExtension(String path) { int index = path.lastIndexOf("."); if (index == -1) { return "json"; } else { String ext = path.substring(index + 1); if (ext.trim().isEmpty()) { return "json"; } if ("yml".equalsIgnoreCase(ext)) { ext = "yaml"; } return ext.toLowerCase(); } } ConfigRetrieverImpl(Vertx vertx, ConfigRetrieverOptions options); }
ConfigRetrieverImpl implements ConfigRetriever { static String extractFormatFromFileExtension(String path) { int index = path.lastIndexOf("."); if (index == -1) { return "json"; } else { String ext = path.substring(index + 1); if (ext.trim().isEmpty()) { return "json"; } if ("yml".equalsIgnoreCase(ext)) { ext = "yaml"; } return ext.toLowerCase(); } } ConfigRetrieverImpl(Vertx vertx, ConfigRetrieverOptions options); synchronized void initializePeriodicScan(); @Override void getConfig(Handler<AsyncResult<JsonObject>> completionHandler); @Override Future<JsonObject> getConfig(); @Override synchronized void close(); @Override synchronized JsonObject getCachedConfig(); @Override synchronized void listen(Handler<ConfigChange> listener); @Override synchronized ConfigRetriever setBeforeScanHandler(Handler<Void> handler); @Override synchronized ConfigRetriever setConfigurationProcessor(Function<JsonObject, JsonObject> processor); @Override ReadStream<JsonObject> configStream(); List<ConfigurationProvider> getProviders(); }
ConfigRetrieverImpl implements ConfigRetriever { static String extractFormatFromFileExtension(String path) { int index = path.lastIndexOf("."); if (index == -1) { return "json"; } else { String ext = path.substring(index + 1); if (ext.trim().isEmpty()) { return "json"; } if ("yml".equalsIgnoreCase(ext)) { ext = "yaml"; } return ext.toLowerCase(); } } ConfigRetrieverImpl(Vertx vertx, ConfigRetrieverOptions options); synchronized void initializePeriodicScan(); @Override void getConfig(Handler<AsyncResult<JsonObject>> completionHandler); @Override Future<JsonObject> getConfig(); @Override synchronized void close(); @Override synchronized JsonObject getCachedConfig(); @Override synchronized void listen(Handler<ConfigChange> listener); @Override synchronized ConfigRetriever setBeforeScanHandler(Handler<Void> handler); @Override synchronized ConfigRetriever setConfigurationProcessor(Function<JsonObject, JsonObject> processor); @Override ReadStream<JsonObject> configStream(); List<ConfigurationProvider> getProviders();  }