@Test
  public void logSegmentCustomNamesTest() throws IOException, StoreException {
    int numSegments = (int) (LOG_CAPACITY / SEGMENT_CAPACITY);
    LogSegment segment = getLogSegment(LogSegmentName.fromPositionAndGeneration(0, 0), SEGMENT_CAPACITY, true);
    long startPos = 2 * numSegments;
    List<Pair<LogSegmentName, String>> expectedSegmentAndFileNames = new ArrayList<>(numSegments);
    expectedSegmentAndFileNames.add(new Pair<>(segment.getName(), segment.getView().getFirst().getName()));
    List<Pair<LogSegmentName, String>> segmentNameAndFileNamesDesired = new ArrayList<>();
    LogSegmentName lastName = null;
    for (int i = 0; i < 2; i++) {
      lastName = LogSegmentName.fromPositionAndGeneration(startPos + i, 0);
      String fileName = lastName.toFilename() + "_modified";
      segmentNameAndFileNamesDesired.add(new Pair<>(lastName, fileName));
      expectedSegmentAndFileNames.add(new Pair<>(lastName, fileName));
    }
    for (int i = expectedSegmentAndFileNames.size(); i < numSegments; i++) {
      lastName = lastName.getNextPositionName();
      String fileName = lastName.toFilename();
      expectedSegmentAndFileNames.add(new Pair<>(lastName, fileName));
    }

    Log log = new Log(tempDir.getAbsolutePath(), LOG_CAPACITY, StoreTestUtils.DEFAULT_DISK_SPACE_ALLOCATOR,
        createStoreConfig(SEGMENT_CAPACITY, setFilePermissionEnabled), metrics, true,
        Collections.singletonList(segment), segmentNameAndFileNamesDesired.iterator(), null);
    // write enough so that all segments are allocated
    ByteBuffer buffer = ByteBuffer.allocate((int) (segment.getCapacityInBytes() - segment.getStartOffset()));
    for (int i = 0; i < numSegments; i++) {
      buffer.rewind();
      CHANNEL_APPENDER.append(log, buffer);
    }

    segment = log.getFirstSegment();
    for (Pair<LogSegmentName, String> nameAndFilename : expectedSegmentAndFileNames) {
      assertEquals("Segment name does not match", nameAndFilename.getFirst(), segment.getName());
      assertEquals("Segment file does not match", nameAndFilename.getSecond(), segment.getView().getFirst().getName());
      segment = log.getNextSegment(segment);
    }
    assertNull("There should be no more segments", segment);
  }
Checks that the constructor that receives segments and segment names iterator,
{@link Log#Log(String, long, DiskSpaceAllocator, StoreConfig, StoreMetrics, boolean, List, Iterator, DiskMetrics)}, loads
the segments correctly and uses the iterator to name new segments and uses the default algorithm once the names
run out.
@throws IOException
ambry-store/src/test/java/com/github/ambry/store/LogTest.java