// Path: cfg4j-core/src/main/java/org/cfg4j/source/ConfigurationSource.java
// public interface ConfigurationSource {
// 
//   /**
//    * Get configuration set for a given {@code environment} from this source in a form of {@link Properties}.
//    * Provided {@link Environment} will be used to determine which environment to use.
//    *
//    * @param environment environment to use
//    * @return configuration set for {@code environment}
//    * @throws MissingEnvironmentException when requested environment couldn't be found
//    * @throws IllegalStateException       when unable to fetch configuration
//    */
//   Properties getConfiguration(Environment environment);
// 
//   /**
//    * Initialize this source. This method has to be called before any other method of this instance.
//    *
//    * @throws IllegalStateException        when source was improperly configured
//    * @throws SourceCommunicationException when unable to communicate with source
//    */
//   void init();
// }
// 
// Path: cfg4j-core/src/main/java/org/cfg4j/source/SourceCommunicationException.java
// public class SourceCommunicationException extends RuntimeException {
// 
//   /**
//    * Indicates problem when communicating with {@link ConfigurationSource}.
//    *
//    * @param msg the detail message
//    * @param e   the cause
//    */
//   public SourceCommunicationException(String msg, Exception e) {
//     super("Unable to communicate with configuration source: " + msg, e);
//   }
// }
// 
// Path: cfg4j-core/src/main/java/org/cfg4j/source/context/environment/DefaultEnvironment.java
// public class DefaultEnvironment extends ImmutableEnvironment {
//   /**
//    * Constructs environment named "" (empty string).
//    */
//   public DefaultEnvironment() {
//     super("");
//   }
// 
//   @Override
//   public String toString() {
//     return "DefaultEnvironment{}";
//   }
// }
// 
// Path: cfg4j-core/src/main/java/org/cfg4j/source/context/environment/Environment.java
// public interface Environment {
// 
//   /**
//    * Name of the environment. Should not be null.
//    *
//    * @return environment name. Not null.
//    */
//   String getName();
// 
// }
// 
// Path: cfg4j-core/src/main/java/org/cfg4j/source/context/environment/MissingEnvironmentException.java
// public class MissingEnvironmentException extends RuntimeException {
// 
//   private static final String MISSING_ENV_MSG = "Missing environment: ";
// 
//   /**
//    * Environment named {@code envName} is missing.
//    *
//    * @param envName environment name
//    */
//   public MissingEnvironmentException(String envName) {
//     super(MISSING_ENV_MSG + envName);
//   }
// 
//   /**
//    * Environment named {@code envName} is missing.
//    *
//    * @param envName environment name
//    * @param cause root cause
//    */
//   public MissingEnvironmentException(String envName, Throwable cause) {
//     super(MISSING_ENV_MSG + envName, cause);
//   }
// }


import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import org.cfg4j.source.ConfigurationSource;
import org.cfg4j.source.SourceCommunicationException;
import org.cfg4j.source.context.environment.DefaultEnvironment;
import org.cfg4j.source.context.environment.Environment;
import org.cfg4j.source.context.environment.MissingEnvironmentException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.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);
  }

  @Test
  void initCallsDelegate() {
    verify(delegate, times(1)).init();
  }

  @Test
  void initPropagatesIllegalStateExceptions() {
    doThrow(new IllegalStateException("")).when(delegate).init();

    assertThatThrownBy(() -> delegate.init()).isExactlyInstanceOf(IllegalStateException.class);
  }

  @Test
  void initPropagatesSourceCommunicationExceptions() {
// Path: cfg4j-core/src/main/java/org/cfg4j/source/ConfigurationSource.java
// public interface ConfigurationSource {
// 
//   /**
//    * Get configuration set for a given {@code environment} from this source in a form of {@link Properties}.
//    * Provided {@link Environment} will be used to determine which environment to use.
//    *
//    * @param environment environment to use
//    * @return configuration set for {@code environment}
//    * @throws MissingEnvironmentException when requested environment couldn't be found
//    * @throws IllegalStateException       when unable to fetch configuration
//    */
//   Properties getConfiguration(Environment environment);
// 
//   /**
//    * Initialize this source. This method has to be called before any other method of this instance.
//    *
//    * @throws IllegalStateException        when source was improperly configured
//    * @throws SourceCommunicationException when unable to communicate with source
//    */
//   void init();
// }
// 
// Path: cfg4j-core/src/main/java/org/cfg4j/source/SourceCommunicationException.java
// public class SourceCommunicationException extends RuntimeException {
// 
//   /**
//    * Indicates problem when communicating with {@link ConfigurationSource}.
//    *
//    * @param msg the detail message
//    * @param e   the cause
//    */
//   public SourceCommunicationException(String msg, Exception e) {
//     super("Unable to communicate with configuration source: " + msg, e);
//   }
// }
// 
// Path: cfg4j-core/src/main/java/org/cfg4j/source/context/environment/DefaultEnvironment.java
// public class DefaultEnvironment extends ImmutableEnvironment {
//   /**
//    * Constructs environment named "" (empty string).
//    */
//   public DefaultEnvironment() {
//     super("");
//   }
// 
//   @Override
//   public String toString() {
//     return "DefaultEnvironment{}";
//   }
// }
// 
// Path: cfg4j-core/src/main/java/org/cfg4j/source/context/environment/Environment.java
// public interface Environment {
// 
//   /**
//    * Name of the environment. Should not be null.
//    *
//    * @return environment name. Not null.
//    */
//   String getName();
// 
// }
// 
// Path: cfg4j-core/src/main/java/org/cfg4j/source/context/environment/MissingEnvironmentException.java
// public class MissingEnvironmentException extends RuntimeException {
// 
//   private static final String MISSING_ENV_MSG = "Missing environment: ";
// 
//   /**
//    * Environment named {@code envName} is missing.
//    *
//    * @param envName environment name
//    */
//   public MissingEnvironmentException(String envName) {
//     super(MISSING_ENV_MSG + envName);
//   }
// 
//   /**
//    * Environment named {@code envName} is missing.
//    *
//    * @param envName environment name
//    * @param cause root cause
//    */
//   public MissingEnvironmentException(String envName, Throwable cause) {
//     super(MISSING_ENV_MSG + envName, cause);
//   }
// }


// Path: cfg4j-core/src/test/java/org/cfg4j/source/metered/MeteredConfigurationSourceTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import org.cfg4j.source.ConfigurationSource;
import org.cfg4j.source.SourceCommunicationException;
import org.cfg4j.source.context.environment.DefaultEnvironment;
import org.cfg4j.source.context.environment.Environment;
import org.cfg4j.source.context.environment.MissingEnvironmentException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.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);
  }

  @Test
  void initCallsDelegate() {
    verify(delegate, times(1)).init();
  }

  @Test
  void initPropagatesIllegalStateExceptions() {
    doThrow(new IllegalStateException("")).when(delegate).init();

    assertThatThrownBy(() -> delegate.init()).isExactlyInstanceOf(IllegalStateException.class);
  }

  @Test
  void initPropagatesSourceCommunicationExceptions() {
    doThrow(new SourceCommunicationException("", null)).when(delegate).init();