@Test public void shouldFailToLoadConfigurationThatHasZeroMinEntriesToSnapshot() throws IOException, RaftConfigurationException { String configFilePath = Resources.getResource("fixtures/config.minimal_fields_zero_min_entries_to_snapshot.bad.json").getPath(); expectedException.expect(RaftConfigurationException.class); RaftConfigurationLoader.loadFromFile(configFilePath); }
public static RaftConfiguration loadFromFile(String configFile) throws IOException { File config = new File(configFile); if (!config.exists() || !config.canRead()) { throw new IOException(String.format("%s cannot be opened", config)); } ObjectMapper mapper = new ObjectMapper(); RaftConfiguration configuration = mapper.readValue(config, RaftConfiguration.class); return validate(configuration); }
RaftConfigurationLoader { public static RaftConfiguration loadFromFile(String configFile) throws IOException { File config = new File(configFile); if (!config.exists() || !config.canRead()) { throw new IOException(String.format("%s cannot be opened", config)); } ObjectMapper mapper = new ObjectMapper(); RaftConfiguration configuration = mapper.readValue(config, RaftConfiguration.class); return validate(configuration); } }
RaftConfigurationLoader { public static RaftConfiguration loadFromFile(String configFile) throws IOException { File config = new File(configFile); if (!config.exists() || !config.canRead()) { throw new IOException(String.format("%s cannot be opened", config)); } ObjectMapper mapper = new ObjectMapper(); RaftConfiguration configuration = mapper.readValue(config, RaftConfiguration.class); return validate(configuration); } private  RaftConfigurationLoader(); }
RaftConfigurationLoader { public static RaftConfiguration loadFromFile(String configFile) throws IOException { File config = new File(configFile); if (!config.exists() || !config.canRead()) { throw new IOException(String.format("%s cannot be opened", config)); } ObjectMapper mapper = new ObjectMapper(); RaftConfiguration configuration = mapper.readValue(config, RaftConfiguration.class); return validate(configuration); } private  RaftConfigurationLoader(); static RaftConfiguration loadFromFile(String configFile); static RaftConfiguration validate(RaftConfiguration configuration); }
RaftConfigurationLoader { public static RaftConfiguration loadFromFile(String configFile) throws IOException { File config = new File(configFile); if (!config.exists() || !config.canRead()) { throw new IOException(String.format("%s cannot be opened", config)); } ObjectMapper mapper = new ObjectMapper(); RaftConfiguration configuration = mapper.readValue(config, RaftConfiguration.class); return validate(configuration); } private  RaftConfigurationLoader(); static RaftConfiguration loadFromFile(String configFile); static RaftConfiguration validate(RaftConfiguration configuration);  }