@Test
  public void testUnsegmentedLogInitWithExistingSegment() throws Exception {
    File segmentFile = new File(tempDir, LogSegmentName.fromPositionAndGeneration(0, 0).toFilename());
    assert segmentFile.createNewFile();
    DiskSpaceAllocator mockDiskSpaceAllocator = mock(DiskSpaceAllocator.class);
    StoreConfig storeConfig = createStoreConfig(SEGMENT_CAPACITY, setFilePermissionEnabled);

    Log log =
        new Log(tempDir.getAbsolutePath(), SEGMENT_CAPACITY, mockDiskSpaceAllocator, storeConfig, metrics, null, false);
    assertEquals("Remaining unallocated segments mismatch", 0, log.getRemainingUnallocatedSegments());
  }
Tests the initialization of an unsegmented log when a segment already exists in the directory.
Verifies that the remaining unallocated segments is set to 0, as the segment already exists.
@throws Exception if an error occurs during the test.
ambry-store/src/test/java/com/github/ambry/store/LogTest.java