title: JUnit assertEquals failing with HashSet
body: <p>I was doing some JUnit tests for the  <a href="https://se-edu.github.io/addressbook-level4/" rel="nofollow noreferrer">AddressBook</a>
  and kept failing to implement one of my tests. Here is that test:</p>
  
  <pre><code>@Test
  public void parseIndices_collectionWithValidIndices_returnsIndexSet() throws Exception {
      Set&lt;Index&gt; actualIndexSet = ParserUtil.parseIndices(Arrays.asList(VALID_INDEX_1, VALID_INDEX_2));
  
      Index index = Index.fromOneBased(Integer.valueOf(VALID_INDEX_1));
      Index index2 = Index.fromOneBased(Integer.valueOf(VALID_INDEX_2));
      Set&lt;Index&gt; expectedIndexSet = new HashSet&lt;&gt;();
      expectedIndexSet.add(index);
      expectedIndexSet.add(index2);
  
      assertEquals(expectedIndexSet, actualIndexSet);
  }
  </code></pre>
  
  <p>The output shows as follows: </p>
  
  <p><a href="https://i.stack.imgur.com/jZIbL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jZIbL.png" alt="Output of running test"></a>
  It shows that they are equal but somehow the assert keeps failing. I then tried asserting the 2 actualIndexSets (as shown below) to see if they would pass the test but it still failed with the same result which is weird.</p>
  
  <pre><code>@Test
  public void parseIndices_collectionWithValidIndices_returnsIndexSet() throws Exception {
      Set&lt;Index&gt; actualIndexSet = ParserUtil.parseIndices(Arrays.asList(VALID_INDEX_1, VALID_INDEX_2));
      Set&lt;Index&gt; actualIndexSet2 = ParserUtil.parseIndices(Arrays.asList(VALID_INDEX_1, VALID_INDEX_2));
  
      Index index = Index.fromOneBased(Integer.valueOf(VALID_INDEX_1));
      Index index2 = Index.fromOneBased(Integer.valueOf(VALID_INDEX_2));
      Set&lt;Index&gt; expectedIndexSet = new HashSet&lt;&gt;();
      expectedIndexSet.add(index);
      expectedIndexSet.add(index2);
  
      assertEquals(actualIndexSet2, actualIndexSet);
  }
  </code></pre>
  
  <p>The problem here is that something is obviously not right because it fails when I assert 2 sets of the actualIndexSet which are the same given that assert for the Index class is working fine.</p>