MeteredConfigurationSource implements ConfigurationSource { @Override public Properties getConfiguration(Environment environment) { Timer.Context context = getConfigurationTimer.time(); try { return delegate.getConfiguration(environment); } finally { context.stop(); } } MeteredConfigurationSource(MetricRegistry metricRegistry, String metricPrefix, ConfigurationSource delegate); @Override Properties getConfiguration(Environment environment); @Override void init();  }
@Test void getConfigurationCallsDelegate() { Properties properties = new Properties(); when(delegate.getConfiguration(any(Environment.class))).thenReturn(properties); assertThat(source.getConfiguration(new DefaultEnvironment())).isEqualTo(properties); }
@Test void getConfigurationPropagatesMissingEnvironmentExceptions() { when(delegate.getConfiguration(any(Environment.class))).thenThrow(new MissingEnvironmentException("")); assertThatThrownBy(() -> source.getConfiguration(new DefaultEnvironment())).isExactlyInstanceOf(MissingEnvironmentException.class); }
@Test void getConfigurationPropagatesIllegalStateExceptions() { when(delegate.getConfiguration(any(Environment.class))).thenThrow(new IllegalStateException("")); assertThatThrownBy(() -> source.getConfiguration(new DefaultEnvironment())).isExactlyInstanceOf(IllegalStateException.class); }