示例#1
0
 @Test(groups = "ordering")
 public void testIsStrictlyOrdered() {
   assertFalse(
       byLengthOrdering.isStrictlyOrdered(
           Arrays.asList(
               hanSolo.getName(),
               princessLeia.getName(),
               lukeSkywalker.getName(),
               lukeSkywalker.getName())));
 }
示例#2
0
 @Test(groups = "ordering")
 public void testNullsFirst() {
   assertEquals(
       byLengthOrdering
           .nullsFirst()
           .sortedCopy(
               Arrays.asList(
                   hanSolo.getName(), null, lukeSkywalker.getName(), null, princessLeia.getName()))
           .toString(),
       "[null, null, Han Solo, Princess Leia, Luke Skywalker]");
 }
示例#3
0
 @Test(groups = "ordering")
 public void testAdHocOrdering() {
   Ordering<String> byLengthOrdering =
       new Ordering<String>() {
         public int compare(String left, String right) {
           return (left.length() - right.length());
         }
       };
   assertEquals(
       byLengthOrdering.max(hanSolo.getName(), lukeSkywalker.getName(), princessLeia.getName()),
       "Luke Skywalker");
 }
示例#4
0
 public int compare(StarWarsCharacter o1, StarWarsCharacter o2) {
   return o1.getName().compareTo(o2.getName());
 }
示例#5
0
 public int compare(StarWarsCharacter o1, StarWarsCharacter o2) {
   return o1.getEpisodeFirstAppearance().getYear() - o2.getEpisodeFirstAppearance().getYear();
 }