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