// Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
//   /**
//    * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
//    *
//    * @param from Source path
//    * @param to Target directory path
//    */
//   void copyDirectoryToDirectory(File from, File to) throws IOException;
// 
//   /**
//    * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
//    *
//    * @param from Source path
//    * @param to Target directory path
//    */
//   void copyFileToDirectory(File from, File to) throws IOException;
// 
//   /**
//    * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
//    *   java.nio.file.attribute.FileAttribute[])}
//    *
//    * @param path Path to create
//    */
//   void createDirectories(Path path) throws IOException;
// 
//   /**
//    * {@link java.nio.file.Files#createTempDirectory(
//    * String, java.nio.file.attribute.FileAttribute[])}
//    *
//    * @param dirPrefix prefix of temporary directory
//    * @return Path to created directory
//    */
//   Path createTempDirectory(String dirPrefix) throws IOException;
// 
//   /**
//    * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
//    *
//    * @param file File to delete
//    * @return true iff directory was deleted
//    */
//   boolean deleteQuietly(File file);
// 
//   /**
//    * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
//    *
//    * @param path path to check
//    * @return true iff exists
//    */
//   boolean exists(Path path);
// 
//   /**
//    * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
//    *
//    * @param path path to check
//    * @return true iff path is a directory
//    */
//   boolean isDirectory(Path path);
// 
//   /**
//    * {@link java.lang.ProcessBuilder}
//    *
//    * @param command command to run
//    * @param pwdFile working directory of the process
//    * @return process running the command
//    */
//   Process runCommand(List<String> command, File pwdFile) throws IOException;
// 
//   /**
//    * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
//    * java.nio.file.OpenOption...)}
//    *
//    * @param path Path of file to write to.
//    * @param content String to be written to file.
//    */
//   void write(Path path, String content) throws IOException;
// }
// 
// Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtilsImpl.java
// public class FileUtilsImpl implements FileUtils {
//   private static FileUtilsImpl FILE_UTILS_IMPL = new FileUtilsImpl();
// 
//   @Override
//   public void copyDirectoryToDirectory(File from, File to) throws IOException {
//     org.apache.commons.io.FileUtils.copyDirectoryToDirectory(from, to);
//   }
// 
//   @Override
//   public void copyFileToDirectory(File from, File to) throws IOException {
//     org.apache.commons.io.FileUtils.copyFileToDirectory(from, to);
//   }
// 
//   @Override
//   public void createDirectories(Path path) throws IOException {
//     Files.createDirectories(path);
//   }
// 
//   @Override
//   public Path createTempDirectory(String dirPrefix) throws IOException {
//     return Files.createTempDirectory(dirPrefix);
//   }
// 
//   @Override
//   public boolean deleteQuietly(File file) {
//     return org.apache.commons.io.FileUtils.deleteQuietly(file);
//   }
// 
//   @Override
//   public boolean exists(Path path) {
//     return Files.exists(path);
//   }
// 
//   public static FileUtilsImpl getFileUtilsImpl() {
//     return FILE_UTILS_IMPL;
//   }
// 
//   @Override
//   public boolean isDirectory(Path path) {
//     return Files.isDirectory(path);
//   }
// 
//   @Override
//   public Process runCommand(List<String> command, File pwdFile) throws IOException {
//     ProcessBuilder pb = new ProcessBuilder();
//     pb.command(command).directory(pwdFile);
//     return pb.start();
//   }
// 
//   @Override
//   public void write(Path path, String content) throws IOException {
//     StandardOpenOption[] options = new StandardOpenOption[3];
// 
//     options[0] = StandardOpenOption.CREATE;
//     options[1] = StandardOpenOption.WRITE;
//     options[2] = StandardOpenOption.APPEND;
// 
//     Collection<String> lines = new ArrayList<>();
//     lines.add(content);
//     Files.write(path, lines, Charset.defaultCharset(), options);
//   }
// }


import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.NoSuchElementException;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.FileUtilsImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package me.gregorias.dfuntest;



/**
 * Factory of {@link LocalEnvironment} working in local temporary directories.
 *
 * @author Grzegorz Milka
 */
public class LocalEnvironmentFactory implements EnvironmentFactory<Environment> {
  public static final String ENV_COUNT_ARGUMENT_NAME = "LocalEnvironmentFactory.environmentCount";
  public static final String DIR_PREFIX_ARGUMENT_NAME = "LocalEnvironmentFactory.dirPrefix";
  private static final Logger LOGGER = LoggerFactory.getLogger(LocalEnvironmentFactory.class);
  private static final String ENV_CONFIG_ROOT_DIR = "localEnvironmentFactoryRootDir";

  private final int mEnvironmentCount;
  private final String mDirPrefix;
// Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
//   /**
//    * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
//    *
//    * @param from Source path
//    * @param to Target directory path
//    */
//   void copyDirectoryToDirectory(File from, File to) throws IOException;
// 
//   /**
//    * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
//    *
//    * @param from Source path
//    * @param to Target directory path
//    */
//   void copyFileToDirectory(File from, File to) throws IOException;
// 
//   /**
//    * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
//    *   java.nio.file.attribute.FileAttribute[])}
//    *
//    * @param path Path to create
//    */
//   void createDirectories(Path path) throws IOException;
// 
//   /**
//    * {@link java.nio.file.Files#createTempDirectory(
//    * String, java.nio.file.attribute.FileAttribute[])}
//    *
//    * @param dirPrefix prefix of temporary directory
//    * @return Path to created directory
//    */
//   Path createTempDirectory(String dirPrefix) throws IOException;
// 
//   /**
//    * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
//    *
//    * @param file File to delete
//    * @return true iff directory was deleted
//    */
//   boolean deleteQuietly(File file);
// 
//   /**
//    * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
//    *
//    * @param path path to check
//    * @return true iff exists
//    */
//   boolean exists(Path path);
// 
//   /**
//    * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
//    *
//    * @param path path to check
//    * @return true iff path is a directory
//    */
//   boolean isDirectory(Path path);
// 
//   /**
//    * {@link java.lang.ProcessBuilder}
//    *
//    * @param command command to run
//    * @param pwdFile working directory of the process
//    * @return process running the command
//    */
//   Process runCommand(List<String> command, File pwdFile) throws IOException;
// 
//   /**
//    * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
//    * java.nio.file.OpenOption...)}
//    *
//    * @param path Path of file to write to.
//    * @param content String to be written to file.
//    */
//   void write(Path path, String content) throws IOException;
// }
// 
// Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtilsImpl.java
// public class FileUtilsImpl implements FileUtils {
//   private static FileUtilsImpl FILE_UTILS_IMPL = new FileUtilsImpl();
// 
//   @Override
//   public void copyDirectoryToDirectory(File from, File to) throws IOException {
//     org.apache.commons.io.FileUtils.copyDirectoryToDirectory(from, to);
//   }
// 
//   @Override
//   public void copyFileToDirectory(File from, File to) throws IOException {
//     org.apache.commons.io.FileUtils.copyFileToDirectory(from, to);
//   }
// 
//   @Override
//   public void createDirectories(Path path) throws IOException {
//     Files.createDirectories(path);
//   }
// 
//   @Override
//   public Path createTempDirectory(String dirPrefix) throws IOException {
//     return Files.createTempDirectory(dirPrefix);
//   }
// 
//   @Override
//   public boolean deleteQuietly(File file) {
//     return org.apache.commons.io.FileUtils.deleteQuietly(file);
//   }
// 
//   @Override
//   public boolean exists(Path path) {
//     return Files.exists(path);
//   }
// 
//   public static FileUtilsImpl getFileUtilsImpl() {
//     return FILE_UTILS_IMPL;
//   }
// 
//   @Override
//   public boolean isDirectory(Path path) {
//     return Files.isDirectory(path);
//   }
// 
//   @Override
//   public Process runCommand(List<String> command, File pwdFile) throws IOException {
//     ProcessBuilder pb = new ProcessBuilder();
//     pb.command(command).directory(pwdFile);
//     return pb.start();
//   }
// 
//   @Override
//   public void write(Path path, String content) throws IOException {
//     StandardOpenOption[] options = new StandardOpenOption[3];
// 
//     options[0] = StandardOpenOption.CREATE;
//     options[1] = StandardOpenOption.WRITE;
//     options[2] = StandardOpenOption.APPEND;
// 
//     Collection<String> lines = new ArrayList<>();
//     lines.add(content);
//     Files.write(path, lines, Charset.defaultCharset(), options);
//   }
// }


// Path: core/src/main/java/me/gregorias/dfuntest/LocalEnvironmentFactory.java
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.NoSuchElementException;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.FileUtilsImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

package me.gregorias.dfuntest;



/**
 * Factory of {@link LocalEnvironment} working in local temporary directories.
 *
 * @author Grzegorz Milka
 */
public class LocalEnvironmentFactory implements EnvironmentFactory<Environment> {
  public static final String ENV_COUNT_ARGUMENT_NAME = "LocalEnvironmentFactory.environmentCount";
  public static final String DIR_PREFIX_ARGUMENT_NAME = "LocalEnvironmentFactory.dirPrefix";
  private static final Logger LOGGER = LoggerFactory.getLogger(LocalEnvironmentFactory.class);
  private static final String ENV_CONFIG_ROOT_DIR = "localEnvironmentFactoryRootDir";

  private final int mEnvironmentCount;
  private final String mDirPrefix;
  private final FileUtils mFileUtils;