title: how to test Comparator at junit test
body: <p>I need to test this method - <code>compare()</code>. Can You get advice? How better I can do this(all part if, else-if, else).</p>
  
  <pre><code>public class AbsFigure {
  
  class AreaCompare implements Comparator&lt;FigureGeneral&gt; {
  
      @Override
      public int compare(FigureGeneral oneFigure, FigureGeneral twoFigure) {
          double firstValue = oneFigure.area();
          double secondValue = twoFigure.area();
          int result = 0;
  
          if (firstValue &gt; secondValue)
              result = 1;
          else if (firstValue &lt; secondValue)
              result = -1;
          else
              result = 0;
  
          return result;
      }
  }
  </code></pre>
  
  <p>After this recomendations - we have next picture (Thank YOU guys a lot!): </p>
  
  <pre><code>public AreaCompare areaCompare = new AreaCompare();
  
  @Test
  public void testEqual() {
      FigureGeneral oneFigure = new Rectangle(2.0, 2.0, "triangle");
      FigureGeneral twoFigure = new Rectangle(2.0, 2.0, "rectangle");
          int result = areaCompare.compare(oneFigure, twoFigure);
          assertTrue("expected to be equal", result == 0);
  }
  
  @Test
  public void testGreaterThan() {
      FigureGeneral oneFigure = new Triangle(2.0, 2.0, "triangle");
      FigureGeneral twoFigure = new Rectangle(1.0, 1.0, "rectangle");
          int result = areaCompare.compare(oneFigure, twoFigure);
          assertTrue("expected to be greater than", result &gt;= 1);
  }
  
  @Test
  public void testLessThan() {
      FigureGeneral oneFigure = new Rectangle(1.0, 1.0, "rectangle");
      FigureGeneral twoFigure = new Triangle(2.0, 2.0, "triangle");
          int result = areaCompare.compare(oneFigure, twoFigure);
          assertTrue("expected to be less than", result &lt;= -1);
  </code></pre>
  
  <p>All is normal testing now.</p>