@Test
  public void comparatorTest() {
    // compare empty name with empty name
    assertEquals("Empty names should be equal", 0,
        LogSegmentName.fromString("").compareTo(LogSegmentName.fromString("")));
    // create sample names
    LogSegmentName[] names =
        {LogSegmentName.fromPositionAndGeneration(0, 0), LogSegmentName.fromPositionAndGeneration(0, 1),
            LogSegmentName.fromPositionAndGeneration(1, 0), LogSegmentName.fromPositionAndGeneration(1, 1)};
    for (int i = 0; i < names.length; i++) {
      for (int j = 0; j < names.length; j++) {
        int expectCompare = Integer.compare(i, j);
        assertEquals("Unexpected value on compare", expectCompare, names[i].compareTo(names[j]));
        assertEquals("Unexpected value on compare", -1 * expectCompare, names[j].compareTo(names[i]));
      }
    }
    // empty name cannot be compared with anything else
    LogSegmentName validName = LogSegmentName.fromPositionAndGeneration(0, 0);
    try {
      validName.compareTo(LogSegmentName.fromString(""));
      fail("Should not have been able to compare empty name with anything else");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do.
    }
    try {
      LogSegmentName.fromString("").compareTo(validName);
      fail("Should not have been able to compare empty name with anything else");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do.
    }
  }
Tests the comparator in {@link LogSegmentName} for correctness.
ambry-store/src/test/java/com/github/ambry/store/LogSegmentNameTest.java