@Test public void shouldThrowSettingsNotFoundExceptionIfNoneFound() { thrown.expect(SettingsNotFoundException.class); loadSettings(null, null, null, null); }
public static SessionSettings loadSettings(String... locations) { try { for (String location : locations) { Optional<Resource> resource = load(location); if (resource.isPresent()) { log.info("Loading settings from '{}'", location); return new SessionSettings(resource.get().getInputStream()); } } throw new SettingsNotFoundException("Settings file not found"); } catch (RuntimeException | ConfigError | IOException e) { throw new SettingsNotFoundException(e.getMessage(), e); } }
SessionSettingsLocator { public static SessionSettings loadSettings(String... locations) { try { for (String location : locations) { Optional<Resource> resource = load(location); if (resource.isPresent()) { log.info("Loading settings from '{}'", location); return new SessionSettings(resource.get().getInputStream()); } } throw new SettingsNotFoundException("Settings file not found"); } catch (RuntimeException | ConfigError | IOException e) { throw new SettingsNotFoundException(e.getMessage(), e); } } }
SessionSettingsLocator { public static SessionSettings loadSettings(String... locations) { try { for (String location : locations) { Optional<Resource> resource = load(location); if (resource.isPresent()) { log.info("Loading settings from '{}'", location); return new SessionSettings(resource.get().getInputStream()); } } throw new SettingsNotFoundException("Settings file not found"); } catch (RuntimeException | ConfigError | IOException e) { throw new SettingsNotFoundException(e.getMessage(), e); } } private  SessionSettingsLocator(); }
SessionSettingsLocator { public static SessionSettings loadSettings(String... locations) { try { for (String location : locations) { Optional<Resource> resource = load(location); if (resource.isPresent()) { log.info("Loading settings from '{}'", location); return new SessionSettings(resource.get().getInputStream()); } } throw new SettingsNotFoundException("Settings file not found"); } catch (RuntimeException | ConfigError | IOException e) { throw new SettingsNotFoundException(e.getMessage(), e); } } private  SessionSettingsLocator(); static SessionSettings loadSettings(String... locations); }
SessionSettingsLocator { public static SessionSettings loadSettings(String... locations) { try { for (String location : locations) { Optional<Resource> resource = load(location); if (resource.isPresent()) { log.info("Loading settings from '{}'", location); return new SessionSettings(resource.get().getInputStream()); } } throw new SettingsNotFoundException("Settings file not found"); } catch (RuntimeException | ConfigError | IOException e) { throw new SettingsNotFoundException(e.getMessage(), e); } } private  SessionSettingsLocator(); static SessionSettings loadSettings(String... locations);  }