@Test
  public void nameFromFilenameTest() {
    LogSegmentName singleSegmentName = LogSegmentName.fromFilename("log_current");
    assertEquals("Did not get expected name", "", singleSegmentName.toString());
    assertTrue("Should be single segment name", singleSegmentName.isSingleSegment());
    LogSegmentName name = LogSegmentName.fromPositionAndGeneration(0, 0);
    String filename = name.toFilename();
    assertEquals("Did not get expected name", name, LogSegmentName.fromFilename(filename));

    // bad file names
    String badNameBase = TestUtils.getRandomString(10);
    String[] badNames =
        {badNameBase, badNameBase + LogSegmentName.SUFFIX, name + BlobStore.SEPARATOR + "123" + LogSegmentName.SUFFIX};
    for (String badName : badNames) {
      try {
        LogSegmentName.fromFilename(badName);
        fail("Should have failed to get name for filename [" + badName + "]");
      } catch (IllegalArgumentException | StringIndexOutOfBoundsException e) {
        // expected. Nothing to do.
      }
    }
  }
Tests correctness of {@link LogSegmentName#fromFilename(String)}.
ambry-store/src/test/java/com/github/ambry/store/LogSegmentNameTest.java