// 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/ImmutableEnvironment.java
// public class ImmutableEnvironment implements Environment {
// 
//   private final String envName;
// 
//   /**
//    * Construct environment named {@code envName}. This name never changes.
//    *
//    * @param envName environment name to use
//    */
//   public ImmutableEnvironment(String envName) {
//     this.envName = requireNonNull(envName);
//   }
// 
//   @Override
//   public String getName() {
//     return envName;
//   }
// 
//   @Override
//   public String toString() {
//     return "ImmutableEnvironment{" +
//         "envName='" + envName + '\'' +
//         '}';
//   }
// }
// 
// 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/main/java/org/cfg4j/source/context/filesprovider/ConfigFilesProvider.java
// public interface ConfigFilesProvider {
// 
//   /**
//    * Provide a list of configuration files to use.
//    * @return {@link Iterable} of configuration {@link File}s to use
//    */
//   Iterable<Path> getConfigFiles();
// 
// }


import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.assertj.core.data.MapEntry;
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.ImmutableEnvironment;
import org.cfg4j.source.context.environment.MissingEnvironmentException;
import org.cfg4j.source.context.filesprovider.ConfigFilesProvider;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.nio.file.Path;
      }
    }

    try (GitConfigurationSource gitConfigurationSource = getSourceForRemoteRepoWithBranchResolver(new Resolver())) {
      Environment environment = new ImmutableEnvironment("ignoreMePlease");

      assertThat(gitConfigurationSource.getConfiguration(environment)).contains(MapEntry.entry("some.setting", "testValue"));
    }
  }

  @Test
  void getConfigurationReadsConfigFromGivenBranch() throws Exception {
    try (GitConfigurationSource gitConfigurationSource = getSourceForRemoteRepoWithDefaults()) {
      Environment environment = new ImmutableEnvironment(TEST_ENV_BRANCH);

      assertThat(gitConfigurationSource.getConfiguration(environment)).contains(MapEntry.entry("some.setting", "testValue"));
    }
  }

  @Test
  void getConfigurationUsesPathResolver() throws Exception {
    class Resolver implements PathResolver {

      @Override
      public Path getPathFor(Environment environment) {
        return Paths.get("otherApplicationConfigs");
      }
    }

    try (GitConfigurationSource gitConfigurationSource = getSourceForRemoteRepoWithPathResolver(new Resolver())) {
// 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/ImmutableEnvironment.java
// public class ImmutableEnvironment implements Environment {
// 
//   private final String envName;
// 
//   /**
//    * Construct environment named {@code envName}. This name never changes.
//    *
//    * @param envName environment name to use
//    */
//   public ImmutableEnvironment(String envName) {
//     this.envName = requireNonNull(envName);
//   }
// 
//   @Override
//   public String getName() {
//     return envName;
//   }
// 
//   @Override
//   public String toString() {
//     return "ImmutableEnvironment{" +
//         "envName='" + envName + '\'' +
//         '}';
//   }
// }
// 
// 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/main/java/org/cfg4j/source/context/filesprovider/ConfigFilesProvider.java
// public interface ConfigFilesProvider {
// 
//   /**
//    * Provide a list of configuration files to use.
//    * @return {@link Iterable} of configuration {@link File}s to use
//    */
//   Iterable<Path> getConfigFiles();
// 
// }


// Path: cfg4j-git/src/test/java/org/cfg4j/source/git/GitConfigurationSourceIntegrationTest.java
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.assertj.core.data.MapEntry;
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.ImmutableEnvironment;
import org.cfg4j.source.context.environment.MissingEnvironmentException;
import org.cfg4j.source.context.filesprovider.ConfigFilesProvider;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.nio.file.Path;

      }
    }

    try (GitConfigurationSource gitConfigurationSource = getSourceForRemoteRepoWithBranchResolver(new Resolver())) {
      Environment environment = new ImmutableEnvironment("ignoreMePlease");

      assertThat(gitConfigurationSource.getConfiguration(environment)).contains(MapEntry.entry("some.setting", "testValue"));
    }
  }

  @Test
  void getConfigurationReadsConfigFromGivenBranch() throws Exception {
    try (GitConfigurationSource gitConfigurationSource = getSourceForRemoteRepoWithDefaults()) {
      Environment environment = new ImmutableEnvironment(TEST_ENV_BRANCH);

      assertThat(gitConfigurationSource.getConfiguration(environment)).contains(MapEntry.entry("some.setting", "testValue"));
    }
  }

  @Test
  void getConfigurationUsesPathResolver() throws Exception {
    class Resolver implements PathResolver {

      @Override
      public Path getPathFor(Environment environment) {
        return Paths.get("otherApplicationConfigs");
      }
    }

    try (GitConfigurationSource gitConfigurationSource = getSourceForRemoteRepoWithPathResolver(new Resolver())) {
      Environment environment = new DefaultEnvironment();