### Question:
LogSegmentNameHelper { static String getName(long pos, long gen) { return pos + BlobStore.SEPARATOR + gen; }    }### Answer:
@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) { } }
@Test public void getNameTest() { for (int i = 0; i < 10; i++) { long pos = Utils.getRandomLong(TestUtils.RANDOM, 1000); long gen = Utils.getRandomLong(TestUtils.RANDOM, 1000); assertEquals("Did not get expected name", pos + BlobStore.SEPARATOR + gen, LogSegmentNameHelper.getName(pos, gen)); } }