title: JUnit Test for Comparator in Java
body: <p>How can I test the following class using JUnit testing. I am new to unit testing I just need a push to start </p>
  
  <pre><code>public class ComponentComparator implements Comparator&lt; Component &gt;
  {
  
  @Override
  public int compare ( final Component c1, final Component c2 )
  {
      if ( c1.getBandwidthWithHeader() &gt; c2.getBandwidthWithHeader() )
      {
          return -1;
      }
      else if ( c1.getBandwidthWithHeader() &lt; c2.getBandwidthWithHeader() )
      {
          return 1;
      }
      return 0;
  }
  }
  </code></pre>
  
  <p>Part of the component class is, there is no constructor for this class</p>
  
  <pre><code>public class Component
  {
     private float bandwidthwithHeader;
  
     public void setBandwidthWithHeader ( float bandwidthwithHeader )
     {
         this.bandwidthwithHeader = bandwidthwithHeader;
     }
     public float getBandwidthWithHeader ()
     {
         return this.bandwidthwithHeader;
     }     
  }
  </code></pre>