MostToLeastDerivedPlaceTypeComparator implements Comparator<TypeElement> { @Override public int compare(TypeElement o1, TypeElement o2) { return realComparator.compare(o1, o2); }  @Override int compare(TypeElement o1, TypeElement o2);  }
@Test public void testEquality() { for (TypeElement p : new TypeElement[] {place, place1, place2, place3, place4, place5}) { assertThat(comparator.compare(p, p)).isEqualTo(0); } }
@Test public void testPlaceComparesGreaterThanAnyDerivedClass() { for (TypeElement p : new TypeElement[] {place1, place2, place3, place4, place5}) { assertThat(comparator.compare(place, p)) .named(String.format("compare(place, %s)", p)) .isGreaterThan(0); assertThat(comparator.compare(p, place)) .named(String.format("compare(%s, place)", p)) .isLessThan(0); } }
@Test public void testPlaceInheritanceOrder() { assertThat(comparator.compare(place1, place3)).isGreaterThan(0); assertThat(comparator.compare(place3, place1)).isLessThan(0); assertThat(comparator.compare(place1, place5)).isGreaterThan(0); assertThat(comparator.compare(place5, place1)).isLessThan(0); assertThat(comparator.compare(place1, place4)).isGreaterThan(0); assertThat(comparator.compare(place4, place1)).isLessThan(0); assertThat(comparator.compare(place3, place5)).isGreaterThan(0); assertThat(comparator.compare(place5, place3)).isLessThan(0); }
@Test public void testFallbackToClassName() { TypeElement[][] places = { {place3, place4}, {place1, place2}, }; for (TypeElement[] pair : places) { assertThat(comparator.compare(pair[0], pair[1])) .named(String.format("compare(%s, %s)", pair[0], pair[1])) .isLessThan(0); assertThat(comparator.compare(pair[1], pair[0])) .named(String.format("compare(%s, %s)", pair[1], pair[0])) .isGreaterThan(0); } }