### Question:
DocumentKey implements Comparable<DocumentKey> { public static DocumentKey fromSegments(List<String> segments) { return new DocumentKey(ResourcePath.fromSegments(segments)); } private  DocumentKey(ResourcePath path); static Comparator<DocumentKey> comparator(); static ImmutableSortedSet<DocumentKey> emptyKeySet(); static DocumentKey empty(); static DocumentKey fromName(String name); static DocumentKey fromPath(ResourcePath path); static DocumentKey fromSegments(List<String> segments); static DocumentKey fromPathString(String path); static boolean isDocumentKey(ResourcePath path); ResourcePath getPath(); boolean hasCollectionId(String collectionId); @Override int compareTo(@NonNull DocumentKey another); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final String KEY_FIELD_NAME; }### Answer:
@Test public void testComparison() { DocumentKey key1 = DocumentKey.fromSegments(asList("a", "b", "c", "d")); DocumentKey key2 = DocumentKey.fromSegments(asList("a", "b", "c", "d")); DocumentKey key3 = DocumentKey.fromSegments(asList("x", "y", "z", "w")); assertEquals(key1, key2); assertNotEquals(key1, key3); DocumentKey empty = DocumentKey.fromSegments(Collections.emptyList()); DocumentKey a = DocumentKey.fromSegments(asList("a", "a")); DocumentKey b = DocumentKey.fromSegments(asList("b", "b")); DocumentKey ab = DocumentKey.fromSegments(asList("a", "a", "b", "b")); new ComparatorTester() .addEqualityGroup(empty) .addEqualityGroup(a) .addEqualityGroup(ab) .addEqualityGroup(b) .testCompare(); }
@Test(expected = Throwable.class) public void testUnevenNumberOfSegmentsAreRejected() { DocumentKey.fromSegments(Collections.singletonList("a")); }