title: How to make two objects equal to pass assertEquals()?
body: <p>So I have this code:</p>
  
  <pre><code>Item i = new Item(ID, TITLE, DESCRIPTION) { };
  Item i2 = new Item(ID, "", "") { };
  assertEquals("Item(id=1)", i.toString());
  assertEquals("Item(id=1)", i2.toString());
  assertNotSame(i, i2);
  assertEquals(i, i2);
  assertThat(0, not(equalTo(i.compareTo(i2))));
  
  Item i3 = new Item(BigInteger.TEN, "", "") { };
  assertEquals("Item(id=10)", i3.toString());
  assertNotSame(i, i3);
  assertThat(i, not(equalTo(i3)));
  </code></pre>
  
  <p>Also provided that:</p>
  
  <pre><code>@Override
  public final int compareTo(final Item o) {
      int c = o.title.compareTo(title);
      if (c == 0) {
          c = o.id.compareTo(id);
      }
      return c;
  }
  </code></pre>
  
  <p>It passes <code>assertNotSame(i, i2);</code> but fails at <code>assertEquals(i, i2);</code> I've tried to override <code>toString()</code> method, but that didn't help. It was actually written that <code>Item(id=1)</code> was expected and it got exactly <code>Item(id=1)</code> but there is still a problem. </p>
  
  <p>I saw suggestions in other threads to override the <code>equals</code> method but don't really know how to do that.</p>