title: How can I assert on a Java Hashmap of Arrays?
body: <p>I'm building a new hashmap ( &lt; String , String[] > ) by combining three other hashmaps ( &lt; String , String > ) and adding the filename.  How do I assert the new hashmap is correct?  The nested array is making the test fail.</p>
  
  <p>This code is a simplified example of my failing test:</p>
  
  <pre><code>@Test
  public void injectArrayIntoHashMap() {
    HashMap map = new HashMap();
    map.put("hi", new String[] { "hello", "howdy" });
  
    HashMap newMap = new HashMap();
    newMap.put("hi", new String[] { "hello", "howdy" });
  
    assertEquals(map, newMap);
  }
  </code></pre>
  
  <p><strong>UPDATE:</strong>  Okay, based on Hna's advice, I got the test working with an ArrayList.  However, I then realized I needed to instantiate an object inside of the ArrayList and now the test is failing.  It seems to have to do with the fact that the objects inside the ArrayList have different memory addresses.  I'm new to Java and inserting the object in the ArrayList this was my attempt to avoid an "if" statement.  Is there a better way?  Or just an easy answer to making my test pass?</p>
  
  <p>Here is the new code:</p>
  
  <pre><code>@Test
  public void sampleTest() throws IOException {
    HashMap expectedResult = new HashMap();
    expectedResult.put("/images",                   new ArrayList(Arrays.asList("/images", new Public())));
    expectedResult.put("/stylesheets",              new ArrayList(Arrays.asList("/stylesheets", new Public())));
  
    HashMap actualResult = test();
  
    assertEquals(expectedResult, actualResult);
  }
  
  public HashMap test() {
    HashMap hashMap = new HashMap();
    hashMap.put("/images",      new ArrayList(Arrays.asList("/images",      new Public())));
    hashMap.put("/stylesheets", new ArrayList(Arrays.asList("/stylesheets", new Public())));
    return hashMap;
  }
  </code></pre>