@Test public void comparatorTest() { Comparator<String> comparator = LogSegmentNameHelper.COMPARATOR; assertEquals("Empty names should be equal", 0, comparator.compare("", "")); String[] names = {LogSegmentNameHelper.getName(0, 0), LogSegmentNameHelper.getName(0, 1), LogSegmentNameHelper.getName(1, 0), LogSegmentNameHelper.getName(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, comparator.compare(names[i], names[j])); assertEquals("Unexpected value on compare", -1 * expectCompare, comparator.compare(names[j], names[i])); } } String validName = LogSegmentNameHelper.getName(0, 0); try { comparator.compare(validName, ""); fail("Should not have been able to compare empty name with anything else"); } catch (IllegalArgumentException e) { } try { comparator.compare("", validName); fail("Should not have been able to compare empty name with anything else"); } catch (IllegalArgumentException e) { } }
static String getName(long pos, long gen) { return pos + BlobStore.SEPARATOR + gen; }
LogSegmentNameHelper { static String getName(long pos, long gen) { return pos + BlobStore.SEPARATOR + gen; } }
LogSegmentNameHelper { static String getName(long pos, long gen) { return pos + BlobStore.SEPARATOR + gen; }  }
LogSegmentNameHelper { static String getName(long pos, long gen) { return pos + BlobStore.SEPARATOR + gen; }   }
LogSegmentNameHelper { static String getName(long pos, long gen) { return pos + BlobStore.SEPARATOR + gen; }    }