@Test
  public void filenameFilterTest() throws IOException {
    int validFileCount = 10;
    int invalidFileCount = 5;
    Set<File> validFiles = new HashSet<>(validFileCount);
    File tempDir = Files.createTempDirectory("nameHelper-" + TestUtils.getRandomString(10)).toFile();
    tempDir.deleteOnExit();
    try {
      String filename = LogSegmentName.fromString("").toFilename();
      File file = createFile(tempDir, filename);
      validFiles.add(file);
      for (int i = 1; i < validFileCount; i++) {
        filename = StoreTestUtils.getRandomLogSegmentName(null).toFilename();
        file = createFile(tempDir, filename);
        validFiles.add(file);
      }
      for (int i = 0; i < invalidFileCount; i++) {
        filename = TestUtils.getRandomString(10);
        switch (i) {
          case 0:
            filename = filename + "_index";
            break;
          case 1:
            filename = filename + LogSegmentName.SUFFIX + "_temp";
            break;
          default:
            break;
        }
        createFile(tempDir, filename);
      }
      Set<File> filteredFiles = new HashSet<>(Arrays.asList(tempDir.listFiles(LogSegmentName.LOG_FILE_FILTER)));
      assertEquals("Filtered files do not have the valid files", validFiles, filteredFiles);
    } finally {
      File[] files = tempDir.listFiles();
      if (files != null) {
        for (File file : files) {
          assertTrue("The file [" + file.getAbsolutePath() + "] could not be deleted", file.delete());
        }
      }
      assertTrue("The directory [" + tempDir.getAbsolutePath() + "] could not be deleted", tempDir.delete());
    }
  }
Checks the file name filter in {@link LogSegmentName} for correctness by creating valid and invalid files
and checking that the invalid ones are filtered out and the valid ones correctly picked up.
@throws IOException
ambry-store/src/test/java/com/github/ambry/store/LogSegmentNameTest.java