View Javadoc

1   package com.google.code.jetm.maven.util;
2   
3   import static org.fest.assertions.Assertions.assertThat;
4   import static org.mockito.Mockito.mock;
5   import static org.mockito.Mockito.when;
6   
7   import org.junit.Test;
8   
9   import etm.core.aggregation.Aggregate;
10  
11  /**
12   * Unit tests for {@link AggregateComparator}.
13   * 
14   * @author jrh3k5
15   * 
16   */
17  
18  public class AggregateComparatorTest {
19      private final AggregateComparator comparator = new AggregateComparator();
20  
21      /**
22       * Test the comparison of two {@link Aggregate} objects by their names when they are different. Normally, the one with the lower-case letters would be the greater one but, because of the initial
23       * case-insensitive comparison, the lower-case one is considered to be the lesser ("C" < "D").
24       */
25      @Test
26      public void testCompareDifferentNames() {
27          final Aggregate lesser = mock(Aggregate.class);
28          when(lesser.getName()).thenReturn("abc");
29  
30          final Aggregate greater = mock(Aggregate.class);
31          when(greater.getName()).thenReturn("ABD");
32          
33          assertThat(comparator.compare(lesser, greater)).isNegative();
34          assertThat(comparator.compare(greater, lesser)).isPositive();
35          assertThat(comparator.compare(greater, greater)).isZero();
36          assertThat(comparator.compare(lesser, lesser)).isZero();
37      }
38  }