// Path: src/main/java/org/fest/util/Lists.java
// public static @NotNull <T> ArrayList<T> newArrayList(@NotNull T... elements) {
//   checkNotNull(elements);
//   ArrayList<T> list = newArrayList();
//   for (T e : elements) {
//     list.add(e);
//   }
//   return list;
// }
// 
// Path: src/main/java/org/fest/util/Sets.java
// public static @NotNull <T> HashSet<T> newHashSet() {
//   return new HashSet<T>();
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @NotNull String concat(@NotNull Object... objects) {
//   checkNotNull(objects);
//   StringBuilder b = new StringBuilder();
//   for (Object o : objects) {
//     b.append(o);
//   }
//   return b.toString();
// }


import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import static java.io.File.separator;
import static org.fest.util.Lists.newArrayList;
import static org.fest.util.Sets.newHashSet;
import static org.fest.util.Strings.concat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.rules.ExpectedException.none;
  }

  @Test
  public void should_return_names_of_files_in_given_directory_but_not_subdirectories() {
    String path = concat("root", separator, "dir_1");
    assertThatContainsFiles(newArrayList("file_1_1", "file_1_2"), Files.fileNamesIn(path, false));
  }

  @Test
  public void should_return_names_of_files_in_given_directory_and_its_subdirectories() {
    String path = concat("root", separator, "dir_1");
    assertThatContainsFiles(newArrayList("file_1_1", "file_1_2", "file_1_1_1"), Files.fileNamesIn(path, true));
  }

  private void assertThatContainsFiles(List<String> expectedFiles, List<String> actualFiles) {
    assertThereAreNoDuplicates(actualFiles);
    for (String fileName : actualFiles) {
      assertTrue(expectedFiles.remove(pathNameFor(fileName)));
    }
    assertTrue(expectedFiles.isEmpty());
  }

  private String pathNameFor(String fileName) {
    return new File(fileName).getName();
  }

  private void assertThereAreNoDuplicates(List<String> actualFiles) {
    if (actualFiles == null || actualFiles.isEmpty()) {
      return;
    }
// Path: src/main/java/org/fest/util/Lists.java
// public static @NotNull <T> ArrayList<T> newArrayList(@NotNull T... elements) {
//   checkNotNull(elements);
//   ArrayList<T> list = newArrayList();
//   for (T e : elements) {
//     list.add(e);
//   }
//   return list;
// }
// 
// Path: src/main/java/org/fest/util/Sets.java
// public static @NotNull <T> HashSet<T> newHashSet() {
//   return new HashSet<T>();
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @NotNull String concat(@NotNull Object... objects) {
//   checkNotNull(objects);
//   StringBuilder b = new StringBuilder();
//   for (Object o : objects) {
//     b.append(o);
//   }
//   return b.toString();
// }


// Path: src/test/java/org/fest/util/Files_fileNamesIn_Test.java
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import static java.io.File.separator;
import static org.fest.util.Lists.newArrayList;
import static org.fest.util.Sets.newHashSet;
import static org.fest.util.Strings.concat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.rules.ExpectedException.none;

  }

  @Test
  public void should_return_names_of_files_in_given_directory_but_not_subdirectories() {
    String path = concat("root", separator, "dir_1");
    assertThatContainsFiles(newArrayList("file_1_1", "file_1_2"), Files.fileNamesIn(path, false));
  }

  @Test
  public void should_return_names_of_files_in_given_directory_and_its_subdirectories() {
    String path = concat("root", separator, "dir_1");
    assertThatContainsFiles(newArrayList("file_1_1", "file_1_2", "file_1_1_1"), Files.fileNamesIn(path, true));
  }

  private void assertThatContainsFiles(List<String> expectedFiles, List<String> actualFiles) {
    assertThereAreNoDuplicates(actualFiles);
    for (String fileName : actualFiles) {
      assertTrue(expectedFiles.remove(pathNameFor(fileName)));
    }
    assertTrue(expectedFiles.isEmpty());
  }

  private String pathNameFor(String fileName) {
    return new File(fileName).getName();
  }

  private void assertThereAreNoDuplicates(List<String> actualFiles) {
    if (actualFiles == null || actualFiles.isEmpty()) {
      return;
    }
    HashSet<String> withoutDuplicates = newHashSet(actualFiles);