@Test public void fails_when_incorrect_values_provided() { Map<String, Object> options = new HashMap<>(); options.put("period", 2); options.put("timeunit", "ERR"); try { HeartbeatConfiguration.create(options); } catch (Exception e) { assertThat(e).isInstanceOf(ConstructorException.class); } }
public static HeartbeatConfiguration create(Map<String, Object> options) throws ConfigurationException { HeartbeatConfiguration conf = new HeartbeatConfiguration(); Yaml yaml = new Yaml(); String str = yaml.dumpAsMap(options); conf.values = yaml.loadAs(str, HeartbeatConfiguration.Values.class); return conf; }
HeartbeatConfiguration { public static HeartbeatConfiguration create(Map<String, Object> options) throws ConfigurationException { HeartbeatConfiguration conf = new HeartbeatConfiguration(); Yaml yaml = new Yaml(); String str = yaml.dumpAsMap(options); conf.values = yaml.loadAs(str, HeartbeatConfiguration.Values.class); return conf; } }
HeartbeatConfiguration { public static HeartbeatConfiguration create(Map<String, Object> options) throws ConfigurationException { HeartbeatConfiguration conf = new HeartbeatConfiguration(); Yaml yaml = new Yaml(); String str = yaml.dumpAsMap(options); conf.values = yaml.loadAs(str, HeartbeatConfiguration.Values.class); return conf; } private  HeartbeatConfiguration(); }
HeartbeatConfiguration { public static HeartbeatConfiguration create(Map<String, Object> options) throws ConfigurationException { HeartbeatConfiguration conf = new HeartbeatConfiguration(); Yaml yaml = new Yaml(); String str = yaml.dumpAsMap(options); conf.values = yaml.loadAs(str, HeartbeatConfiguration.Values.class); return conf; } private  HeartbeatConfiguration(); static HeartbeatConfiguration create(Map<String, Object> options); int period(); TimeUnit timeunit(); long reportingRateInMillis(); }
HeartbeatConfiguration { public static HeartbeatConfiguration create(Map<String, Object> options) throws ConfigurationException { HeartbeatConfiguration conf = new HeartbeatConfiguration(); Yaml yaml = new Yaml(); String str = yaml.dumpAsMap(options); conf.values = yaml.loadAs(str, HeartbeatConfiguration.Values.class); return conf; } private  HeartbeatConfiguration(); static HeartbeatConfiguration create(Map<String, Object> options); int period(); TimeUnit timeunit(); long reportingRateInMillis();  }