title: How to test Comparator using Junit Test?
body: <p>Assuming i do not change the current way of my compare method, how can i create a test for this properly? I am struggling to understand how.</p>
  <p>I need to test the below:</p>
  <pre><code>public class MemberComparator implements Comparator&lt;Member&gt; {
  
  private final String clientId;
  
  public MemberComparator(String clientId) {
      this.clientId = clientId;
  }
  
  @Override
  public int compare(Member m1, Member m2) {
      if (m1.getClientId().startsWith(clientId)) {
          return m2.getClientId().startsWith(clientId) ? m1.getClientId().compareTo(m2.getClientId())
                  : -1;
      } else {
          return m2.getClientId().startsWith(clientId) ? 1
                  : m1.getClientId().compareTo(m2.getClientId());
      }
  }
  </code></pre>
  <p>}</p>
  <p>So far i have created this test, but i get an error. Can someone show how i can get this to work?</p>
  <pre><code>class MemberComparatorTest {
  
  //private MemberComparator caseID_test;
  private final MemberComparator memberComparator = new MemberComparator(&quot;jake&quot;);
  
  @Test
  void testEqual() {
      Member m1 = new Member();
      Member m2 = new Member();
      int result = memberComparator.compare(m1,m2);
      //assertTrue(&quot;expected to be equal&quot;, result == 0);
  
  }
  </code></pre>
  <p>}</p>