CustomMetricsConfigurationFactory { public static CustomMetricsConfiguration create() { return create(System.getenv()); }  static CustomMetricsConfiguration create(); static CustomMetricsConfiguration create(Map<String, String> env);  }
@Test public void testMatches_WithEnv() throws Exception { EnvUtils.setEnvs(new String[][] { getCustomMetricsEnv("20000") }); CustomMetricsConfiguration config = CustomMetricsConfigurationFactory.create(); assertFalse(config.isEnabled()); assertEquals(20_000, config.getInterval()); List<String> metrics = config.getMetrics(); assertEquals(2, metrics.size()); assertTrue(metrics.contains("timer")); assertTrue(metrics.contains("summary")); assertTrue(config.metricQuantiles()); }
@Test public void testMatches_WithShortIntervalEnv() throws Exception { EnvUtils.setEnvs(new String[][] { getCustomMetricsEnv("1000") }); CustomMetricsConfiguration config = CustomMetricsConfigurationFactory.create(); assertFalse(config.isEnabled()); assertEquals(CustomMetricsConfiguration.DEFAULT_INTERVAL, config.getInterval()); List<String> metrics = config.getMetrics(); assertEquals(2, metrics.size()); assertTrue(metrics.contains("timer")); assertTrue(metrics.contains("summary")); }
@Test(expected = NumberFormatException.class) public void testMatches_WrongIntervalFormat() throws Exception { EnvUtils.setEnvs(new String[][] { getCustomMetricsEnv("wronginterval") }); CustomMetricsConfigurationFactory.create(); }
@Test public void testMatches_WithEnv() throws Exception { EnvUtils.setEnvs(new String[][] { getCustomMetricsEnv() }); CustomMetricsConfiguration config = CustomMetricsConfigurationFactory.create(); System.out.println(config); assertFalse(config.isEnabled()); assertEquals(1000, config.getInterval()); List<String> metrics = config.getMetrics(); assertEquals(2, metrics.size()); assertTrue(metrics.contains("timer")); assertTrue(metrics.contains("summary")); }